1
3
5 3 4
 6
5
5 3 4 4 5
3
1 1 1
5
4 4 3 4 4
5
5 5 4 3 2
3
1 1 2
5
5 4 3 5 5
 1
3
10 1 5

1
 1
-1
2
2
3
1
 1

#include <bits/stdc++.h>
using namespace std;
struct p {
  int a, ind;
};
bool cmp(p a, p b) { return a.a < b.a; }
void solve() {
  int n, i, j, mx = -1;
  cin >> n;
  p a[n];
  for (i = 0; i < n; i++) {
    cin >> j;
    a[i].a = j;
    a[i].ind = i + 1;
  }
  stable_sort(a, a + n, cmp);
  for (i = 0; i < n - 1; i++) {
    if (a[i].a < a[i + 1].a)
      mx = a[i + 1].ind;
    else if (a[i].a == a[i + 1].a) {
      if (a[i].ind - a[i + 1].ind != -1) mx = a[i].ind;
    }
  }
  cout << mx << "\n";
}
int main() {
  int t;
  cin >> t;
  while (t--) solve();
}
