#include<iostream>
#include<time.h>

using namespace std;
int main(int argc, char *argv[])
{
	
	ios_base::sync_with_stdio(false); cin.tie(0);
	int t;
	cin>>t;
	while(t--)
	{
		//cout<<t<<1;
		int b[200008]={0},i,ans=-1,start,end,n,a[200008]={0};
		cin >> n;
		cin>>start;end=start;a[start]++;b[1]=start;
		//cout<<t<<2;
		for(i=2;i<=n;i++)
		{
			int temp;
			cin>>temp;
			b[i]=temp;
			if (temp<start) start=temp;
			if (temp>end) end=temp;
			a[temp]++;
			//cout<<i<<1;
		}
		//cout<<"cined all"<<endl;
		for(i=start;i<=end;i++){if(a[i]==1) break;}
		//cout<<"for 2 "<<endl;
		
		if(a[i]!=1)
		ans=-1;
		else
		{ 
			ans=i;
			
			for(i=1;i<=n;i++)
			{
				if(b[i]==ans) break;
			}
			ans=i;
		}
		cout<<ans<<endl;
	}
}