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>
#pragma GCC target("avx2")
#pragma GCC optimization("O60")
#pragma GCC optimization("unroll-loops")
using namespace std;
template <class T>
bool ckmin(T& a, const T& b) {
  return a > b ? a = b, 1 : 0;
}
template <class T>
bool ckmax(T& a, const T& b) {
  return a < b ? a = b, 1 : 0;
}
long long int func(long long int n) {
  long long int cnt = 0;
  while (n > 0) {
    cnt++;
    n /= 10;
  }
  return cnt;
}
void solve() {
  long long int n;
  cin >> n;
  vector<long long int> v(n);
  for (long long int i(0); i < n; ++i) {
    cin >> v[i];
  }
  set<long long int> st(v.begin(), v.end());
  if (st.size() == 1) {
    cout << -1 << "\n";
  } else {
    long long int u = *max_element(v.begin(), v.end());
    long long int cnt = 0, cnt2 = 0;
    for (long long int i(0); i < n; ++i) {
      if (v[i] == u) {
        cnt++;
      } else {
        break;
      }
    }
    for (long long int i(n - 1); i >= 0; i--) {
      if (v[i] == u) {
        cnt2++;
      } else {
        break;
      }
    }
    if (cnt != 0) {
      cout << cnt << "\n";
    } else {
      if (cnt == 0) {
        if (cnt2 == (1)) {
          cout << (n) << "\n";
        } else {
          cout << -1 << "\n";
        }
      }
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
