t=int(input())
for _ in range(t):
    n=int(input())
    l=[int(i) for i in input().split()]
    if(n==1):
        print(-1)
    else:
        if(n==2):
            if(l[0]==l[1]):
                print(2)
            else:
                print(-1)
        else:
            dict={}
            count={}
            diff={}
            for e,f in enumerate(l):
                if f not in dict:
                    dict[f]=[e]
                    count[f]=1
                else:
                    count[f]+=1
                    if(len(dict[f])<2):
                        dict[f].append(e)
                        diff[f]=dict[f][1]-dict[f][0]
                    elif(len(dict[f])==2):
                        dict[f].append(e)
                        a=dict[f][2]-dict[f][1]
                        if(a<diff[f]):
                            diff[f]=a
                        dict[f].pop(0)
            temp=10**7
            h=[]
            for e,f in diff.items():
                if(temp>=f):
                    temp=f
                    h.append((e,f))
            lis=[]
            for e,f in count.items():
                lis.append(f)
            lis.sort()
            if(len(lis)==1):
                print(h[0][1]+1)
            else:
                if(lis[-2]==lis[-1]):
                    print(-1)
                else:
                    print(h[0][1]+1)