#include <bits/stdc++.h>

using namespace std;
#define fastRead() ios_base::sync_with_stdio(false),cin.tie(NULL);
#define pii pair<ll, ll>
#define vv vector<vector<pii> >
typedef long long ll;

ll MOD = 1e9 + 7;

ll ADD(ll a, ll b) {
    return (a % MOD + b % MOD) % MOD;
}


int main() {
    fastRead()
    int t;
    cin >> t;
    //t = 1;
    while (t--) {
        int n, a, ans = INT32_MAX;
        cin >> n;
        map<int, int> mp;
        vector<int> index(n + 1, INT32_MAX);
        for (int i = 1; i <= n; i++) {
            cin >> a;
            index[a] = min(index[a], i);
            mp[a]++;
        }
        for (auto x:mp) {
            if (x.second == 1)
                ans = min(ans, x.first);
        }
        if (ans == INT32_MAX)
            cout << -1 << "\n";
        else
            cout << index[ans] << "\n";
    }
    return EXIT_SUCCESS;
}