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>
int compare(const void *p, const void *q) { return (*(int *)p - *(int *)q); }
int main() {
  long long int min = 100000000000, num, arr[100000], count, t, i, max = -1;
  scanf("%lld", &t);
  while (t--) {
    max = -1;
    scanf("%lld", &num);
    for (i = 1; i <= num; i++) {
      scanf("%lld", &arr[i]);
      if (arr[i] > max) max = arr[i];
    }
    for (i = 1, count = 0; i <= num; i++) {
      if (arr[i] == max) count++;
    }
    if (count == num)
      printf("-1\n");
    else
      printf("%d\n", max);
  }
  return 0;
}
