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

try:
    T=int(input())
    for i in range(T):
        n=int(input())
        A=list(map(int,input().split()))
        def checkme(A):
            pos=-1
            for i in range(len(A)-1):
                if A[i]==maxi and A[i+1]!=maxi:
                    pos=i
                    break
            return pos
        maxi=max(A)
        r=checkme(A)
        t=checkme(A[::-1])
        k=len(A)-t-1
        if r==-1 and t==-1:
            print(-1)
        else:
            print(max(r+1,k+1))
except:
    pass