#include <bits/stdc++.h>

using namespace std;

void solve(){
    int n;
    cin >> n;
    map<int, int> mp;
    for(int i = 0; i < n; ++i){
        int x;
        cin >> x;
        mp[x]++;
    }
    for(auto [x, y] : mp){
        if(y & 1){
            cout << x << '\n';
            return;
        }
    }
    cout << "-1\n";
}

int main() {
    ios_base::sync_with_stdio(false);
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    int t;
    cin >> t;
    while(t--)
    solve();
    // TIP See CLion help at <a href="https://www.jetbrains.com/help/clion/">jetbrains.com/help/clion/</a>. Also, you can try interactive lessons for CLion by selecting 'Help | Learn IDE Features' from the main menu.
}