Find the Spy
#include<iostream>
#include<algorithm>
#define maxn 105
#define maxsize 100000000
using namespace std;
int n,cas,i,j,ans;
int a[maxn];
bool ishas[maxsize];
bool compare(int a,int b)
{
return a < b;
}
int main(void)
{
cin >> cas;
while(cas --)
{
cin >> n;
for(i = 0;i < n;i ++){
cin >> a[i];
}
sort(a,a+n,compare);
if(a[0] != a[1])
ans = a[0];
else if(a[n-1] != a[n-2])
ans = a[n-1];
else
{
for(i = 1;i < n-1;i ++)
{
if(a[i] != a[i-1]&&a[i] != a[i+1])
ans = a[i];
}
}
cout << ans << endl;
}
return 0;
}