t=int(input())
for i in range(t):
    n=int(input())
    a=list(map(int,input().split()))
    flag=0
    u=0
    for i in range(len(a)):
        for j in range(i+1,len(a)):
            u=len(set(a[i:j+1]))
            if(len(a[i:j+1])-u==1):
                k=u
                flag=1
                break
    if(flag==0):
        print(-1)
    else:
        print(k+1)