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 Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int t = scan.nextInt();

        while (t-- > 0) {
            int count = 0;
        int n= scan.nextInt();
        int []a=new int[n];
        int dom=a[0];
        for (int i=0;i<a.length;i++){
            a[i]= scan.nextInt();
            if (a[i]>dom){
                dom=a[i];
            }
        }
        for (int i=0;i<a.length;i++){
            if (a[i]==dom)
                count++;

        }
        if (count==n){
            System.out.println(-1);
        }
        else System.out.println(dom);


          }
    }
}