Help me in solving MISSP problem

My issue

include <bits/stdc++.h>
using namespace std;

int main() {
// your code goes here
int t;
cin >> t;
while(t–) {
int n;
cin >> n;
int a[100000] = {0};
for(int i = 0; i <= n; i++){
cin >> a[i];
}
int count = 0;
for(int i = 0; i < n; i++){

    for(int j = 0; j< n; j++){
        if(a[i] == a[j]){
            count++;
        }
    }
    if(count % 2 == 1){
        cout << a[i] ;
        break;
    }
}
}

}
this is my approach and it is not working

My code

#include <bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
	int t;
	cin >> t;
	while(t--) {
	    int n;
	    cin >> n;
	    int a[100000] = {0};
	    for(int i = 0; i <= n; i++){
	        cin >> a[i];
	    }
	    int count = 0;
    for(int i = 0; i < n; i++){
        
        for(int j = 0; j< n; j++){
            if(a[i] == a[j]){
                count++;
            }
        }
        if(count % 2 == 1){
            cout << a[i] ;
            break;
        }
	}
    }
}

Problem Link: Chef and Dolls Practice Coding Problem