Help me in solving MISSP problem

My issue

include
using namespace std;

int main() {
int t;
cin>>t;
while(t–)
{
int n;
cin>>n;
int a[n];
for (int i=0;i<n;i++)
{
cin>>a[i];
}
for(int i=0;i<n;i++)
{
int f=1;
for (int j=0;j<n;j++)
{
if(a[i]==a[j] && i!=j)
{
f++;
}
}
if(f%2!=0)
{
cout<<a[i]<<“\n”;
}
}
}
return 0;
}

why I am getting the wrong answer??

My code

#include <iostream>
using namespace std;

int main() {
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
int a[n];
for (int i=0;i<n;i++)
{
cin>>a[i];
}
for(int i=0;i<n;i++)
{
int f=1;
for (int j=0;j<n;j++)
{
if(a[i]==a[j] && i!=j)
{
f++;
}
}
if(f%2!=0)
{
cout<<a[i]<<"\n";
}
}
}
return 0;
}

Problem Link: MISSP Problem - CodeChef

@tushar_rao210
U have to print break after printing the answer to get out of the loop;
like this

#include <iostream>
using namespace std;

int main() {
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
int a[n];
for (int i=0;i<n;i++)
{
cin>>a[i];
}

for(int i=0;i<n;i++)
{
int f=1;
for (int j=0;j<n;j++)
{
if(a[i]==a[j] && i!=j)
{
f++;
}
}
if(f%2!=0)
{
cout<<a[i]<<"\n";
break;
}
}
}
return 0;
}