#include <bits/stdc++.h>

using namespace std;

#define ll long long

int main()
{
	ios_base::sync_with_stdio(false);

	ll t;
	cin >> t;
	while (t--)
	{
		ll n;
		cin >> n;
		vector <ll> s(n + 1), s1(n + 1);
		for(ll i = 0; i < n; i++)
		{
			ll x;
			cin >> x;
			++s[x];
			s1[x] = i + 1;
		}
		ll answer = -1;
		for (ll i = 0; i <= n; i++)
		{
			if (s[i] == 1) {
				answer = s1[i];
				break;
			}
		}
		cout << answer << "\n";
	}

	return 0;
}