1
3
5 3 4
 6
5
5 3 4 4 5
3
1 1 1
5
4 4 3 4 4
5
5 5 4 3 2
3
1 1 2
5
5 4 3 5 5
 1
3
10 1 5

1
 1
-1
2
2
3
1
 1

#include <bits/stdc++.h>
const long long hellc = 998244353;
const long long SZ = 100010;
long long op = 1;
using namespace std;
void yehbhikrnapadega() {}
long long gcd(long long a, long long b) {
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }
void krdiyasuru() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  map<long long, long long> chk;
  for (long long i = 0; i < (n); i++) {
    cin >> a[i];
    chk[a[i]]++;
  }
  if ((long long)chk.size() == 1) {
    cout << -1 << '\n';
    return;
  } else {
    cout << a[n / 2] << '\n';
    return;
  }
  return;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long ___T;
  cin >> ___T;
  while (___T-- > 0) {
    krdiyasuru();
  }
  return 0;
}
