#include <bits/stdc++.h>

#ifndef This_is_Kunteynir
#define dbg(...)
#endif

#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2,bmi")

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define len(x) ((int)x.size())

using namespace std;
using ll = long long;
using ld = long double;
using i128 = __int128;

void solve() {
    int n;
    cin >> n;
    vector <int> a(n);
    for (int i = 0; i < n; ++i){
        cin >> a[i];
    }
    sort(all(a));
    a.push_back(-1);
    int last = 0;
    for (int i = 1; i <= n; ++i){
        if (a[i] != a[i - 1]){
            if ((i - last) & 1){
                cout << a[i - 1];
                return;
            }
            last = i;
        }
    }
    cout << -1;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int _ = 1;
    cin >> _;
    while (_--) {
        solve();
        cout << '\n';
    }
}
