function PrintArray(arr)
{
    var str = ''
    for(var k=0;k<arr.length;k++)
    {
        str+=arr[k]+' ';
    }
    print(str);
}

function spy(n,arr)
{
    if(arr[0]!=arr[1] && arr[0]!=arr[2])
    {
        return 1;
    }

    if(arr[n-1]!=arr[n-2] && arr[n-1]!=arr[n-3])
    {
        return n;
    }

    for(var i=1;i<n-1;i++)
    {
        if(arr[i]!=arr[i+1] && arr[i]!=arr[i-1])
        {
            return i+1
        }
    }
}

var arr = []
var t = readline();

for(var indT=0;indT<t;indT++)
{
    var n = readline();

    var arr = readline();
    arr = arr.split(' ');

    print(spy(n,arr))

}

let input = '';
process.stdin.on('data', (c) => {
    input += c;
});

process.stdin.on('end', () => {
    const lines = input.split('\n');
    const cases = parseInt(lines[0]);

    let on = true;
    for (let i = 1; i < cases * 3; i++) {
        const line = lines[i];
     //   console.log(line);
        if (!line) {
            return;
        }
        if (on) {
        } else {
            const arr = lines[i].split(' ').map(t => t.trim());
            let t;
        //console.log(arr);
            const index = arr.findIndex((item, index) => {
                //console.log('t' + t + item);
                if (index === 0 && arr[index + 1] !== item && arr[index + 2] !== item) {
                    return true;
                }
                if (t === undefined) {
                    t = item;
                    return false;
                }

                if (item !== t) {
                    return true;
                }
            });

            console.log((index + 1));
        }

        on = !on;
    }
});

"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");

function print(x) {
  console.log(x);
}
let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});
process.stdin.on("end", () => {
  inputString = inputString.split("\n");
  main();
});
function readline() {
  return inputString[currentLine++];
}

// ********** Code Start **********

function main() {
  var a=readline();
while(a--){
   var t=readline();
   var s=readline().split(" ");

   var c=[];
   var ex;

   for(let i=0;i<s.length;i++){
       if(c.indexOf(s[i])==-1){
           c.push(s[i])
       }else{
           ex=s[i]
       }
   }
//    console.log(c,'kkkk')
var ans=c.filter(data => data != ex);
   console.log(s.indexOf(ans[0])+1)
}
}

// Common Template Starts //
process.stdin.resume();
process.stdin.setEncoding("utf-8");

let inputString = ""
let currentLine = 0

process.stdin.on("data", inputStdin => inputString += inputStdin)

process.stdin.on("end", (_) => {
    inputString = inputString.trim().split("\n").map((string) => string.trim())
    main()
})

const readline = () => inputString[currentLine++]
// Common Template Ends //

// Driver Function Starts //
const main = () => {
    console.clear()
    let t = parseInt(readline())
    while (t--) {
        let n = parseInt(readline())
        let arr = readline().split(' ').map( Number )
        console.log( solve(arr) )
    }
}
// Driver Function Ends //

// MAIN LOGIC
const solve = (arr) => {
    let min = minOfArray( arr )
    let max = maxOfArray( arr )
    let minArr = arr.filter( a => a === min )

    spy = ( minArr.length === 1 ) ? min : max

    for( a in arr ) {
        if( arr[a] === spy ) return parseInt( a ) + 1
    }
}

const isOdd         = (num) => num & 1
const isEven        = (num) => !(num & 1)
const minOfArray    = (arr) => Math.min.apply(null, arr)
const maxOfArray    = (arr) => Math.max.apply(null, arr)
const uniqueArray   = (arr) => [...new Set(arr)]
const sortArray     = (arr) => arr.sort((a, b) => a - b)
const sumOfArray    = (arr) => arr.reduce((partialSum, a) => partialSum + a, 0)

let q = '';
process.stdin.on('data', c => q += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = q.split(EOL);
    var n = lines[0];
    var e = 0;
    for(i = 1; i <= n * 2; i++){
        if(i % 2 == 1){
            e = lines[i];
        }else{
            var k = lines[i].split(' ').map(Number);
            for(j = 0; j < e; j++){
                var l = j - 1;
                var r = j + 1;
                l = l == -1 ? k.length - 1 : l;
                r = r == k.length ? 0 : r;
                if(k[l] != k[j] && k[j] != k[r]){
                    console.log(j + 1);
                    break;
                }
            }
        }
    }
});

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL); /*your input text, split by lines*/
    var n = lines[0];
    var answer = 0;
    for(var j = 1; j <= n * 2; j += 2){
        var num = lines[j + 1].split(' ');
        for(var k = 0; k < num.length; k++){
            var left = k - 1;
            var right = k + 1;
            if(left == -1){
                left = num.length -1;
            }
            if(right == num.length){
                right = 0;
            }
            if(num[k] != num[left] && num[k] != num[right]){
                console.log(k + 1);
            }
        }

    }
});

process.stdin.resume();
process.stdin.setEncoding("utf-8");

let inputString = "";
let currentLine = 0;
let max = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});

process.stdin.on("end", (_) => {
  inputString = inputString
    .trim()
    .split("\n")
    .map((string) => {
      return string.trim();
    });

  main();
});

function readline() {
  return inputString[currentLine++];
}

function main() {
  let = i = 0;

  let x = readline();
  max = x;

  for (let i = 0; i < max * 2; i++) {
    let y = readline();
    if (i % 2 === 1) {
      execute(y.split(" "));
    }
  }
}

function execute(x) {
  // without auto '\n' (newline)
  // process.stdout.write("");
  // with auto '\n' (newline)
  // console.log(x);

  let data = {};
  let spy = null;

  if (x.length !== 1) {
    for (let i = 0; i < x.length; i++) {
      if (!data.hasOwnProperty(x[i])) {
        data[`${x[i]}`] = 1;
      } else {
        data[`${x[i]}`] += 1;
      }
    }

    for (const el in data) {
      if (data[el] === 1) {
        spy = el;
      }
    }

    for (let i = 0; i < x.length; i++) {
      if (x[i] === spy) {
        console.log(i + 1);
      }
    }
  }
}

function processInput(input) {
        let opt = {};
        let [first, ...second] = [...input.split("\n")];
        opt.n = parseInt(first);
        for(var i = 0; i < second.length; i++) {
            second[i] = second[i].split(" ").map(val => parseInt(val));
        }
        opt.testcases = second;
       // console.log(opt);
        return opt;
    }

    function iterateTC(TC) {
        var size = TC.n, arr = TC.testcases, k;
        for(var  i = 1; i<arr.length; i=i+2) {
            getSum(arr[i]);//main function call
        }
    }

    function getSum(ar) {
         if(isNaN(ar[ar.length-1])) ar.pop();
    	var a, b, key;
    	a = ar[0]; b = ar[1];
        if(ar[2] == a && ar[2] == b) {
        	key = a;
        	for(var i = 0; i<ar.length; i++) {
        		if(ar[i] !== key) {
        			console.log(i+1);
        			return;
        		}
        	}
        } else if(ar[2] == ar[1] && ar[2] !== ar[0]) {
        	console.log(1);
        } else if(ar[2] !== ar[1] && ar[2] == ar[0]) {
        	console.log(2);
        } else {
        	console.log(3);
        }
    }

process.stdin.resume();
process.stdin.setEncoding("ascii");
_input = "";
process.stdin.on("data", function (input) {
    _input += input;
});

process.stdin.on("end", function () {
   var TC = processInput(_input);
   iterateTC(TC);
});

function solve(arr, N) {
    const a = arr[0];
    const b = arr[1];
    const c = arr[2];
    if (a == b && b == c) {
        for (let i = 3; i < N; i++) {
            if (arr[i] != a) {
                return i + 1;
            }
        }
    } else if (a == b && b != c) {
        return 3;
    } else if (b == c && a != b) {
        return 1;
    } else {
        return 2;
    }
}

function processData(input) {
    //Enter your code here
    input = input.split('\n');
    const T = Number(input[0].trim());
    let i = 1;
    for (let t = 0; t < T; t++) {
        const N = Number(input[i++].trim());
        const arr = input[i++].trim().split(' ').map(Number);
        const ans = solve(arr, N);
        console.log(ans);
    }
}

process.stdin.resume();
process.stdin.setEncoding("ascii");
_input = "";
process.stdin.on("data", function (input) {
    _input += input;
});

process.stdin.on("end", function () {
    processData(_input);
});

const readline = require("readline");
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false,
});

let c = 0;

rl.on("line", (d) => {
  if (c === 0) {
    c++;
    return;
  }

  if (c % 2) {
    c++;
    return;
  }

  const arr = d.split(" ").map(Number);
  let guess = arr[0];

  if (guess === arr[1]) {
    let inc = 1;
    while (guess === arr[inc]) {
      inc++;
    }

    console.log(inc + 1);
  } else {
    if (guess === arr[2]) {
      console.log(2);
    } else {
      console.log(1);
    }
  }

  c++;
});

rl.on("close", () => {});

const readline = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});

let input = [];
let ans = [];

readline.on('line', line => {
    input.push(line);
}).on('close', () => {
    for (let i = 2; i < input.length; i+=2) {
        let nums = input[i].split(' ');
        for (let j = 0; j < nums.length; j++) {
            if (nums.indexOf(nums[j]) === nums.lastIndexOf(nums[j])) {
                ans.push(j+1);
                break;
            }
        }
    }
    console.log(ans.join('\n'))
});

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')

    const lines = i.split(EOL)
    const NoL = lines[0]*2

    let LoA = false
    let crewmate = 0

    let n = 1
    while(NoL >= n){
        if(!LoA){
            LoA = lines[n]

        }else{
            let number =  lines[n].split(" ")

            if(number[0] == number[1]){
                crewmate = number[0]

            }else if(number[0] == number[2]){
                crewmate = number[0]
            }else{
                crewmate = number[1]
            }

            let a = 0
            while(LoA > a){
                if(number[a] != crewmate){
                    console.log(number.indexOf(number[a])+1)
                    break;
                }
                a++
            }

            LoA = false
        }
         n++
    }
})

'use strict';
const readline = require('readline');
const util = require('util');
const rl = readline.createInterface({
    input: process.stdin,
});
let pos = 0;
const words = [];
rl.on('line', (line) => {
    words.push.apply(words, line.split(' ').filter(s => s != ''));
});
rl.on('close', main);
function check(b) {
    if (!b) {
        process.stderr.write(`${new Error().stack}\n`);
        process.exit(-1);
    }
}
function printf(...args) {
    process.stdout.write(util.format(...args));
}
function nextInt() {
    return Math.trunc(Number(words[pos++]));
}
function nextStr() {
    return words[pos++];
}
function af(l) {
    return Array.from({ length: l });
}
const INIT = -1;
function solve() {
    let n = nextInt();
    const cnt = af(101).fill(0);
    const a = af(n);
    for (let i = 0; i < n; i++) {
        a[i] = nextInt();
        cnt[a[i]]++;
    }
    for (let i = 1; i <= 100; i++) {
        if (cnt[i] == 1) {
            for (let j = 0; j < n; j++) {
                if (a[j] == i) {
                    return j + 1;
                }
            }
        }
    }
    return INIT;
}
function main() {
    let tc = nextInt();
    while (tc-- > 0) {
        printf("%d\n", solve());
    }
}

/**
 * Bismillahir Rahmanir Rahim
 * This code has been taken from: https://codeforces.com/blog/entry/69610
 */
 process.stdin.resume();
 process.stdin.setEncoding('utf-8');

 let inputString = '';
 let currentLine = 0;

 process.stdin.on('data', inputStdin => {
     inputString += inputStdin;
 });

 process.stdin.on('end', _ => {
     inputString = inputString.trim().split('\n').map(string => {
         return string.trim();
     });

     main();
 });

 function readLine() {
     return inputString[currentLine++];
 }

 /****** BELOW HERE START WRITING YOUR CODE IN main() FUNCTION   ***************************************/
 /**
  * Use "readLine()" function for input, which will return a string consisting the entire line, so accordingly split the string
  * when required.
  *
  * I am using console.log() to output
  */
//  function main() {
//      let t = readLine();
//      t = parseInt(t);
//      console.log("mai yahan aaya")
//      while(t--) {
//          let line = readLine();
//          line = line.split(" ");
//          let n = parseInt(line[0]);
//          let m = parseInt(line[1]);
//          if(n === 1) {
//              console.log("0");
//          } else if (n === 2) {
//              console.log(m);
//          } else {
//              console.log(2*m);
//          }
//      }
//  }

function main() {

	let t = parseInt(readLine());
	// t = parseInt(t);
	while(t--) {
		let n = readLine();
		n = parseInt(n);
		let s = readLine().split(" ").map(item=>parseInt(item));
		console.log(solve(n,s)+1);

	}
    // console.log(t);
}

function solve(n, s) {
	for (let i = 0; i < n-2; i++) {
		if (s[i] == s[i+1] && s[i] == s[i+2]) {
			continue;
		}
		if (s[i] == s[i+1]) return i+2;
		if (s[i] == s[i+2]) return i+1;
		if (s[i+1] == s[i+2]) return i;
	}
}

let data = '';
process.stdin.on('data', c => data += c);

function* nextLine() {
	let lines = data.trim().split(/\n/g);
	for(let l of lines){
		yield l.trim();
	}
}

let nl = nextLine();

nl.elem = function(funParse) {
		return funParse(this.next().value);
	};

nl.array = function(funParse) {
		return this.next().value.split(/\s/g).map(funParse||(x => x));
	};

nl.num = function() {
		return nl.elem(Number);
	};

nl.nums = function() {
		return nl.array(Number);
	};

nl.line = function() {
		return this.next().value;
	};

const sol = () => {
	let t = nl.num();
    let ans = [];
    for(let i = 0; i < t; i++){
		nl.num();
		let s = nl.nums();
		let a = s[0];
		let b = s[1];
		let c = s[2];
		let x = 0;
		if (a == b) {
			x = a;
		} else if (b == c) {
			x = b;
		} else {
			x = a;
		}

		let y = 0;
		s.forEach((e, i) => {
			if (e != x) {
				y = i + 1;
				return;
			}
		});
		ans.push(y);
    }

	console.log(ans.join("\n"));

};

process.stdin.on('end', sol);

input()
//-------------------

function input () {
  let i = ''
  process.stdin.on('data', c => i += c)
  process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL) /*your input text, split by lines*/
    //console.log(lines);
    solve(lines)
  })

}

function solve (arr) {
  var d =+arr[0]
  for (var i =1 ;i <=d ;i++){
    var mas =arr[2*i].split(" ")
    var mno =new Set(mas)

    for (var e of mno){
      var k =mas.indexOf(e)
      var kk =mas.lastIndexOf(e)
      if (k == kk){
        console.log(k+1)
        break

      }
    }

  }

}

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on("data", inputStdin => {
	inputString += inputStdin;
});

process.stdin.on("end", a => {
	inputString = inputString.trim().split("\n").map(str => str.trim());
	main();
});

function readLine() {
	return inputString[currentLine++];
}

function main() {
	let t = parseInt(readLine().split(" ")[0]);

	while(t-->0) {
		let n = parseInt(readLine().split(" ")[0]);

		let arr = new Array(n);
		let num = readLine().split(" ");
		for(let i=0;i<n;i++) {
			arr[i] = parseInt(num[i]);
		}
		let ans = 0;
		for(let i=0;i<n-2;i++) {
			if(arr[i] !== arr[i+1] && arr[i+1] !== arr[i+2]) {
				console.log(i+2);
				break;
			} else if(arr[i] !== arr[i+1] && arr[i+1] === arr[i+2]) {
				console.log(i+1);
				break;
			} else if(arr[i] === arr[i+1] && arr[i+1] !== arr[i+2]){
				console.log(i+3);
				break;
			}
		}
	}
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}

function main() {
    let t = readline();
    while(t--)
    {
        let num_of_elements = readline();
        let elements = readline();
        elements = elements.split(' ')
        let prev_occ = elements[0];
        for(let i=1;i<num_of_elements;i++)
        {
            if(prev_occ != elements[i])
            {
                if(elements[i] == elements[i+1])
                    console.log(i)
                else
                    console.log(i+1)
                break;
            }
        }
    }

}

var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
process.stdin.resume();
process.stdin.setEncoding('utf-8');
var inputString = [];
var s = "";
var currentLine = 0;
process.stdin.on('data', function (inputStdin) {
    s += inputStdin;
});
process.stdin.on('end', function (_) {
    inputString = s.trim().split('\n').map(function (string) {
        return string.trim();
    });
    s = null;
    main();
});
function readline() {
    return inputString[currentLine++];
}
function readIntLine() {
    return inputString[currentLine++].split(" ").map(function (e) { return parseInt(e); });
}
var println = console.log;
// -- SOLUTION
function main() {
    //get data
    var t = readIntLine()[0];
    var _loop_1 = function (i) {
        var n = readIntLine()[0];
        var arr = readIntLine();
        var m = {};
        arr.forEach(function (e, i) {
            m[e] = m[e] ? __assign(__assign({}, m[e]), { count: m[e].count + 1 }) : { firstPos: i, count: 1 };
        });
        println(m[Object.keys(m).filter(function (k) {
            return m[k].count == 1;
        })[0]].firstPos + 1);
    };
    for (var i = 0; i < t; i++) {
        _loop_1(i);
    }
}

'use-strict'

process.stdin.resume();
process.stdin.setEncoding('utf8');

let data = '';
let currentLine = 0;

process.stdin.on('data', chunk => {
data += chunk;
});

process.stdin.on('end', () =>{
    data = data.replace(/\s*$/, '')
    .split('\n')
    .map(str => str.replace(/\s*$/, ''));

    let testCases = parseInt(readLine());
    while(testCases--)
    {
       let n = parseInt(readLine());
       let arr = get_ints();
       let my_map = new Map();
       for(let i = 0 ; i < n ; i++)
            my_map.get(arr[i]) ? my_map.set(arr[i], my_map.get(arr[i]) + 1) : my_map.set(arr[i], 1)
        let ans;
        for([key,value] of my_map){
            if(value === 1) ans = key;
        }
        for(let i = 0; i < n; i++){
            if(arr[i] === ans){
                console.log(i + 1);
                break;
            }
        }
    }
});

function get_ints() {
    return readLine().split(' ').map(Number);
}

function readLine() {
        return data[currentLine++];
}

function print(c){
    return console.log(c)
}

function isEqual(arr){
     let flag = true;
        for(let i = 0 ; i < arr.length - 1; i++){
            if(arr[i] !== arr[i + 1]){
                flag = false;
                break;
            }
        }
    return flag;
}

// https://codeforces.com/problemset/problem/1512/A

process.stdin.setEncoding('utf-8')
const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
  }
)

let count = -1
let inputArr = []

rl.on('line', data => {
  if (count === -1) {
    count = +data * 2
  } else if (count !== 0) {
    inputArr.push(data.trim())
    count--;
  }

  if (count === 0) {
    inputArr = inputArr.map(i => i.split(' ').map(j => +j))

    for (let i = 0; i < inputArr.length; i += 2) {
      solution(inputArr[i], inputArr[i + 1])
    }

    process.exit(0)
  }
})

/**
TEST CASES
4
4
11 13 11 11
5
1 4 4 4 4
10
3 3 3 3 10 3 3 3 3 3
3
20 20 10
 */
const solution = (n, arr) => {
    const key0 = arr[0];
    const key1 = arr[1];
    const key2 = arr[2];

    if (key0 === key1 && key0 !== key2) {
      console.log(3);
      return;
    } else if (key0 === key2 && key0 !== key1) {
      console.log(2);
      return;
    } else if (key1 === key2 && key0 !== key1) {
      console.log(1);
      return;
    }

    let result = 1;

    for (let i=1; i<arr.length; i++) {
      if (arr[i] !== key0) {
        result = i + 1;

        break;
      }
    }

    console.log(result);
};

function solution(scanner) {
    const T = scanner.readInt();
    const r = [];
    for (let tc = 0; tc < T; tc++) {
        const N = scanner.readInt();
        const db = scanner.readLine().split(' ').map(Number);
        let testNum;
        if (db[0] === db[1]) testNum = db[0];
        else if (db[0] === db[2]) testNum = db[0];
        else if (db[1] === db[2]) testNum = db[1];
        for (let i = 0; i < N; i++) {
            if (db[i] !== testNum) {
                r.push(i + 1);
                break;
            }
        }
    }
    return r.join('\n');
}

/////////////////////////////////////////////////////////////////////////////////
// Readiz JS Util Start
/////////////////////////////////////////////////////////////////////////////////
const scanner = {
    readInt: () => {
        return parseInt(__lineDB[__lineIdx++], 10);
    },
    readLine: () => {
        return __lineDB[__lineIdx++];
    }
};
let __lineDB = [];
let __lineIdx = 0;
const isDebug = process.argv[2] === 'readizDebug';
if (!isDebug) {
    global.console = {
        log: () => {},
        warn: () => {},
        info: () => {},
        debug: () => {},
        error: () => {}
    };
    const rl = require('readline').createInterface({
        input: process.stdin,
        output: process.stdout
    });
    rl.on('line', (line) => {
        __lineDB.push(line);
    });
    rl.on('close', () => {
        process.stdout.write(solution(scanner) + '\n');
    });
} else {
    __lineDB = require('fs').readFileSync(process.argv[1].replace('.js', '_input.txt')).toString().split('\n');
    while (__lineIdx < __lineDB.length) {
        process.stdout.write('--------------------------------------------\n');
        process.stdout.write('New Start + Log\n');
        process.stdout.write('--------------------------------------------\n');
        const start = __lineIdx;
        const answer = solution(scanner);
        const end = __lineIdx;
        process.stdout.write('----------------------\n');
        process.stdout.write('Input\n')
        process.stdout.write('----------------------\n');
        process.stdout.write(__lineDB.slice(start, end).join('\n') + '\n');
        process.stdout.write('----------------------\n');
        process.stdout.write('Answer\n')
        process.stdout.write('----------------------\n');
        process.stdout.write(answer + '\n');
    }
}

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = []; var outputList = [];var retcode = new Set();
read.on('line', function(input){
	var tmp = input.split(' ');
	for(var i = 0; i < tmp.length; i++){
		inLine.push(tmp[i]);
		if(i == tmp.length - 1){
			retcode.add(inLine.length);
		}
	}
});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
	console.log(myconv(outputList, 9));
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextArray(size, code){
	var ret = new Array(size);
	for(var i = 0; i < size; i++){
		if(code == 'int'){
			ret[i] = nextInt();
		}else{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);}
function getCountMap(list){
	var map = {};
	for(var i = 0; i < list.length; i++){
		if(map[list[i]] == null){
			map[list[i]] = 0;
		}
		map[list[i]]++;
	}
	return map;
}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}},
		isReturn : function(){return retcode.has(this.index);}
	};
}
function myout(s){outputList.push(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
function isReturn(){return obj.isReturn();}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	for(var i = 0; i < t; i++){
		var N = nextInt();
		var list = nextStrArray(N);
		var map = {};
		for(var j = 0; j < N; j++){
			if(map[list[j]] == null){
				map[list[j]] = 0;
			}
			map[list[j]]++;
		}
		var key = Object.keys(map);
		var min;
		myerr(map);
		if(map[key[0]] < map[key[1]]){
			min = key[0];
		}else{
			min = key[1];
		}
		myerr(min);
		myout(list.indexOf(min) + 1);
	}
}

process.stdin.setEncoding('utf-8')
const readline = require('readline')

const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout
    }
)

let count = -1
let inputArr = []

rl.on('line', data => {
    if (count === -1) {
        count = +data * 2
    } else if (count !== 0) {
        inputArr.push(data.trim())
        count--
    }
    // max number 2^(53) - 1 ~~ 10^(15)
    if (count === 0) {
        inputArr = inputArr.map(i => i.split(' ').map(j => +j))
        main()
        process.exit(0)
    }
})

function solve(n, arr) {
    const res = arr.filter((el, i, arr) => arr.indexOf(el) === arr.lastIndexOf(el))
    console.log(arr.indexOf(res[0]) + 1)
}

function main() {
    for (let i = 0; i < inputArr.length; i += 2) solve(inputArr[i], inputArr[i + 1])
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
  inputString += inputStdin;
});

process.stdin.on('end', _ => {
  inputString = inputString.trim().split('\n').map(string => {
    return string.trim();
  });

  main();
});

function readline() {
  return inputString[currentLine++];
}

var maxN = 21
var mod = 1000000007

// Make a Snippet for the code above this and then write your logic in main();

function main() {
  const xx = readline();

  Array(Number(xx)).fill(1).map((t, i) => {
    const n = parseInt(readline());
    // var [n, p, k] = readline().split(' ').map((x, iii) => {
    //   return parseInt(x)
    // });
    var a = readline().split(' ').map((x, iii) => {
      return parseInt(x)
    });
    var min = 0
    var object = {}
    for (let j = 0; j < n; j++) {
      if (!object[a[j]]) object[a[j]] = 0
      object[a[j]]++
    }
    for (let j = 0; j < n; j++) {
      if (object[a[j]] === 1) return console.log(j + 1)
    }

  })
}

var cases = parseInt(readline());
var t;
for(t=0; t <cases; t++){
var integer = readline();
var array = readline().split(" ");
var i;
var k;
var counter=0;
var item;
for(i=0; i <array.length; i++){
	counter=0;
	item = array[i];
	for(k=0; k <array.length;k++){
		if(k!=i && array[k] === item){
			counter++;
			break;
		}
	}

	if (counter==0){
		print(i+1);
		break;
	}

}
}

function readInt() {
  return parseInt(readline());
}

function readInts() {
  return readline()
    .split(' ')
    .map(function (e) {
      return parseInt(e);
    });
}

var t = readInt();

while (t--) {
  var n = readInt();
  var a = readInts().map(function (e, i) {
    return { e: e, i: i };
  });

  a.sort(function (a, b) {
    return a.e - b.e;
  });

  if (a[0].e !== a[1].e) {
    print(a[0].i + 1);
  } else {
    print(a[n - 1].i + 1);
  }
}

z = +readline();
y = 0;
for (j = 0; j < z; j++) {
  c = +readline();
  x = readline().split(" ").map(Number);
  for (i = 0; i <= c; i++) {
    if (x[i] !== x[i + 1] && x[i + 1] !== x[i + 2]) {
      y = x[i + 1];
      break;
    } else {
      y = x[0];
    }
  }
  index = x.indexOf(y);
  print(index + 1);
}

// 1512 A - Spy detected!

// number of test case
var numTests = parseInt( readline() );

for (var numTest = 0; numTest < numTests; numTest++) {

    // input data
    var n = parseInt( readline() );
    var array = readline().split(' ').map( e => parseInt(e));;
    var indexSpy = 0;
    var occorences = {};

    // count all occorence of two number in the array
    array.forEach( (e) => {
        occorences[e] = occorences[e] ? (occorences[e] += 1) : 1;
    });

    // find number with one occorence
    if( occorences[ Object.keys(occorences)[0] ] == 1){
        indexSpy = Object.keys(occorences)[0];
    } else {
        indexSpy = Object.keys(occorences)[1];
    }

    // print output
    print( array.indexOf( parseInt(indexSpy) ) + 1 );

}

// 1512 A - Spy detected!

// number of test case
var numTests = parseInt( readline() );

for (var numTest = 0; numTest < numTests; numTest++) {

    // input data
    var n = parseInt( readline() );
    var array = readline().split(' ').map( e => parseInt(e));;
    var indexSpy = 0;
    var occorences = {};

    array.forEach( (e) => {
        occorences[e] = occorences[e] ? (occorences[e] += 1) : 1;
    });

    // print(JSON.stringify(occorences));

    if( occorences[ Object.keys(occorences)[0] ] == 1){
        indexSpy = Object.keys(occorences)[0];
    } else {
        indexSpy = Object.keys(occorences)[1];
    }

    // print('spy: '+indexSpy);
    indexSpy = array.indexOf( parseInt(indexSpy) ) + 1 ;
    // print('index: '+indexSpy+'\n');

    print(indexSpy);

}

var testCases = readline();
var count;
var resultObj;
var result;
var length0;
for (var i = 0; i < testCases; i++) {
    resultObj = {};
    length0= readline();
    var arr = readline().split(' ');
    for (var val of arr) {
        if(!resultObj[val]) resultObj[val] = 1;
        else resultObj[val]++;
    }
    for (var key in resultObj) {
        if(resultObj[key] == 1) result = key;
    }
    print(arr.indexOf(result) + 1);
}

function solution() {
  var t = parseInt(readline());
  for (var i = 0; i < t; i++) {
    var n = parseInt(readline());
    var a = readline().split(" ");
    var nonSpy = a[0] === a[1] ? a[0] : a[2];
    for (var j = 0; j < n; j++) {
      if (a[j] !== nonSpy) {
        print(j+1);
      }
    }
  }
}

solution();

var t = readline();
    for(var i = 0 ; i < t ; i++){
        var n = readline(),
            a = readline().split(' ');
            valuesArray = [...new Set(a)],
            unexceptedValue = valuesArray[0]  , counter = 0;
            for(var j = 0 ; j < n ; j++){
                if(parseInt(valuesArray[0]) == parseInt(a[j]) ){
                    counter++;
                    if(counter > 1){
                     unexceptedValue = valuesArray[1];
                     break;
                    }
                }
            }
            print(parseInt(a.indexOf(unexceptedValue)) + 1);
    }

var t = parseInt(readline());

for (var i = 0; i < t; i++) {
    var n = parseInt(readline());
    var arr = readline().split(' ');

    if (arr[0] !== arr[1]) {
        if (arr[2] === arr[0]) {
            print(2);
        } else {
            print(1);
        }
    } else {
        for (var j = 2; j < n; j++) {
            if (arr[j] !== arr[0]) {
                print(j + 1);
                break;
            }
        }
    }
}

var numberOfTests =+(readline()),counter=0
for(var i=0;i<numberOfTests;i++){
    var a=[]
    var arrayLength=+readline()
    var array=readline().split(" ").map(node=>+node)
    for(var j=0;j<arrayLength;j++){
        for(var k=0;k<array.length;k++){
            if(array[j]===array[k]){
                counter++
            }
        }
        a.push(counter)
        counter=0
    }
    var min=a.reduce((a,b)=>{
        return Math.min(a,b)
    })

    print(a.indexOf(min)+1)
}

  var t = parseInt(readline());

  function solve() {
    var n = parseInt(readline());

    var inp = readline()
      .split(" ")
      .map((data) => +data);
    var hash = {};
    for (var i = 0; i < n; i++) {
      if (hash.hasOwnProperty(inp[i])) {
        hash[inp[i]]++;
      } else {
        hash[inp[i]] = 1;
      }
    }

    var ind = 0;
    for (var i in hash) {
      if (hash[i] === 1) {
        ind = i;
      }
    }
    return inp.indexOf(+ind) + 1;
  }

  while (t--) {
    print(solve());
  }

var test = parseInt(readline());
var inte = 0;

for(var i = 0; i < test; i++) {
    var foo = parseInt(readline());
    var bar = readline();
    var barSplited = bar.split(" ");
    for(var j = 0; j < barSplited.length; j++) {
        var counter = 0
        for(var k = 0; k < barSplited.length; k++) {
            if(barSplited[j] == barSplited[k] && j != k) {
                counter++
            }
        }
        if(counter == 0) {
            inte = j + 1;
        }
    }
    print(inte)
}

var tests = Number(readline());

for (var i = 0; i < tests; i++) {
    var len = Number(readline());
    var n = readline().split(" ");
    var index = 0;
    var check = 0;
    var is_first = false;

    for (var j = 0; j < len; j++) {
       var temp = n[j];

        if (j == 0 && n[j] != n[j+1]) {
            if (n[j + 1] == n[j + 2])
                is_first = true;
        }

        if (temp != n[j + 1])
            check++;

        if (check == 2) {
            index = j;
            break;
        }

    }

    is_first ? print(1) : print(index + 1);
}

var t=Number(readline());
for (var i=0; i<t; i++) {
    var n=Number(readline());
    var w=readline().split(" ").map(Number);
    var x=Array.from(new Set(w));
    if ((x[0]==w[1]&&x[0]==w[0])||(x[0]==w[1]&&x[0]==w[2])||(x[0]==w[0]&&x[0]==w[2])) {
        print(w.indexOf(x[1])+1);
    }
    else {
        print(w.indexOf(x[0])+1);
    }
}

var t = +readline();

for (var i = 0; i < t; i++) {
  var n = +readline();
  var a = readline().split(" ").map(Number);

  var first = a[0];
  var second = a[1];

  for(var j = 2; j < a.length; j++) {
      if(first === second && a[j] !== first) {
          print(j + 1);
          break;
      } else if(first !== second && a[j] === first) {
          print(a.indexOf(second) + 1);
          break;
      } else if(first !== second && a[j] === second){
          print(a.indexOf(first) + 1);
          break;
      }
  }
}

(function () {
    const count = readline();
    const n = Number(count);

    var i;
    var j;
    var result;
    for (i = 0; i < n; i++) {
        var length = readline();
        var l = Number(length);
        var line = readline();
        var items = line.split(' ');
        for (j = 0; j < l - 2; j++) {
            if (Number(items[j]) !== Number(items[j + 1]) && Number(items[j]) !== Number(items[j + 2])) {
                result = j + 1;
            }
            if (Number(items[j]) === Number(items[j + 1]) && Number(items[j]) !== Number(items[j + 2])) {
                result = j + 3;
            }
            if (Number(items[j]) === Number(items[j + 2]) && Number(items[j]) !== Number(items[j + 1])) {
                result = j + 2;
            }
        }

        print(result);
    }
})();

  'use strict';

  process.stdin.resume();
  process.stdin.setEncoding('utf-8');

  let inputString = '';
  let currentLine = 0;

  process.stdin.on('data', inputStdin => {
  	inputString += inputStdin;
  });

  process.stdin.on('end', _ => {
  	inputString = inputString.trim().split('\n').map(string => {
  		return string.trim();
  	});

  	main();
  });

  function readline() {
  	return inputString[currentLine++];
  }

  function main() {
		///problem specific code start
let tc = readline();
while(tc--)
{
	let arraySize = readline();
	const array = readline().split(' ');
    const obj = {};
    for (let value of array)
    {
    	if(value in obj)
    	{
          obj[value]++;
    	}
    	else
    		obj[value]=1;
    }
    for(let key in obj)
    {
    	if(obj[key]==1)
    		console.log(array.indexOf(key)+1);
    }

}      //problem specific code end

}

    'use strict';

    process.stdin.resume();
    process.stdin.setEncoding('utf-8');

    let inputString = '';
    let currentLine = 0;

    process.stdin.on('data', inputStdin => {
    	inputString += inputStdin;
    });

    process.stdin.on('end', _ => {
    	inputString = inputString.trim().split('\n').map(string => {
    		return string.trim();
    	});

    	main();
    });

    function readline() {
    	return inputString[currentLine++];
    }

    function main() {
    	///problem specific code start
        /*
    	var tc=readline();
    	while(tc--)
    	{
    		let size=readline();
    		const numbers=readline().split(' ');
    		for(let i=0;i<size;i++)
    		{
    			let cnt=0;
    			for(let j=0;j<size;j++)
    			{
    				if(numbers[i]==numbers[j])
    					cnt++;

    			}
    			if(cnt===1)
    			{
    				var index=i+1;
    				break;
    			}

    		}
    		console.log(index);

    	}
        */let testcase=readline();
while(testcase--)
{
    let arraySize=readline();
    const array=readline().split(' ');
    const tempObj={};
    for(let i of array)
    {
        if(!tempObj[i])
            tempObj[i]=1;
        else
            tempObj[i]++;
    }
   // console.log(Object.keys(tempObj));
   let result;
   for(let key in tempObj)
   {
    if(tempObj[key]==1)
        result=key;
   }
   console.log(array.indexOf(result)+1);
}
    	//problem specific code end

    }

    'use strict';

    process.stdin.resume();
    process.stdin.setEncoding('utf-8');

    let inputString = '';
    let currentLine = 0;

    process.stdin.on('data', inputStdin => {
        inputString += inputStdin;
    });

    process.stdin.on('end', _ => {
        inputString = inputString.trim().split('\n').map(string => {
            return string.trim();
        });

        main();
    });

    function readline() {
        return inputString[currentLine++];
    }

    function main() {

       var tc=readline();
while(tc--)
{
	let size=readline();
	const numbers=readline().split(' ');
	for(let i=0;i<size;i++)
	{
		let cnt=0;
		for(let j=0;j<size;j++)
		{
          if(numbers[i]==numbers[j])
              cnt++;

		}
		if(cnt===1)
		{
			var index=i+1;
			break;
		}

	}
	console.log(index);

}

    }

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
  inputString += inputStdin;
});

process.stdin.on('end', _ => {
  inputString = inputString.trim().split('\n').map(string => {
    return string.trim();
  });

  main();
});

function readline() {
  return inputString[currentLine++];
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {
  const useCases = readline();

  for (let i = 0; i < useCases; i++) {
    const arrayLength = readline();
    const arrayContent = readline().split(' ');
    const arrayContentSorted = arrayContent.slice().sort((a,b) => a - b);
    let unique = 0;

    if (arrayContentSorted[0] === arrayContentSorted[1]) {
      unique = arrayContentSorted[arrayLength - 1];
    } else {
      unique = arrayContentSorted[0];
    }

    const uniqueIndex = arrayContent.indexOf(unique);

    print(uniqueIndex + 1);
  }
}

function print(x) {
    // process.stdout.write("hello: ");   // without auto '\n' (newline)
    console.log(x);  // with auto '\n' (newline)
}

process.stdin.resume();
process.stdin.setEncoding("utf-8");

let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
    inputString += inputStdin;
});

process.stdin.on("end", (_) => {
    inputString = inputString
        .trim()
        .split("\n")
        .map((string) => {
            return string.trim();
        });

    main();
});

function readline() {
    return inputString[currentLine++];
}

// ********** Code Start **********

function main() {
    const t = parseInt(readline())
    const results = []
    const arrayInputs = []
    for(let i =0; i<t; i++) {
        const length = readline()
        arrayInputs[i] = readline().split(" ")
    }

    const check = (arr) => {
        if(arr[0] != arr[1]) {
            if(arr[1] == arr[2]) {
                results.push(1)
            }else {
                results.push(2)
            }
        }else {
            let cont = true
            i=2;
            while(cont && i<arr.length) {
                if(arr[i] == arr[i-1]) {
                    i++
                }else {
                    cont = false
                    results.push(i+1)
                }
            }

        }
    }

    arrayInputs.forEach((arrayInput) => {
        check(arrayInput)
    })

    results.forEach(result => console.log(result))
}

"use strict";

process.stdin.resume();
process.stdin.setEncoding("utf-8");

let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});

process.stdin.on("end", (_) => {
  inputString = inputString
    .trim()
    .split("\n")
    .map((string) => {
      return string.trim();
    });

  main();
});

function readline() {
  return inputString[currentLine++];
}
// Make a Snippet for the code above this and then write your logic in main();

const getSpyIndex = (arrNum) => {
  // console.log("input string", arrNum);

  if (arrNum[0] === arrNum[2] && arrNum[1] !== arrNum[2]) {
    return 1;
  }
  for (let i = 2; i < arrNum.length; i++) {
    if (arrNum[0] !== arrNum[i]) {
      if (arrNum[1] === arrNum[i]) {
        return 0;
      } else {
        return i;
      }
    }
  }
};

function main() {
  const numberOfTestCases = 1 * readline();
  // console.log("number of test cases", numberOfTestCases);
  Array.from({ length: numberOfTestCases }).forEach(() => {
    const arrayLength = 1 * readline();
    const arrayString = readline();
    const arr = arrayString.split(" ");
    const arrNum = arr.map((x) => +x);

    console.log(getSpyIndex(arrNum) + 1);
  });
}

"use strict";

process.stdin.resume();
process.stdin.setEncoding("utf-8");

let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});

process.stdin.on("end", (_) => {
  inputString = inputString
    .trim()
    .split("\n")
    .map((string) => {
      return string.trim();
    });

  main();
});

function readline() {
  return inputString[currentLine++];
}
// Make a Snippet for the code above this and then write your logic in main();

const getSpyIndex = (arrNum) => {
  let index;
  //   console.log("input string", arrNum);

  arrNum.forEach((x, i) => {
    if (i > 1) {
      if (arrNum[0] !== x) {
        if (arrNum[1] === x) {
          index = 0;
        } else {
          index = i;
        }
      } else if (i === 2) {
        index = 1;
      }
    }
  });

  console.log(index + 1);
};

function main() {
  const numberOfTestCases = 1 * readline();
  // console.log("number of test cases", numberOfTestCases);
  Array.from({ length: numberOfTestCases }).forEach(() => {
    const arrayLength = 1 * readline();
    const arrayString = readline();
    const arr = arrayString.split(" ");
    const arrNum = arr.map((x) => x * 1);

    getSpyIndex(arrNum);
  });
}
// const arrString = "3 3 3 3 10 3 3 3 3 3";

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', (inputStdin) => {
  inputString += inputStdin;
});

process.stdin.on('end', (_) => {
  inputString = inputString
    .trim()
    .split('\n')
    .map((string) => {
      return string.trim();
    });

  main();
});

function readline() {
  return inputString[currentLine++];
}

function main() {
  let tests = parseInt(readline());
  while (tests--) {
    let len = parseInt(readline());
    let arr = readline().split(' ');
    let key = {};
    for (let i = 0; i < len; i++) {
      if (key[arr[i]]) key[arr[i]].push(i + 1);
      else key[arr[i]] = [i + 1];
    }
    PrintMin(Object.values(key));
  }
}

function PrintMin(arr) {
  if (arr[0].length === 1) console.log(...arr[0]);
  else console.log(...arr[1]);
}

var integer = readline();
var array = readline().split(" ");
var i;
var k;
var counter=0;
var item;
for(i=0; i <array.length; i++){
	counter=0;
	item = array[i];
	for(k=0; k <array.length;k++){
		if(k!=i && array[k] === item){
			counter++;
			break;
		}
	}

	if (counter==0){
		print(i+1);
		break;
	}

}

var integer = readline();
var array = readline().split(" ");
var i;
var k;
var counter=0;
var item;
for(i=0; i <array.length; i++){
	counter=0;
	item = array[i];
	for(k=0; k <array.length;k++){
		if(k!=i && array[k] === item){
			counter++;
			break;
		}
	}

	if (counter==0){
		i++;
		print(i);
		break;
	}

}

var integer = readline();
var array = readline().split(" ");
var i;
var counter=0;
var item;
for(i=0; i <array.length; i++){
	counter=0;
	item = array[i];
	for(k=0; k <array.length;k++){
		if(k!=i && array[k] === item){
			counter++;
			break;
		}
	}

	if (counter==0){
		print(i+1);
		break;
	}

}

var t = parseInt(readline());
while (t--) {
  var n = parseInt(readline());
  var a = readline()
    .split(' ')
    .map(function (e) {
      return parseInt(e);
    });
  var nonSpy = a[0] === a[1] ? a[0] : a[2];
  for (var j in a) {
    if (j !== nonSpy) {
      print(j + 1);
    }
  }
}

var t = parseInt(readline());
while (t--) {
  var n = parseInt(readline());
  var a = readline().split(' ');
  var nonSpy = a[0] === a[1] ? a[0] : a[2];
  for (var j in a) {
    if (j !== nonSpy) {
      print(j + 1);
    }
  }
}

z = +readline();
y = 0;
for (i = 0; i < z; i++) {
  c = +readline();
  x = readline().split(" ").map(Number);
  for (i = 0; i <= c; i++) {
    if (x[i] !== x[i + 1] && x[i + 1] !== x[i + 2]) {
      y = x[i + 1];
      break;
    } else {
      y = x[0];
    }
  }
  index = x.indexOf(y);
  print(index + 1);
}

y = 0;
z = +readline();
for (i = 0; i < z; i++) {
  c = +readline();
  x = readline().split(" ").map(Number);
  for (i = 0; i <= x.length; i++) {
    if (x[i] !== x[i + 1] && x[i + 1] !== x[i + 2]) {
      y = x[i + 1];
    } else {
      y = x[0];
    }
  }
  index = x.indexOf(y);
  print(index + 1);
}

y = 0;
z = +readline();
for (i = 0; i < z; i++) {
  c = +readline();
  x = readline().split(" ").map(Number);
  for (i = 0; i <= x.length; i++) {
    if (x[i] !== x[i + 1] && x[i + 1] !== x[i + 2]) {
      y = x[i + 1];
      break;
    } else {
      y = x[0];
    }
  }
  index = x.indexOf(y);
  print(index + 1);
}

//const { readline, print, console } = require('@ip-algorithmics/codeforces-io');

function PrintArray(arr)
{
    var str = ''
    for(var k=0;k<arr.length;k++)
    {
        str+=arr[k]+' ';
    }
    print(str);
}

function PalindromeBinaire(a,b,str) //https://codeforces.com/problemset/problem/69/A
{
    b = parseInt(b)
    a = parseInt(a)

    str = str.split("");

    var n = str.length-1
    if(n==1 && a==1 && b==0)
    {
        return '0'
    }
    else if(n==1 && b==1 && a==0)
    {
        return '1'
    }

    for(var i=0;i<n;i++)
    {

       if(i<Math.ceil(n/2))
       {
            var inversed = n-i-1
            var current = i
       }
       else
       {
            var inversed = i
            var current = n-i-1
       }

       var next = a>b?'0':'1'
       if(str[current] == '?')
       {
            if(str[inversed]!='?')
            {
                str[current] = str[inversed];
                if(str[inversed] == '0')
                {
                    a = parseInt(a) - 1
                }
                else
                {
                    b = parseInt(b) - 1
                }
            }
            else
            {
                str[current] = next;
                str[inversed] = next;
                if(a>b)
                {
                    a = parseInt(a) - 2
                }
                else
                {
                    b = parseInt(b) - 2
                }
            }
       }
       else if(str[current] == '0')
       {
            if(str[inversed] == '1')
            {
                return "-1";
            }
            else if(str[inversed] == '?')
            {
                str[inversed] =  '0';
                a = parseInt(a) - 1;
            }
       }
       else if(str[current] == '1')
       {
            if(str[inversed] == '0')
                {
                    return "-1";
                }
                else if(str[inversed] == '?')
                {
                    str[inversed] = '1';
                    b = parseInt(b) - 1;
                }
       }
       if(a<0 || b<0)
       {
            return "-1";
       }
    }

    return str.join("");
}

var arr = []
var t = readline();

for(var indT=0;indT<t;indT++)
{
    var abLine = readline().split(" ");

    var a = parseInt(abLine[0]);
    var b = parseInt(abLine[1]);

    var str = readline();

    arr.push([a,b,str])

}

arr.forEach(function(element){
    print(PalindromeBinaire(element[0],element[1],element[2]))
})

var testCases = readline();
var count;
var resultObj;
var result;
for (var i = 0; i < testCases; i++) {
    resultObj = {};
    var length = readline();
    var arr = readline().split(' ');
    for (const val of arr) {
        if(!resultObj[val]) resultObj[val] = 1;
        else resultObj[val]++;
    }
    for (const key in resultObj) {
        if(resultObj[key] == 1) result = key;
    }
    print(arr.indexOf(result) + 1);
}

function solution() {
  var t = parseInt(readline());
  for (var i = 0; i < t; i++) {
    var n = parseInt(readline());
    var a = readline().split(" ");
    var nonSpy = a[0] === a[1] ? a[0] : a[2];
    for (var j = 0; j < n; j++) {
      if (a[j] !== nonSpy) {
        print(j);
      }
    }
  }
}

solution();

    "use strict";
    process.stdin.resume();
    process.stdin.setEncoding("utf-8");

    function print(x) {
      console.log(x);
    }
    let inputString = "";
    let currentLine = 0;

    process.stdin.on("data", (inputStdin) => {
      inputString += inputStdin;
    });
    process.stdin.on("end", () => {
      inputString = inputString.split("\n");
      main();
    });
    function readline() {
      return inputString[currentLine++];
    }

    // ********** Code Start **********

    function main() {
    	/*
      var a=readline();
    while(a--){
       var t=readline();
       var s=readline().split(" ");

       var c=[];
       var ex;

       for(let i=0;i<s.length;i++){
           if(c.indexOf(s[i])==-1){
               c.push(s[i])
           }else{
               ex=s[i]
           }
       }
    //    console.log(c,'kkkk')
    var ans=c.filter(data => data != ex);
       console.log(s.indexOf(ans[0])+1)
    }
    */
    var tc=readline();
while(tc--)
{
	let size=readline();
	const numbers=readline().split(' ');
	for(let i=0;i<size;i++)
	{
		let cnt=0;
		for(let j=0;j<size;j++)
		{
          if(numbers[i]==numbers[j])
              cnt++;

		}
		if(cnt==1)
		{
	      console.log(i+1);

		}

	}

}

    }

    "use strict";
    process.stdin.resume();
    process.stdin.setEncoding("utf-8");

    function print(x) {
      console.log(x);
    }
    let inputString = "";
    let currentLine = 0;

    process.stdin.on("data", (inputStdin) => {
      inputString += inputStdin;
    });
    process.stdin.on("end", () => {
      inputString = inputString.split("\n");
      main();
    });
    function readline() {
      return inputString[currentLine++];
    }

    // ********** Code Start **********

    function main() {
    	/*
      var a=readline();
    while(a--){
       var t=readline();
       var s=readline().split(" ");

       var c=[];
       var ex;

       for(let i=0;i<s.length;i++){
           if(c.indexOf(s[i])==-1){
               c.push(s[i])
           }else{
               ex=s[i]
           }
       }
    //    console.log(c,'kkkk')
    var ans=c.filter(data => data != ex);
       console.log(s.indexOf(ans[0])+1)
    }
    */
    var tc=readline();
while(tc--)
{
	let size=readline();
	const numbers=readline().split(' ');
	for(let i=0;i<size;i++)
	{
		let cnt=0;
		for(let j=0;j<size;j++)
		{
          if(numbers[i]==numbers[j])
              cnt++;

		}
		if(cnt==1)
		{
			var index=i+1;
			break;

		}

	}
	console.log(index);

}

    }

    "use strict";
    process.stdin.resume();
    process.stdin.setEncoding("utf-8");

    function print(x) {
      console.log(x);
    }
    let inputString = "";
    let currentLine = 0;

    process.stdin.on("data", (inputStdin) => {
      inputString += inputStdin;
    });
    process.stdin.on("end", () => {
      inputString = inputString.split("\n");
      main();
    });
    function readline() {
      return inputString[currentLine++];
    }

    // ********** Code Start **********

    function main() {
    	/*
      var a=readline();
    while(a--){
       var t=readline();
       var s=readline().split(" ");

       var c=[];
       var ex;

       for(let i=0;i<s.length;i++){
           if(c.indexOf(s[i])==-1){
               c.push(s[i])
           }else{
               ex=s[i]
           }
       }
    //    console.log(c,'kkkk')
    var ans=c.filter(data => data != ex);
       console.log(s.indexOf(ans[0])+1)
    }
    */
    var tc=readline();
while(tc--)
{
	let size=readline();
	const numbers=readline().split(' ');
	for(let i=0;i<size;i++)
	{
		let cnt=0;
		for(let j=0;j<size;j++)
		{
          if(numbers[i]==numbers[j])
              cnt++;

		}
		if(cnt===1)
		{
			var index=i+1;

		}

	}
	console.log(index);

}

    }

    "use strict";
    process.stdin.resume();
    process.stdin.setEncoding("utf-8");

    function print(x) {
      console.log(x);
    }
    let inputString = "";
    let currentLine = 0;

    process.stdin.on("data", (inputStdin) => {
      inputString += inputStdin;
    });
    process.stdin.on("end", () => {
      inputString = inputString.split("\n");
      main();
    });
    function readline() {
      return inputString[currentLine++];
    }

    // ********** Code Start **********

    function main() {
    	/*
      var a=readline();
    while(a--){
       var t=readline();
       var s=readline().split(" ");

       var c=[];
       var ex;

       for(let i=0;i<s.length;i++){
           if(c.indexOf(s[i])==-1){
               c.push(s[i])
           }else{
               ex=s[i]
           }
       }
    //    console.log(c,'kkkk')
    var ans=c.filter(data => data != ex);
       console.log(s.indexOf(ans[0])+1)
    }
    */
    var tc=readline();
while(tc--)
{
	let size=readline();
	const numbers=readline().split(' ');
	for(let i=0;i<size;i++)
	{
		let cnt=0;
		for(let j=0;j<size;j++)
		{
          if(numbers[i]==numbers[j])
              cnt++;

		}
		if(cnt===1)
		{
			var index=i+1;
			break;
		}

	}
	console.log(index);

}

    }

function main() {
  const useCases = readline();

  for (let i = 0; i < useCases; i++) {
    const arrayLength = readline();
    let unique = 0
    const arrayContent = readline().split(' ')
    const arrayContentSorted = arrayContent.slice().sort((a,b) => a - b);
    if (arrayContentSorted[0] === arrayContentSorted[1]) {
      unique = arrayContentSorted[arrayLength - 1]
    } else {
      unique = arrayContentSorted[0]
    }
    const uniqueIndex = arrayContent.indexOf(unique)
    console.log(uniqueIndex + 1)
  }
}

function main() {
  const useCases = readline();

  for (let i = 0; i < useCases; i++) {
    const arrayLength = readline();
    let unique = 0
    const arrayContent = readline().split(' ')
    const arrayContentSorted = arrayContent.slice().sort((a,b) => a - b);
    if (arrayContentSorted[0] === arrayContentSorted[1]) {
      unique = arrayContentSorted[arrayLength - 1]
    } else {
      unique = arrayContentSorted[0]
    }
    const uniqueIndex = arrayContent.indexOf(unique)
    print(uniqueIndex + 1)
  }
}

"use strict";

process.stdin.resume();
process.stdin.setEncoding("utf-8");

let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});

process.stdin.on("end", (_) => {
  inputString = inputString
    .trim()
    .split("\n")
    .map((string) => {
      return string.trim();
    });

  main();
});

function readline() {
  return inputString[currentLine++];
}
// Make a Snippet for the code above this and then write your logic in main();

const getSpyIndex = (arrNum) => {
  let index;
  //   console.log("input string", arrNum);

  for (let i = 2; i < arrNum.length; i++) {
    if (arrNum[0] !== arrNum[i]) {
      if (arrNum[1] === arrNum[i]) {
        index = 0;
      } else {
        index = i;
      }
      break;
    } else if (i === 2) {
      index = 1;
      break;
    }
  }

  console.log(index + 1);
};

function main() {
  const numberOfTestCases = 1 * readline();
  // console.log("number of test cases", numberOfTestCases);
  Array.from({ length: numberOfTestCases }).forEach(() => {
    const arrayLength = 1 * readline();
    const arrayString = readline();
    const arr = arrayString.split(" ");
    const arrNum = arr.map((x) => +x);

    getSpyIndex(arrNum);
  });
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', (inputStdin) => {
  inputString += inputStdin;
});

process.stdin.on('end', (_) => {
  inputString = inputString
    .trim()
    .split('\n')
    .map((string) => {
      return string.trim();
    });

  main();
});

function readline() {
  return inputString[currentLine++];
}

function main() {
  let tests = parseInt(readline());
  while (tests--) {
    let len = parseInt(readline());
    let arr = readline().split(' ').map(Number);
    let left = 0;
    let right = len - 1;
    for (let i = 0; i < len; i++) {
      if (arr[left] === arr[right]) {
        left++;
        right--;
      } else {
        if (arr[left] === arr[left + 1]) {
          console.log(right + 1);
          break;
        }
        console.log(left + 1);
        break;
      }
    }
  }
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', (inputStdin) => {
  inputString += inputStdin;
});

process.stdin.on('end', (_) => {
  inputString = inputString
    .trim()
    .split('\n')
    .map((string) => {
      return string.trim();
    });

  main();
});

function readline() {
  return inputString[currentLine++];
}

function main() {
  let tests = parseInt(readline());
  while (tests--) {
    let len = parseInt(readline());
    let arr = readline().split(' ').map(Number);
    let left = 0;
    let right = len - 1;
    for (let i = 0; i < len; i++) {
      if (arr[left] === arr[right]) {
        left++;
        right--;
      } else {
        if (arr[left + 1] !== arr[right]) {
          console.log(right + 1);
          break;
        }
        console.log(left + 1);
        break;
      }
    }
  }
}

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL); /*your input text, split by lines*/
    var number = lines[0].split(' ');
    var boyGirl = lines[1].split('');
    var answer = '';
    while(number[1]--){
        for(j = 1; j < number[0]; j++){
            if(boyGirl[j] == 'G' && boyGirl[j - 1] == 'B'){
                boyGirl[j] = 'B';
                boyGirl[j - 1] = 'G';
                j++;
            }
        }
    }
    answer = boyGirl.toString();
    answer.split(',');
    var a = '';
    for(k = 0; k < Number(number[0]) * 2 - 1;k++){
        if(k % 2 === 0){
            a += answer[k];
        }
    }
    console.log(a);
});

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL); /*your input text, split by lines*/
    for(var j = 1; j <= lines[0] * 2; j += 2){
        var a = lines[j].split(' ');
        for(var k = 0; k <= a.length; k++){
            var l = k - 1;
            var r = k + 1;
            if(l == -1){
                l = a.length;
            }
            if(r == a.length){
                r = 0;
            }
            if(a[k] != a[l] && a[k] != a[r]){
                console.log(k + 1);
            }
        }

    }
});

"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");

function print(x) {
  console.log(x);
}
let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});
process.stdin.on("end", () => {
  inputString = inputString.split("\n");
  main();
});
function readline() {
  return inputString[currentLine++];
}

// ********** Code Start **********

function main() {
  var a=readline();
while(a--){
   var t=readline();
   var s=readline().split(" ");

   var c=[];
   var ex;

   for(let i=0;i<s.length;i++){
       if(c.indexOf(s[i])==-1){
           c.push(s[i])
       }else{
           ex=s[i]
       }
   }
//    console.log(c,'kkkk')
var ans=c.filter(data => data != ex);
   console.log(s.indexOf(ans[0]))
}
}

"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");

function print(x) {
  console.log(x);
}
let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});
process.stdin.on("end", () => {
  inputString = inputString.split("\n");
  main();
});
function readline() {
  return inputString[currentLine++];
}

// ********** Code Start **********

function main() {
  var a=readline();
while(a--){
   var t=readline();
   var s=readline().split(" ");
   var c=[];
   var ex;

   for(let i=0;i<s.length;i++){
       if(c.indexOf(s[i])==-1){
           c.push(s[i])
       }else{
           ex=s[i]
       }
   }
//    console.log(c,'kkkk')
var ans=c.filter(data => data != ex);
   console.log(ans[0])
}
}

// Common Template Starts //
process.stdin.resume();
process.stdin.setEncoding("utf-8");

let inputString = ""
let currentLine = 0

process.stdin.on("data", inputStdin => inputString += inputStdin)

process.stdin.on("end", (_) => {
    inputString = inputString.trim().split("\n").map((string) => string.trim())
    main()
})

const readline = () => inputString[currentLine++]
// Common Template Ends //

// Driver Function Starts //
const main = () => {
    console.clear()
    let t = parseInt(readline())
    while (t--) {
        let n = parseInt(readline())
        let arr = readline().split(' ').map( Number )
        console.log( solve(arr) )
    }
}
// Driver Function Ends //

// MAIN LOGIC
const solve = (arr) => {
    let freq = new Array( 100 ).fill( 0 )

    for( let a of arr ) {
        freq[a]++
    }

    return ( arr.indexOf( freq.indexOf(1) )  + 1 )
}

const isOdd         = (num) => num & 1
const isEven        = (num) => !(num & 1)
const minOfArray    = (arr) => Math.min.apply(null, arr)
const maxOfArray    = (arr) => Math.max.apply(null, arr)
const uniqueArray   = (arr) => [...new Set(arr)]
const sortArray     = (arr) => arr.sort((a, b) => a - b)
const sumOfArray    = (arr) => arr.reduce((partialSum, a) => partialSum + a, 0)

process.stdin.resume();
process.stdin.setEncoding("utf-8");

let inputString = "";
let currentLine = 0;
let maxLine = 8;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});

process.stdin.on("end", (_) => {
  inputString = inputString
    .trim()
    .split("\n")
    .map((string) => {
      return string.trim();
    });

  main();
});

function readline() {
  return inputString[currentLine++];
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {
  for (let i = 0; i <= maxLine; i++) {
    let x = readline();
    execute(x.split(" "));
  }
}

function execute(x) {
  // without auto '\n' (newline)
  // process.stdout.write("");
  // with auto '\n' (newline)
  // console.log(x);

  let data = {};
  let spy = null;

  if (x.length !== 1) {
    for (let i = 0; i < x.length; i++) {
      if (!data.hasOwnProperty(x[i])) {
        data[`${x[i]}`] = 1;
      } else {
        data[`${x[i]}`] += 1;
      }
    }

    for (const el in data) {
      if (data[el] === 1) {
        spy = el;
      }
    }

    for (let i = 0; i < x.length; i++) {
      if (x[i] === spy) {
        console.log(i + 1);
      }
    }
  }
}

function solve(arr, N) {
    const a = arr[0];
    const b = arr[1];
    const c = arr[2];
    if (a == b && b == c) {
        for (let i = 4; i < N; i++) {
            if (arr[i] != a) {
                return i + 1;
            }
        }
    } else if (a == b && b != c) {
        return 3;
    } else if (b == c && a != b) {
        return 1;
    } else {
        return 2;
    }
}

function processData(input) {
    //Enter your code here
    input = input.split('\n');
    const T = Number(input[0].trim());
    let i = 1;
    for (let t = 0; t < T; t++) {
        const N = Number(input[i++].trim());
        const arr = input[i++].trim().split(' ').map(Number);
        const ans = solve(arr, N);
        console.log(ans);
    }
}

process.stdin.resume();
process.stdin.setEncoding("ascii");
_input = "";
process.stdin.on("data", function (input) {
    _input += input;
});

process.stdin.on("end", function () {
    processData(_input);
});


var input = readline().split(' ').map(Number), t = input[0], k = input[1];
var res = [];
var sum = [];
res[0] = 1;
for (var i = 1; i <= 100000; i++) {
    res[i] = (i - k >= 0) ? ((res[i-1] + res[i-k]) % 1000000007) : res[i-1];
}
var currentSum = 0;
sum[0] = 0;
for (var i = 1; i <= 100000; i++) {
    currentSum = (currentSum  + res[i]) % 1000000007;
    sum[i] = currentSum;
}
var ans = '';
for (var i = 0; i < t; i++) {
    input = readline().split(' ').map(Number), a = input[0], b = input[1];
    var diff = sum[b] - sum[a-1];
    if (diff < 0) diff += 1000000007;
    ans += (diff + '\n');
}

write(ans);

var xx = readline().split(' ');
var t = parseInt(xx[0]);
var k = parseInt(xx[1]);
var MOD = 1000000007;
var a = new Array();
var b = new Array();
var n = 100000;
for(var i=1;i<k;i++)
{
    b[i]=1;
}
b[k]=2;
for(var i=k+1;i<=n;i++)
{
    b[i]=(b[i-1]+b[i-k])%MOD;
}
a[0]=0;
for(var i=1;i<=n;i++)
{
    a[i]=(a[i-1]+b[i])%MOD;
}
while(t--)
{
    var xxx = readline().split(' ');
	var ans = a[parseInt(xxx[1])]-a[parseInt(xxx[0])-1];
	if(ans<0)
	{
	    ans+=MOD;
	}
	print(ans);
}

var input = readline().split(' ').map(Number), t = input[0], k = input[1];
var res = [];
var sum = [];
res[0] = 1;
for (var i = 1; i < 100000; i++) {
    res[i] = (i - k >= 0) ? ((res[i-1] + res[i-k]) % 1000000007) : res[i-1];
}
var currentSum = 0;
sum[0] = 0;
for (var i = 1; i < 100000; i++) {
    currentSum = (currentSum  + res[i]) % 1000000007;
    sum[i] = currentSum;
}
var ans = '';
for (var i = 0; i < t; i++) {
    input = readline().split(' ').map(Number), a = input[0], b = input[1];
    var diff = sum[b] - sum[a-1];
    ans += (diff + '\n');
}

write(ans);

var input = readline().split(' ').map(Number), t = input[0], k = input[1];
var res = [];
var sum = [];
res[0] = 1;
for (var i = 1; i < 100000; i++) {
    res[i] = (i - k >= 0) ? ((res[i-1] + res[i-k]) % 1000000007) : res[i-1];
}
var currentSum = 0;
sum[0] = 0;
for (var i = 1; i < 100000; i++) {
    currentSum = (currentSum  + res[i]) % 1000000007;
    sum[i] = currentSum;
}
var ans = '';
for (var i = 0; i < t; i++) {
    input = readline().split(' ').map(Number), a = input[0], b = input[1];
    var diff = sum[b] - sum[a-1];
    if (diff < 0) diff += 1000000007;
    ans += (diff + '\n');
}

write(ans);


'use strict';

var fs = require('fs');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);

function solve(read) {
  const [rn, rb, rns, re, rbs] = convertInput(read);
  const n = rn(),
        a = rns(n),
        b = rns(n);
  let x = a.reduce((a, b) => a + b, 0),
      y = b.reduce((a, b) => a + b, 0);
  let dif = x - y;
  let res = Math.abs(dif);
  for (let i = 0; i < n && dif; i++) {
    if (dif > 0) {
      if (a[i] !== b[i] && a[i]) {
        a[i] = 0;
        dif--;
      }
    } else if (dif < 0) {
      if (a[i] !== b[i] && !a[i]) {
        a[i] = 1;
        dif++;
      }
    }
  }
  for (let i = 0; i < n; i++) {
    if (a[i] !== b[i]) {
      res++;
      break;
    }
  }
  return res;
}
function convertInput(read) {
  const rn = () => Number(read());
  const rb = () => BigInt(read());
  const rns = n => {
    let res = new Array(n);
    for (let i = 0; i < n; i++) res[i] = rn();
    return res;
  };
  const re = n => {
    let res = new Array(n);
    for (let i = 0; i < n; i++) res[i] = rn() - 1;
    return res;
  };
  const rbs = n => {
    let res = new Array(n);
    for (let i = 0; i < n; i++) res[i] = rb();
    return res;
  };
  return [rn, rb, rns, re, rbs];
}
function main(r) {
  const [rn, rb, rns, re, rbs] = convertInput(r);
  try {
    let t = rn();
    let res = new Array(t);
    let limit = 0;
    for (let i = 0; i < t; i++) {
      var _solve;
      const s = (_solve = solve(r)) !== null && _solve !== void 0 ? _solve : '';
      if (t < limit) {
        process.stdout.write(s.toString());
        process.stdout.write('\n');
      } else {
        res[i] = s;
      }
    }
    if (t >= limit) {
      return res.join('\n');
    } else {
      return '';
    }
  } catch (error) {
    console.log(error);
  }
}

const inputs = fs__default["default"].readFileSync(0, 'utf-8')
.split(/\s+/);
void function () {
  const read = ((i = 0) => () => inputs[i++])();
  const output = main(read);
  process.stdout.write(output);
}();

// Common Template Starts //
process.stdin.resume();
process.stdin.setEncoding("utf-8");

let inputString = ""
let currentLine = 0

process.stdin.on("data", inputStdin => inputString += inputStdin)

process.stdin.on("end", (_) => {
    inputString = inputString.trim().split("\n").map((string) => string.trim())
    main()
})

const readline = () => inputString[currentLine++]
// Common Template Ends //

// Driver Function Starts //
const main = () => {
    console.clear()
    let t = parseInt(readline())
    while (t--) {
        let n = parseInt(readline())
        let a = readline()
        let b = readline()
        console.log( solve( n, a, b ) )
    }
}
// Driver Function Ends //

// MAIN LOGIC
const solve = (n, a, b) => {
    if( a === b ) return 0
    if( n === 1 && a !== b ) return 1

    a = a.split(' ').map( Number )
    b = b.split(' ').map( Number )

    let ones_a = 0
    for(let i = 0; i < n; i++) {
        if( a[i] == 1 ) ones_a++
    }

    let ones_b = 0
    for(let i = 0; i < n; i++) {
        if( b[i] == 1 ) ones_b++
    }

    let diff = Math.abs(ones_a - ones_b)

    let res = 0
    for(let i = 0; i < n; i++) {
        if(a[i] != b[i]) res++
    }

    return Math.min( res, diff + 1 )
}

const isOdd         = (num) => num & 1
const isEven        = (num) => !(num & 1)
const minOfArray    = (arr) => Math.min.apply(null, arr)
const maxOfArray    = (arr) => Math.max.apply(null, arr)
const uniqueArray   = (arr) => [...new Set(arr)]
const sortArray     = (arr) => arr.sort((a, b) => a - b)
const sumOfArray    = (arr) => arr.reduce((partialSum, a) => partialSum + a, 0)


const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
const lines = []
rl.on('line', (input) => {
    lines.push(input);
})
rl.on('close', () => {
// (function() {
    // const lines = require('fs').readFileSync('test.in', 'utf8').split('\n')
    let l = 0;
    let t = +lines[l++]
    const output = []
    for (let i = 0; i < t; i++) {
        const str = lines[l++]
        output[i] = solve(str) ? 'YES' : 'NO'
    }
    console.log(output.join('\n'))
// })()
})

function solve(str) {
    const n = str.length
    let a = Array(n)
    let b = Array(n)
    let c = Array(n)
    const s = 'Yes'
    for (let i = 0; i < n; i++) {
        a[i] = s[i % 3]
        b[i] = s[(i + 1) % 3]
        c[i] = s[(i + 2) % 3]
    }
    a = a.join('')
    b = b.join('')
    c = c.join('')
    // console.log(n, a, b, c)
    return a === str || b === str || c === str
}

var n = parseInt(readline());

for(var i = 0; i < n; i++) {
  var s = readline();

  var yes = 'Yes';

  var k = 0;

  while(k < 3 && yes[k] !== s[0]) k++;

  k %= 3;

  if(yes[k] !== s[0]) {
    print('NO');
    continue;
  }

  var j = 0;
  for(; j < s.length;) {
    if(yes[k] === s[j]) {
      k = (k + 1) % 3;
      j++;
    } else {
      print('NO')
      break;
    }
  }

  if(j === s.length) print('YES');
}

var n = Number(readline());

for (var i = 0; i < n; i++) {
  var str = readline();
  var b = "Yes".repeat(50).indexOf(str) > -1;
  print(b ? "Yes" : "NO");
}

"use strict";
exports.__esModule = true;
var readline_1 = require("readline");
var yesMap = {
	Y: "e",
	e: "s",
	s: "Y",
};
function isValidSubString(s) {
	if (s === "Y" || s === "e" || s === "s") {
		return true;
	}
	return false;
}
function findYesSubString(lines) {
	var testCases = Number(lines[0]);
	var mainString;
	var isPartOfYes;
	for (var i = 1; i <= testCases; i++) {
		isPartOfYes = false;
		mainString = lines[i];
		var char = void 0;
		// mainString = mainString.replace("Yes", "");
		for (var j = 0; j < mainString.length; j++) {
			char = mainString[j];
			if (mainString.length === 1 && isValidSubString(char)) {
				isPartOfYes = true;
				break;
			}
			if (mainString.length === j + 1) {
				break;
			}
			// console.log(i, mainString, yesMap[char], mainString[j + 1], char);
			if (isValidSubString(char) && yesMap[char] === mainString[j + 1]) {
				isPartOfYes = true;
			} else {
				isPartOfYes = false;
				break;
			}
		}
		if (isPartOfYes) {
			console.log("YES");
		} else {
			console.log("NO");
		}
	}
}
var rl = readline_1.createInterface(process.stdin, process.stdout);
var input = [];
rl.on("line", function (line) {
	return input.push(line);
}).on("close", function () {
	return findYesSubString(input);
});
var a = "s";

    const fs = require("fs");
    const input = fs.readFileSync(0, 'utf8').trim().split('\r\n');
    let currentline = 0;
    function readline(){
          return input[currentline++];
    }
    function alph() {
      var f = 'abcdefghijklmnopqrstuvwxyz';
      return f;
    }
    function Alph() {
      var f = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
      return f;
    }
    function max(x,y) {
      return x >=y ? x : y;
    }
    function min(x,y) {
      return x <=y ? x : y;
    }
    function abs(x) {
      return x < 0 ? x*(-1) : x;
    }
    var T = readline();
    var inf = 1000000000000;
    for(var tc=1;tc<=T;tc++) {
    	var n = readline();
    	var N = n.length;
    	var ok = false;
    	var ref = ["Y","e","s"];
    	var r = ref.indexOf(n[0]);
    	if(r!==-1) {
    		var j = 0;
    		while(j<N && n[j] === ref[r]) {
    			j++;
    			r = (r+1)%3;
    		}
    		if(j==N) ok = true;
    	}
    	console.log(ok ? "Yes" : "No")
    }

"use strict";

const rl = require('readline').createInterface(process.stdin, process.stdout);
let all_input = [];

rl.on('line', function(input){
  all_input.push(input);
});

rl.on('close', function(line){
  let index = 0;
  let t = +all_input[index++]; // + makes turns a convertable number string to a number

  while(t--)
  {
    let str = all_input[index++];

    solve(str);
  }
});

function solve(str)
{
  let temp_s = '';
  let temp_len = Math.floor(str.length / 3) + 3;

  for(let i = 0; i < temp_len; i++)
  {
    temp_s += "Yes";
  }
  //console.log(temp_s);

  if(temp_s.search(str) !== -1)
    console.log("YES");
  else
    console.log("NO");
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', (inputStdin) => {
	inputString += inputStdin;
});

process.stdin.on('end', (_) => {
	inputString = inputString
		.trim()
		.split('\n')
		.map((string) => {
			return string.trim();
		});

	main();
});

function readline() {
	return inputString[currentLine++];
}

function main() {
	let t = parseInt(readline());

	for (let i = 0; i < t; i++) {
		let s = readline();
		let yes = ['Y', 'e', 's'];
		let index = -1;
		let i = 0;

		// s es substring de YesYesYes

		let esSubstring = true;

		if (s[0] != 'Y' && s[0] != 'e' && s[0] != 's') {
			esSubstring = false;
		}

		if (s[0] == 'Y') {
			index = 0;
		} else if (s[0] == 'e') {
			index = 1;
		}
		if (s[0] == 's') {
			index = 2;
		}

		while (esSubstring && i < s.length) {
			if (s[i] != yes[index]) {
				esSubstring = false;
			}
			if (index == 2) {
				index = 0;
			} else {
				index++;
			}
			i++;
		}
		if (esSubstring) {
			console.log('YES');
		} else {
			console.log('NO');
		}
	}
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}

function main() {
    const testCases = Number(readline());
    const str = 'Yes'.repeat(50);
    for (let i = 0; i < testCases; i++) {
        let chunk = readline();
        if (findChunk(str, chunk)) console.log("YES");
        else console.log("NO");
    }
}

function findChunk(str, chunk) {
    return str.indexOf(chunk) > -1
}

const readline = require('readline');
const { stdin: input, stdout: output } = require('process')
const rl = readline.createInterface({ input, output })

let lines = []

const createReadLine = () => {
  i = 0;
  return () => lines[i++]
}
const int = (num, radix=10) => parseInt(num, radix)

rl.on('line', line => lines.push(line))

rl.on("close", () => {
  const readLine = createReadLine();
  let t = int(readLine());
  while (t--) {
    let str = readLine();
    let len = str.length
    let yes = 'Yes'.repeat(len)
    if (yes.includes(str)) {
      console.log('YES')
    } else {
      console.log('NO')
    }
  }
});

'use strict';

var fs = require('fs');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);

function solve(read) {
  let s = read();
  if (s[0] !== 'Y' && s[0] !== 'e' && s[0] !== 's') return 'NO';
  let i = 0,
      j = 0;
  if (s[0] === 'e') j = 1;else if (s[0] === 's') j = 2;
  const s1 = 'Yes';
  while (i < s.length) {
    if (s[i] !== s1[j]) return 'NO';
    j = (j + 1) % 3;
    i++;
  }
  return 'YES';
}
function main(r) {
  try {
    let t = Number(r());
    let res = new Array(t);
    let limit = 0;
    for (let i = 0; i < t; i++) {
      let s = solve(r);
      if (s === undefined) s = '';
      if (t < limit) {
        process.stdout.write(s.toString());
        process.stdout.write('\n');
      } else {
        res[i] = s;
      }
    }
    if (t >= limit) {
      return res.join('\n');
    } else {
      return '';
    }
  } catch (error) {
    console.log(error);
  }
}

const inputs = fs__default["default"].readFileSync(0, 'utf-8').split(/\r?\n/);
void function () {
  const read = ((i = 0) => () => inputs[i++])();
  const output = main(read);
  process.stdout.write(output);
}();

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = []; var outputList = [];var retcode = new Set();
read.on('line', function(input){
	var tmp = input.split(' ');
	for(var i = 0; i < tmp.length; i++){
		inLine.push(tmp[i]);
		if(i == tmp.length - 1){
			retcode.add(inLine.length);
		}
	}
});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
	console.log(myconv(outputList, 9));
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextArray(size, code){
	var ret = new Array(size);
	for(var i = 0; i < size; i++){
		if(code == 'int'){
			ret[i] = nextInt();
		}else if(code == 'long'){
			ret[i] = nextLong();
		}else if(code == 'double'){
			ret[i] = nextDouble();
		}else{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');} function nextLongArray(size){return nextArray(size, 'long');} function nextDoubleArray(size){return nextArray(size, 'double');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);} function nextLong(){return BigInt(next());} function nextDouble(){return parseFloat(next());}
function getCountMap(list){
	var map = {};
	for(var i = 0; i < list.length; i++){
		if(map[list[i]] == null){
			map[list[i]] = 0;
		}
		map[list[i]]++;
	}
	return map;
}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}},
		isReturn : function(){return retcode.has(this.index);}
	};
}
function myout(s){outputList.push(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
function isReturn(){return obj.isReturn();}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	var V = "";
	for(var i = 0; i < 10000; i++){
		V += "Yes";
	}
	while(hasNext()){
		var s = next();
		if(V.indexOf(s) != -1){
			myout("Yes");
		}else{
			myout("No");
		}
	}
}

var input = readline();

for(var i=0; i<Number(input); i++) {
    var word = readline();
    if(word[0] != "Y" && word[0] != "e" && word[0] != "s") {
        print("NO");
        continue;
    }

    for(var j=0; j<word.length; j++) {
        if(j == word.length - 1) {
            print("YES");
            break;
        }
        if(word[j] == "Y") {
            if(word[j+1] != "e") {
                print("NO");
                break;
            }
        }
        else if(word[j] == "e") {
            if(word[j+1] != "s") {
                print("NO");
                break;
            }
        }
        else {
            if(word[j+1] != "Y") {
                print("NO");
                break;
            }
        }
    }
}

var numOfCases = Number(readline());

var template = 'YesYesYesYesYesYesYesYesYesYesYesYesYesYesYesYesYesYesYesYesYesYesYesYesYesYesYesYesYesYesYesYesYesYesYesYesYesYesYesYesYesYesYesYesYesYesYesYesYesYes';

for (var testCase = 0; testCase < numOfCases; testCase++) {
    var input = readline();

    var result = process(input);
    print(result);
}

function process(input) {
    return template.indexOf(input) !== -1 ? 'YES' : 'NO';
}

"use strict";
exports.__esModule = true;
var readline_1 = require("readline");
var yesMap = {
	Y: "e",
	e: "s",
	s: "Y",
};
function isValidSubString(s) {
	if (s === "Y" || s === "e" || s === "s") {
		return true;
	}
	return false;
}
function findYesSubString(lines) {
	var testCases = Number(lines[0]);
	var mainString;
	var isPartOfYes;
	for (var i = 1; i <= testCases; i++) {
		isPartOfYes = false;
		mainString = lines[i];
		var char = void 0;
		// mainString = mainString.replace("Yes", "");
		for (var j = 0; j < mainString.length; j++) {
			char = mainString[j];
			if (mainString.length === j + 1) {
				break;
			}
			// console.log(i, mainString, yesMap[char], mainString[j + 1], char);
			if (isValidSubString(char) && yesMap[char] === mainString[j + 1]) {
				isPartOfYes = true;
			} else {
				isPartOfYes = false;
				break;
			}
		}
		if (isPartOfYes) {
			console.log("YES");
		} else {
			console.log("NO");
		}
	}
}
var rl = readline_1.createInterface(process.stdin, process.stdout);
var input = [];
rl.on("line", function (line) {
	return input.push(line);
}).on("close", function () {
	return findYesSubString(input);
});
var a = "s";

const fs = require("fs");
const input = fs.readFileSync(0, 'utf8').trim().split('\n');
let currentline = 0;
function readline(){
      return input[currentline++];
}
function alph() {
  var f = 'abcdefghijklmnopqrstuvwxyz';
  return f;
}
function Alph() {
  var f = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  return f;
}
function max(x,y) {
  return x >=y ? x : y;
}
function min(x,y) {
  return x <=y ? x : y;
}
function abs(x) {
  return x < 0 ? x*(-1) : x;
}
var T = readline();
var inf = 1000000000000;
for(var tc=1;tc<=T;tc++) {
	var n = readline();
	var N = n.length;
	var ok = false;
	var ref = ["Y","e","s"];
	var r = ref.indexOf(n[0]);
	if(r!==-1) {
		var j = 0;
		while(j<N && n[j] === ref[r]) {
			j++;
			r = (r+1)%3;
		}
		if(j==N) ok = true;
	}
	console.log(ok ? "Yes" : "No")
}

var input = readline();

print(Number(input))
for(var i=0; i<Number(input); i++) {
    var word = readline();
    if(word[0] != "Y" && word[0] != "e" && word[0] != "s") {
        print("NO");
        break;
    }

    for(var j=0; j<word.length; j++) {
        if(j == word.length - 1) {
            print("YES");
            break;
        }
        if(word[j] == "Y") {
            if(word[j+1] != "e") {
                print("NO");
                break;
            }
        }
        else if(word[j] == "e") {
            if(word[j+1] != "s") {
                print("NO");
                break;
            }
        }
        else {
            if(word[j+1] != "Y") {
                print("NO");
                break;
            }
        }
    }
}

var input = readline();

for(var i=0; i<Number(input); i++) {
    var word = readline();
    if(word[0] != "Y" && word[0] != "e" && word[0] != "s") {
        print("NO");
        break;
    }

    for(var j=0; j<word.length; j++) {
        if(j == word.length - 1) {
            print("YES");
            break;
        }
        if(word[j] == "Y") {
            if(word[j+1] != "e") {
                print("NO");
                break;
            }
        }
        else if(word[j] == "e") {
            if(word[j+1] != "s") {
                print("NO");
                break;
            }
        }
        else {
            if(word[j+1] != "Y") {
                print("NO");
                break;
            }
        }
    }
}

var input = readline();

for(var i=0; i<Number(input).length; i++) {
    var word = readline();
    if(word[0] != "Y" && word[0] != "e" && word[0] != "s") {
        print("NO");
        break;
    }

    for(var j=0; j<word.length; j++) {
        if(j == word.length - 1) {
            print("YES");
            break;
        }
        if(word[j] == "Y") {
            if(word[j+1] != "e") {
                print("NO");
                break;
            }
        }
        else if(word[j] == "e") {
            if(word[j+1] != "s") {
                print("NO");
                break;
            }
        }
        else {
            if(word[j+1] != "Y") {
                print("NO");
                break;
            }
        }
    }
}


process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    B();
});

function readline() {
    return inputString[currentLine++];
}

function pi(a) {
    return parseInt(a);
}

function ti(a){
    for(let i = 0; i < a.length; i++)
        a[i] = pi(a[i]);

    return a;
}

function A(){
    let t = pi(readline());
    while(t > 0){
        t--;
        let [x,y] = ti(readline().split(' '));

        let min = Math.min(x,y);
        let max = Math.max(x,y);
        if(max === min){
            console.log(max+min);
        }else{
            console.log(2*min+(1+(max-min-1)*2));
        }
    }
}

function B(){
    let t = pi(readline());
    while(t > 0){
        t--;
        let n = pi(readline());
        let a = ti(readline().split(' '));
        a.sort((a,b) => a-b);

        let sum = 0;
        for(let i = 0; i < a.length; i++)
            sum += a[i];

        let x = sum-a[0];
        let d = a[n-1]*(n-1)-x;

        if(a[0] > d){
            let diff = a[0]-d;
            console.log(diff % (n-1) === 0 ? 0 : ((n-1) - (diff % (n-1))));
        }else{
            console.log(d-a[0]);
        }
    }
}

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}

// utils
const MOD = 1e9 + 7;
const mod = (n) => ((n % MOD) + MOD) % MOD;
const add = (a, b) => mod(mod(a) + mod(b));
const sub = (a, b) => mod(mod(a) - mod(b));
function mul() {
  for (var a = arguments, r = a[0], i = a.length; --i; )
    r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;
  return r;
}
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);
  u %= MOD;
  return u < 0 ? u + MOD : u;
}
function pow(base, n) {
  if (n === 0) return 1;
  let p = pow(base, Math.floor(n / 2));
  let res = mul(mod(p), mod(p));
  if (n % 2 === 1) res = mul(mod(res), base);
  return res;
}
function highestOneBit(i) {
  i |= i >> 1;
  i |= i >> 2;
  i |= i >> 4;
  i |= i >> 8;
  i |= i >> 16;
  return i - (i >>> 1);
}
function permutation(arr, len, store = "", permutations = []) {
  if (store.length === len) {
    permutations.push(store);
    return;
  }
  for (let i = 0; i < arr.length; i++) {
    const newArr = [...arr];
    const newChar = newArr.splice(i, 1);
    permutation(newArr, len, store.concat(newChar), permutations);
  }
  return permutations;
}

function main() {
  let t = +readLine();
  while (t--) {
    const len = +readLine();
    let [max, sum] = [-Infinity, 0];
    readLine()
      .split(" ")
      .forEach((n) => {
        n = parseInt(n);
        sum += n;
        max = Math.max(max, n);
      });

    const value = Math.ceil(sum / (len - 1));
    if (max > value) {
      let output = Math.abs((len - 1) * max - sum);
      console.log(output);
    } else {
      let output = Math.abs(sum - (len - 1) * value);
      console.log(output);
    }
  }
}

/*
You are asked to watch your nephew who likes to play with toy blocks in a strange way.

He has n boxes and the i-th box has ai blocks. His game consists of two steps:

he chooses an arbitrary box i;
he tries to move all blocks from the i-th box to other boxes.
If he can make the same number of blocks in each of n−1 other boxes then he will be happy, otherwise, will be sad. Note that your nephew can only move the blocks from the chosen box to the other boxes; he cannot move blocks from the other boxes.
You don't want to make your nephew sad, so you decided to put several extra blocks into some boxes in such a way that no matter which box i he chooses he won't be sad. What is the minimum number of extra blocks you need to put?

Input
The first line contains a single integer t (1≤t≤1000) — the number of test cases.

The first line of each test case contains the integer n (2≤n≤105) — the number of boxes.

The second line of each test case contains n integers a1,a2,…,an (0≤ai≤109) — the number of blocks in each box.

It's guaranteed that the sum of n over test cases doesn't exceed 105.

inputCopy
3
3
3 2 2 -> 3. 1 -> 2 || 2 (2,3,2) || (2,2,3) 2. 1->
4
2 2 3 2
3
0 3 0
outputCopy
1
0
3

In the first test case, you can, for example, put one extra block into the first box and make a=[4,2,2]. If your nephew chooses the box with 4 blocks, then we will move two blocks to the second box and two blocks to the third box (0,4,4). If he chooses the box with 2 blocks then he will move these two blocks to the other box with 2 blocks. (4,0,4) || (4,4,0)

In the second test case, you don't need to put any extra blocks, since no matter which box your nephew chooses, he can always make other boxes equal.

In the third test case, you should put 3 extra blocks. For example, you can put 2 blocks in the first box and 1 block in the third box. You'll get array a=[2,3,1].
*/

'use-strict'

process.stdin.resume();
process.stdin.setEncoding('utf8');

let data = '';
let currentLine = 0;

process.stdin.on('data', chunk => {
data += chunk;
});

process.stdin.on('end', () =>{
    data = data.replace(/\s*$/, '')
    .split('\n')
    .map(str => str.replace(/\s*$/, ''));

    let testCases = parseInt(data.shift());

    while(testCases--) {

        const n = parseInt(data.shift());

        const arr = get_ints();

        const res = b(n,arr);

        console.log(res)
    }
});

function get_ints() {
    return data.shift().split(' ').map(Number);
}

function readLine() {
        return data[currentLine++];
}

function b(n, arr)
{
    arr.sort((a,b) => b - a);

    const max = arr[0];

    const sum = arr.reduce((a, b) => a + b);

    const k = Math.max(Math.ceil(sum/(n - 1)), max)

    return (n - 1) * k - sum;
}

module.exports = b;

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    B();
});

function readline() {
    return inputString[currentLine++];
}

function pi(a) {
    return parseInt(a);
}

function ti(a){
    for(let i = 0; i < a.length; i++)
        a[i] = pi(a[i]);

    return a;
}

function A(){
    let t = pi(readline());
    while(t > 0){
        t--;
        let [x,y] = ti(readline().split(' '));

        let min = Math.min(x,y);
        let max = Math.max(x,y);
        if(max === min){
            console.log(max+min);
        }else{
            console.log(2*min+(1+(max-min-1)*2));
        }
    }
}

function B(){
    let t = pi(readline());
    while(t > 0){
        t--;
        let n = pi(readline());
        let a = ti(readline().split(' '));
        a.sort((a,b) => a-b);

        let sum = 0;
        for(let i = 0; i < a.length; i++)
            sum += a[i];

        let x = sum-a[0];
        let d = a[n-1]*(n-1)-x;

        if(a[0] > d){
            let diff = a[0]-d;
            console.log(diff % (n-1));
        }else{
            console.log(d-a[0]);
        }
    }
}