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>
using namespace std;
int main() {
  int q, n, aux;
  cin >> q;
  while (q--) {
    int may = 0, aux = 0;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++) {
      cin >> v[i];
      may = max(may, v[i]);
    }
    for (int i = 0; i < n; i++) {
      if (v[i] == may) {
        if (i == 0) {
          if (v[i + 1] < v[i]) {
            cout << v[i] << "\n";
            break;
          }
        } else if (i == n - 1) {
          if (v[i - 1] < v[i]) {
            cout << v[i] << "\n";
            break;
          }
        } else {
          if (v[i + 1] < v[i] || v[i - 1] < v[i]) {
            cout << v[i] << "\n";
            break;
          }
        }
        aux++;
      }
    }
    if (aux == n) cout << -1 << "\n";
  }
}
