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

import java.util.*;
import java.io.*;

public class c 
{
    static boolean multiple_testcases = true;
        
    static void solve() {
        int n = in.nextInt();
        int[] arr = in.intArray(n);
        HashSet<Integer> hash = new HashSet<>();
        for(int i=0;i<n;i++) {
            if(!hash.contains(arr[i])) hash.add(arr[i]);
            else continue;
        }
        if(hash.size()==1) {
            System.out.println(-1);
            return;
        }
        
        int max = 0;
        for(int i=1;i<n;i++) {
            if(arr[i]>arr[i-1] && (arr[i]+i-max) > max ) max = i;
            else if(arr[i]==arr[i-1] && max== i-1 ) max = i;
        }

        System.out.println(max+1);
    }

    static int INF = Integer.MAX_VALUE;
    static FastReader in = new FastReader();
    public static void main(String[] args) { 
        if(multiple_testcases) {
            int t = in.nextInt();
            while(t-- >0)  solve();
        } else solve();
    }

    static class FastReader { 
        BufferedReader br; StringTokenizer st; 
        public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } 
      
        String next() { while (st == null || !st.hasMoreElements()) { 
            try{ st = new StringTokenizer(br.readLine()); } catch (IOException  e) { e.printStackTrace(); } }
            return st.nextToken(); } 
        int nextInt() { return Integer.parseInt(next()); } 
        long nextLong() { return Long.parseLong(next()); } 
        double nextDouble() { return Double.parseDouble(next()); } 
        char nextChar() { return next().charAt(0); }
        String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } 
        return str; }
     
        int[] intArray(int n) {
            int[] arr = new int[n];
            for(int i=0;i<n;i++) 
                arr[i] = in.nextInt();
            return arr;    
        } 
        int[] intArray1(int n) {
            int[] arr = new int[n+1];
            for(int i=1;i<=n;i++) 
                arr[i] = in.nextInt();
            return arr;    
        } 
    } 
}