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

import java.util.*;
public class CodeForces {
	
	static int f(int a[], int n) {
		int x = a[0], i = 1;
		while(i<n && a[i]==x) i++;
		if(i==n) return -1;
		int max = 0;
		for(int y : a) max = Math.max(max, y);
		return max;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		while(t-->0) {
			int n = sc.nextInt();
			int a[] = new int[n];
			for(int i=0; i<n; i++) {
				a[i] = sc.nextInt();
			}
			System.out.println(f(a, n));
		}
	}

}