/* I am not the best, but I am better than your father. */
#include <bits/stdc++.h>
using namespace std;
using ll=long long ;
#define len(s) (int)s.size()
#define ss second
#define ff first
#define all(a) a.begin(),a.end()
#define s(a,b) for ( int i = a ; i < b ; i++)
#define q(a,b) for ( int j = a ; j < b ; j++)
void solve ()
{
int n , m ;
cin >>n >> m;
ll arr[20];
arr[0]=1;
s(1,20)
arr[i]=i*arr[i-1];
cout<< arr[n]/(arr[m]*arr[n-m])<<endl;
/*s(0,20)
cout<<arr[i]<<endl;*/
}
void solve2()
{
int n;
cin>>n;
int arr[n], arr1[n];
s(0,n)
cin>>arr[i];
s(0,n)
cin>>arr1[i];
int ma= 0;
s(0,n)
{
if(arr1[i]>arr[i])
{
int z =arr1[i]-arr[i];
ma=max(ma,z);
}}
cout<<ma<<"\n";
}
void solve3()
{
string str ;
bool p = true;
cin >>str ;
int c = len (str)/2;
if(len(str)%2==1)
c++;
s(0,c)
{
if(str[i]!=str[i+c] && p)
{
cout<<"No\n";
p=false;
}}
if(p)
cout<<"Yes\n";
}
void solve4 ()
{
int n;
cin>> n;
int arr[n];
int counter = 0;
int ma=0;
s(0,n)
{
cin>>arr[i];
ma=max(ma,arr[i]);
}
s(0,n)
{
if(ma==arr[i])
counter++;
}
if(counter ==2)
cout<<n/2+1<<endl;
else if(counter > 2)
cout<<-1<<endl;
else
cout<<n<<endl;
}
int main() {
// solve();
ll t;
cin >> t;
while(t--){
solve4();
}}
Copy