#include<stdio.h>
#include<iostream>
#include<string.h>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<stack>
#include<set>
using namespace std;
#define pb push_back
#define POP pop_back()
#define DEBUG cout << "DEBUG\n";
#define ll long long
#define db double
#define endl '\n'
#define fo(i,a,b) for(int i = a;i <= b;i++)
#define lowbit(x) (x&-x);
const int maxn = 5e5+5;
const int inf = 0x3f3f3f3f;
const ll inF = 0x3f3f3f3f3f3f3f3f;
const ll mod = 1e8;
const db eps = 1e-8;
struct node{
	int v , id;
	bool operator < (const node &b)const{
		return v < b.v;
	}
};
node cnt[maxn];
int a[maxn];
int main(){
	int t , n;cin >> t;
	while(t--){
		cin >> n;
		for(int i = 1;i <= n;i++)cnt[i].v = cnt[i].id = 0;
		for(int i = 1;i <= n;i++)scanf("%d",&a[i]) , cnt[a[i]].v++ , cnt[a[i]].id = i;
		int ans = -1;
		for(int i = 1;i <= n;i++){
			if(cnt[i].v == 1){ans = cnt[i].id;break;}
		}
		if(ans == -1){
			cout << "-1\n";
		}
		else cout << ans << endl;
	}
	return 0;
}