function begin(nums) {
    nums.sort((a,b) => a - b);
    for(var i = 1; i < nums.length; i++) {
        if(nums[i] == nums[i-1]) {
            print("NO");
            return;
        }
    }
    print("YES");
}

var caseNum = parseInt(readline(), 10);
for (var i = 0; i < caseNum; i++) {
    var n = parseInt(readline(), 10);
    var x = readline()
        .trim()
        .split(' ')
        .map((y) => parseInt(y, 10));
        begin(x);
}

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

let inputString = "";
let currentLine = 0;

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

process.stdin.on("end", function () {
  inputString = inputString.split("\n");
  main();
});

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

function possibleIncrease(cases) {
  for (let i = 0; i < cases.length; i++) {
    const [...elements] = cases[i];
    let dict = {};
    for (let j = 0; j < elements.length; j++) {
      dict = {
        ...dict,
        [elements[j]]: isNaN(dict[[elements[j]]])
          ? 1
          : Number(dict[[elements[j]]]) + 1,
      };
    }

    const res = Object.keys(dict).some((element) => {
      if (dict[element] > 1) {
        return true;
      }
    });

    const sortElements = cases[i];
    sortElements.sort((a, b) => a - b);

    let isSorted = true;
    for (let j = 0; j < elements.length && isSorted; j++) {
      if (elements[j] !== sortElements[j]) {
        isSorted = false;
      }
    }
    console.log(res ? "NO" : "YES");
  }
}

function main() {
  const t = parseInt(readLine().trim());
  const cases = [];
  for (let i = 0; i < t * 2; i++) {
    const numbers = readLine().trim().split(" ");
    if (i % 2 === 1) cases.push(numbers);
  }

  possibleIncrease(cases);
}

const readline = require('readline');

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
});
const data = [];
const input = [];
rl.on('line', line => {
  input.push(line);
}).on('close', () => {
  const dSize = parseInt(input[0], 10);
  for (let i = 1; i < input.length; i += 2) {
    const size = parseInt(input[i], 10);
    if (
      new Set(input[i + 1].split(' ').map(x => parseInt(x, 10))).size === size
    ) {
      data.push('YES');
    } else {
      data.push('NO');
    }
  }
  if (data.length === dSize) {
    console.log(data.join('\n'));
    process.exit(0);
  }
});

const readline = require('readline');

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
});
const data = [];
const input = [];
rl.on('line', line => {
  input.push(line);
}).on('close', () => {
  const dSize = parseInt(input[0], 10);
  for (let i = 1; i < input.length; i += 2) {
    const size = parseInt(input[i], 10);
    new Set(input[i + 1].split(' ').map(x => parseInt(x, 10))).size === size
      ? data.push('YES')
      : data.push('NO');
  }
  if (data.length === dSize) {
    console.log(data.join('\n'));
    process.exit(0);
  }
});

const readline = require('readline');

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

rl.on('line', line => {
  input.push(line);
}).on('close', () => {
  const dSize = parseInt(input[0], 10);
  for (let i = 1; i < input.length; i += 2) {
    new Set(input[i + 1].split(' ').map(x => parseInt(x, 10))).size ===
    parseInt(input[i], 10)
      ? data.push('YES')
      : data.push('NO');
  }
  if (data.length === dSize) {
    console.log(data.join('\n'));
    process.exit(0);
  }
});

const readline = require('readline');

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
});
const data = [];
const input = [];
process.stdin.resume();
process.stdin.setEncoding('utf8');
rl.on('line', line => {
  input.push(line);
}).on('close', () => {
  const dSize = parseInt(input[0], 10);
  for (let i = 1; i < input.length; i += 2) {
    const size = parseInt(input[i], 10);
    const arr = input[i + 1].split(' ').map(x => parseInt(x, 10));
    new Set(arr).size === size ? data.push('YES') : data.push('NO');
  }
  if (data.length === dSize) {
    console.log(data.join('\n'));
    rl.close();
    process.exit(0);
  }
});

// cls; cat .\input.txt | node .\script.js
// codium --diff file1.js file2.js
'use strict';
async function main(read) {
    let amount = Number(await read());
    let output = ""
    while (amount > 0) {
        let length = Number(await read())
        let array = await read().split(' ').map(Number).sort((a, b) => a - b)
        let answer = array.every((e, i) => array.lastIndexOf(e) == i)
        output += (answer ? "YES" : "NO") + '\n'
        amount--
    }
    return output
}

let inputs, str = '';
function read() {
    return inputs.next().value.trim();
}
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', input => str += input);
process.stdin.on('end', async () => {
    inputs = str.split('\n').values();
    const output = await main(read);
    process.stdout.write(output);
});

//  var gcd = function(a, b) {
//   if (!b) {
//     return a;
//   }

//   return gcd(b, a % b);
// }
let ryan = '';//.map(Number).sort(function(a, b){return a - b})
process.stdin.on('data', c => ryan += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = ryan.split(EOL);
    var n = lines[0]
    for(j = 1; j <= n * 2; j++){
        if(j % 2 == 1){
            var e = lines[j], a = new Map(), f=  false
        }else{
            k = lines[j].split(' ').map(Number)
            for(l = 0; l < e; l++){
                if(a.has(k[l])){
                    f = true
                    break;
                }else{
                    a.set(k[l])
                }
            }
            console.log(f === true ? 'NO' : 'YES')
        }

    }
});

        const fs = require('fs');
        const input = fs.readFileSync(0, 'utf8').trim().split('\n');

        let currentline = 0;
        function readline(){
            return input[currentline++];
        }

        let T = readline();
        for(let i = 1; i <= T; i++){
            let N = readline().split(' ');
            let arr = readline().split(' ').map(Number);
            console.log(solve(arr, N));
        }

        function solve(arr, N){
            let itms = new Set();
            for(let i=0;i<arr.length;i++){
                itms.add(arr[i]);
            }
            return (itms.size === arr.length) ? 'YES' : 'NO';
        }

let stop = '';
process.stdin.on('data', c => stop += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = stop.split(EOL);
    var t = lines[0];
    var n = 0;
    for(i = 1; i <= t * 2; i++){
        if(i % 2 == 1){
            n = lines[i], a = new Map(), flag = false;
        }else{
            k = lines[i].split(' ').map(Number);
            for(j = 0; j < n; j++){
                if(a.has(k[j])){
                    flag = true;
                    break;
                }else{
                    a.set(k[j]);
                }
            }
            console.log(flag === true ? 'NO' : 'YES');
        }
    }
});

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();
  });
  solve();
});
function readline() {
  return inputString[currentLine++];
}

function solve() {
  var t = readline();
  for (var k = 0; k < t; k++) {
    var n = readline();
    var a = readline().split(' ');
    var repeated = a.filter(function (e, i, a) {
      return a.indexOf(e) !== i;
    })
    if (repeated.length == 0) {
      process.stdout.write('YES\n');
    } else {
      process.stdout.write('NO\n');
    }
  }
}

let buf='';

process.stdin.on('readable',function(){
    let chunk=process.stdin.read();
    if(chunk) buf+=chunk.toString();
})

process.stdin.on('end',function(){
    const {EOL} = require('os');
    let line=buf.split(EOL);
    let t=parseInt(line[0]);
    // console.log(EOL);
    for(let z=1;z<=t;z++)
    {
        let n=parseInt(line[2*z-1]);
        let arr=line[2*z].split(' ').map(x=>{return parseInt(x)});
        // console.log(arr);
        const st=new Set();
        for(let i=0;i<arr.length;i++) st.add(arr[i]);
        if(st.size===n) console.log("YES");
        else console.log("NO");
    }
})

const lines = [];
let currentLineIndex = 0;
const readlineInterface = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});
readlineInterface.on("line", (line) => {
  if (currentLineIndex > 0 && currentLineIndex % 2 === 0) {
    lines.push(line);
  }
  currentLineIndex++;
});

readlineInterface.on("close", () => {
  const tests = lines.map((line) => line.split(" ").map((e) => +e));

  tests
    .map((numbers) => {
      return new Set(numbers).size === numbers.length ? "YES" : "NO";
    })
    .forEach((e) => console.log(e));
});

/**
 * 10/13/22 morning
 * https://codeforces.com/contest/1742/problem/B
 */

const pr = console.log;

const solve = (n, a) => {
    a.sort((x, y) => x - y);
    for (let i = 1; i < n; i++) {
        if (a[i] == a[i - 1]) return pr("NO");
    }
    pr("YES");
};

const main = () => {
    const readLine = () => input[currentLine++];
    const ni = () => readLine() - '0';
    const nas = () => readLine().split(" ");
    const nai = () => nas().map(Number);
    const nal = () => nas().map(BigInt);
    let input = '', currentLine = 0;
    process.stdin.on('data', (stdin) => input += stdin)
    process.stdin.on('end', () => {
        input = input.split('\n');
        let t = ni();
        while (t--) {
            let n = ni(), a = nai();
            solve(n, a);
        }
    });
};

main()

const readline = require("readline");

var tcn = 0
var isnTurn = true

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

rl.on('line', line => {
  if (!tcn) return tcn = Number(line)

  if (isnTurn) {
    isnTurn = false
  }
  else {
    isnTurn = true
    run(line)
    if (!--tcn) rl.close()
  }

})

function run(line) {
  var vals = line.split(' ').map(val => Number(val)).sort((a, b) => a - b)
  for (let index = 0; index < vals.length - 1; index++) {
    if (vals[index] == vals[index + 1]) {
      console.log('NO')
      return
    }
  }
  console.log('YES')
}

/*
** Template
*/

// 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) => {
            return string.trim();
        });

    main();
});

function readline() {
    return 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 arr2 = uniqueArray( arr )

    if( arr.length === arr2.length ) return 'YES'

    return 'NO'
}

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)

// cmd: cat input.txt | node main.js

'use strict';

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

let processIn = '';
let processCurr = 0;

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

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

    JS();
});

function readLine() {
    return processIn[processCurr++];
}
function mergeSort(a) {
    let r = a.length;
    let l = 0;
    let m = Math.round((r - l) / 2);
    if (r === 1) {
        return;   // returns recursively
    }
    let L = [];   // left half of current a
    let R = [];   // right half of current a
    for (let i = l; i < m; i++) {
        L.push(a[i]);
    }
    for (let j = m; j < r; j++) {
        R.push(a[j]);
    }
    mergeSort(L);
    mergeSort(R);
    let i = 0, j = 0, k = 0;
    // Merging part
    while (i < L.length && j < R.length) {
        if (L[i] < R[j]) {
            a[k] = L[i];
            i++;
        } else {
            a[k] = R[j];
            j++;
        }
        k++;
    }
    while (i < L.length) {
        a[k] = L[i];
        i++;
        k++;
    }
    while (j < R.length) {
        a[k] = R[j];
        j++;
        k++;
    }
}

function JS() {
    /*

    */
    let tt = parseInt(readLine());
    // let tt = 1;
    for(let t=0;t<tt;++t){
        let n = parseInt(readLine());
        let l = readLine().trim().split(' ').map(string => { return parseInt(string.trim()); });
        mergeSort(l);
        let flag = 1;
        for(let i=0;i<n-1;++i){
            if(l[i] === l[i+1]){
                flag = 0;
            }
        }
        if(flag){
            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() {
  let t = readline();
  for (let i = 0; i < t; i++) {
    let n = readline();
    let arr = readline().split(" ").map(Number);
    const set = new Set();
    for (let i = 0; i < arr.length; i++) {
      if (!set.has(arr[i])) {
        set.add(arr[i]);
      }
    }
    if (set.size === arr.length) {
      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) {
  const [rn, rb, rns, re, rbs] = convertInput(read);
  const n = rn(),
        a = rns(n);
  a.sort((a, b) => a - b);
  for (let i = 0; i < n - 1; i++) {
    if (a[i] >= a[i + 1]) return 'NO';
  }
  return 'YES';
}
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);
}();

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 n = +lines[l++]
        const arr = lines[l++].trim().split(' ').map(Number)
        output[i] = solve(n, arr)
    }
    console.log(output.join('\n'))
// })()
})

function solve(n, arr) {
    const m = {}
    for (let x of arr) {
        if (m[x]) return 'NO'
        m[x] = 1
    }
    return 'YES'
}

// run on javascript V8 4.8.0
// https://codeforces.com/contest/1742/problem/A
// You are given an array a of n positive integers. Determine if, by rearranging the elements, you can make the array strictly increasing. In other words, determine if it is possible to rearrange the elements such that a1<a2<⋯<an holds.
function main() {
    var tn = +readline(); // Number of test cases
    for (var i = 0; i < tn; i++) {
        var n = +readline();
        var a = readline().split(' ').map(Number);
        // Call solve()
        solve(n, a);
    }
}

function solve(n, a) {
    // Sort array in ascending order using quicksort
    var quicksort = function (a) {
        if (a.length <= 1) {
            return a;
        }
        var pivot = a[0];
        var left = [];
        var right = [];
        for (var i = 1; i < a.length; i++) {
            if (a[i] < pivot) {
                left.push(a[i]);
            } else {
                right.push(a[i]);
            }
        }
        return quicksort(left).concat(pivot, quicksort(right));
    }
    var a = quicksort(a);
    // Check if a is in non-decreasing order
    var isDecreasing = function (a) {
        for (var i = 1; i < a.length; i++) {
            if (a[i-1] > a[i]) {
                return true;
            }
        }
        return false;
    }
    var isEqual = function (a) {
        for (var i = 1; i < a.length; i++) {
            if (a[i-1] == a[i]) {
                return true;
            }
        }
        return false;
    }

    if (isDecreasing(a)) {
        print('NO');
    }
    else if (isEqual(a)) {
        print('NO');
    }
    else {
        print('YES');
    }
}

main();

const tc = readline();
for (var t =0 ; t<tc;t++){
   var n = readline();
   var input = readline().split(" ").map(i=>Number(i));
   input = input.sort();
   var b = true;
   for(var i=1;i<n;i++){
       if(input[i]==input[i-1]){
           if(b)
           print("NO")
           b = false;
       }
   }
   if(b)
   print("YES")
}

var limit = parseInt(readline());
for (var i = 0; i < limit; i++)
{
    var caseLength = parseInt(readline());
    var caseArray = readline().split(" ");
    var caseMap = new Map();
    var flag = true;
    for (var j = 0; j < caseLength; j++)
    {
        var current = parseInt(caseArray[j]);
        if (caseMap.has(current))
        {
            flag = false;
            break;
        }
        else
        {
            caseMap.set(current, current);
        }
    }
    if (flag) print("YES"); else print("NO");

}

var tests = +readline();

for(var i=0; i<tests; i++) {
    var hash = {};
    var l = +readline();
    var nums = readline().split(" ");
    var pos = true;
    for(var index = 0; index < l; index++) {
        if(hash[nums[index]]) {
            var pos = false;
            print("NO");
            break;
        }else {
            hash[nums[index]] = true
        }
    }
    if(pos) {
        print("YES");
    }
}

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

let inputString = "";
let currentLine = 0;

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

process.stdin.on("end", function () {
  inputString = inputString.split("\n");
  main();
});

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

function possibleIncrease(cases) {
  for (let i = 0; i < cases.length; i++) {
    const [...elements] = cases[i];
    let dict = {};
    for (let j = 0; j < elements.length; j++) {
      dict = {
        ...dict,
        [elements[j]]: isNaN(dict[[elements[j]]])
          ? 1
          : Number(dict[[elements[j]]]) + 1,
      };
    }

    const res = Object.keys(dict).some((element) => {
      if (dict[element] > 1) {
        return true;
      }
    });

    // const sortElements = cases[i];
    // sortElements.sort((a, b) => a - b);

    // let isSorted = true;
    // for (let j = 0; j < elements.length && isSorted; j++) {
    //   if (elements[j] !== sortElements[j]) {
    //     isSorted = false;
    //   }
    // }
    console.log(res ? "NO" : "YES");
  }
}

function main() {
  const t = parseInt(readLine().trim());
  const cases = [];
  for (let i = 0; i < t * 2; i++) {
    const numbers = readLine().split(" ");
    if (i % 2 === 1) cases.push(numbers);
  }

  possibleIncrease(cases);
}

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

let inputString = "";
let currentLine = 0;

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

process.stdin.on("end", function () {
  inputString = inputString.split("\n");
  main();
});

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

function possibleIncrease(cases) {
  for (let i = 0; i < cases.length; i++) {
    const [...elements] = cases[i];
    let dict = {};
    for (let j = 0; j < elements.length; j++) {
      dict = {
        ...dict,
        [elements[j]]: isNaN(dict[[elements[j]]])
          ? 1
          : Number(dict[[elements[j]]]) + 1,
      };
    }

    const res = Object.keys(dict).some((element) => {
      if (dict[element] > 1) {
        return true;
      }
    });

    console.log("ress nya:", res);

    const sortElements = cases[i];
    sortElements.sort((a, b) => a - b);

    let isSorted = true;
    for (let j = 0; j < elements.length && isSorted; j++) {
      if (elements[j] !== sortElements[j]) {
        isSorted = false;
      }
    }
    console.log(res ? "NO" : "YES");
  }
}

function main() {
  const t = parseInt(readLine().trim());
  const cases = [];
  for (let i = 0; i < t * 2; i++) {
    const numbers = readLine().split(" ");
    if (i % 2 === 1) cases.push(numbers);
  }

  possibleIncrease(cases);
}

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

let inputString = "";
let currentLine = 0;

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

process.stdin.on("end", function () {
  inputString = inputString.split("\n");
  main();
});

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

function possibleIncrease(cases) {
  for (let i = 0; i < cases.length; i++) {
    const [...elements] = cases[i];
    let dict = {};
    for (let j = 0; j < elements.length; j++) {
      dict = {
        ...dict,
        [elements[j]]: isNaN(dict[[elements[j]]])
          ? 1
          : Number(dict[[elements[j]]]) + 1,
      };
    }

    const res = Object.keys(dict).some((element) => {
      if (dict[element] > 1) {
        return true;
      }
    });

    const sortElements = cases[i];
    sortElements.sort((a, b) => a - b);

    let isSorted = true;
    for (let j = 0; j < elements.length && isSorted; j++) {
      if (elements[j] !== sortElements[j]) {
        isSorted = false;
      }
    }
    console.log(res ? "NO" : "YES");
  }
}

function main() {
  const t = parseInt(readLine().trim());
  const cases = [];
  for (let i = 0; i < t * 2; i++) {
    const numbers = readLine().split(" ");
    if (i % 2 === 1) cases.push(numbers);
  }

  possibleIncrease(cases);
}

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

let inputString = "";
let currentLine = 0;

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

process.stdin.on("end", function () {
  inputString = inputString.split("\n");
  main();
});

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

function possibleIncrease(cases) {
  for (let i = 0; i < cases.length; i++) {
    const [...elements] = cases[i];
    let dict = {};
    for (let j = 0; j < elements.length; j++) {
      dict = {
        ...dict,
        [elements[j]]: isNaN(dict[[elements[j]]])
          ? 1
          : Number(dict[[elements[j]]]) + 1,
      };
    }

    const res = Object.keys(dict).some((element) => {
      if (dict[element] > 1) {
        return true;
      }
    });

    const sortElements = cases[i];
    sortElements.sort((a, b) => a - b);

    let isSorted = true;
    for (let j = 0; j < elements.length && isSorted; j++) {
      if (elements[j] !== sortElements[j]) {
        isSorted = false;
      }
    }
    console.log(res || (isSorted && elements.length > 1) ? "NO" : "YES");
  }
}

function main() {
  const t = parseInt(readLine().trim());
  const cases = [];
  for (let i = 0; i < t * 2; i++) {
    const numbers = readLine().split(" ");
    if (i % 2 === 1) cases.push(numbers);
  }

  possibleIncrease(cases);
}

const readline = require('readline');
const util = require('util');

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
});
const question = util.promisify(rl.question).bind(rl);
const data = [];

rl.question('', async testCaseSize => {
  const dSize = parseInt(testCaseSize, 10);
  for (let i = 0; i < dSize; i++) {
    const size = parseInt(await question(''), 10);
    const arr = (await question('')).split(' ').map(x => parseInt(x, 10));
    new Set(arr).size === size ? data.push('YES') : data.push('NO');
    if (data.length === dSize) {
      console.log(data.join('\n'));
      rl.close();
    }
  }
});

rl.on('close', function () {
  process.exit(0);
});

// cls; cat .\input.txt | node .\script.js
// codium --diff file1.js file2.js
'use strict';
async function main(read) {
    let amount = Number(await read());
    let output = ""
    while (amount > 0) {
        try {
            let length = Number(await read())
            let array = await read().split(' ').map(Number).sort((a, b) => a - b)
            while (array.length > 1) {
                let c = array.shift()
                let n = array.shift()
                if (c < n) continue
                break
            }
            output += (array.length == 0 ? "YES" : "NO") + '\n'
        } catch (error) {
            console.log(error);
        }
        amount--
    }
    return output
}

let inputs, str = '';
function read() {
    return inputs.next().value.trim();
}
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', input => str += input);
process.stdin.on('end', async () => {
    inputs = str.split('\n').values();
    const output = await main(read);
    process.stdout.write(output);
});

// cls; cat .\input.txt | node .\script.js
// codium --diff file1.js file2.js
'use strict';
async function main(read) {
    let amount = Number(await read());
    let output = ""
    while (amount > 0) {
        try {
            let length = Number(await read())
            let array = await read().split(' ').map(Number).sort((a, b) => a - b)
            while (array.length > 0) {
                let c = array.shift()
                let n = array.shift()
                if (c >= n) break
            }
            output += (array.length == 0 ? "YES" : "NO") + '\n'
        } catch (error) {
            console.log(error);
        }
        amount--
    }
    return output
}

let inputs, str = '';
function read() {
    return inputs.next().value.trim();
}
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', input => str += input);
process.stdin.on('end', async () => {
    inputs = str.split('\n').values();
    const output = await main(read);
    process.stdout.write(output);
});

// cls; cat .\input.txt | node .\script.js
// codium --diff file1.js file2.js
'use strict';
async function main(read) {
    let amount = Number(await read());
    let output = ""
    while (amount > 0) {
        try {
            let length = Number(await read())
            let array = await read().split(' ').sort((a, b) => a - b)
            while (array.length > 0) {
                let c = array.shift()
                let n = array.shift()
                if (c >= n) break
            }
            output += (array.length == 0 ? "YES" : "NO") + '\n'
        } catch (error) {
            console.log(error);
        }
        amount--
    }
    return output
}

let inputs, str = '';
function read() {
    return inputs.next().value.trim();
}
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', input => str += input);
process.stdin.on('end', async () => {
    inputs = str.split('\n').values();
    const output = await main(read);
    process.stdout.write(output);
});

//  var gcd = function(a, b) {
//   if (!b) {
//     return a;
//   }

//   return gcd(b, a % b);
// }
let ryan = '';//.map(Number).sort(function(a, b){return a - b})
process.stdin.on('data', c => ryan += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = ryan.split(EOL);
    var n = lines[0]
    for(j = 1; j <= n * 2; j++){
        if(j % 2 == 1){
            var e = lines[j], a = new Map(), f=  false
        }else{
            k = lines[j].split(' ').map(Number)
            for(l = 0; l < e; l++){
                if(a.has(k[l])){
                    f = true
                    break;
                }
            }
            console.log(f === true ? 'NO' : 'YES')
        }

    }
});

//  var gcd = function(a, b) {
//   if (!b) {
//     return a;
//   }

//   return gcd(b, a % b);
// }
let ryan = '';//.map(Number).sort(function(a, b){return a - b})
process.stdin.on('data', c => ryan += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = ryan.split(EOL);
    var n = lines[0]
    for(j = 1; j <= n * 2; j++){
        if(j % 2 == 1){
            var e = lines[j], a = new Map(), f=  false
        }else{
            k = lines[j].split(' ').map(Number)
            for(l = 0; l < e; l++){
                if(a.has(k[l])){
                    f = true
                    break;
                }
            }
            console.log(f === true ? 'NO' : 'YES')
            break;
        }

    }
});

    const fs = require('fs');
    const input = fs.readFileSync(0, 'utf8').trim().split('\n');

    let currentline = 0;
    function readline(){
        return input[currentline++];
    }

    let T = readline();
    for(let i = 1; i <= T; i++){
        let N = readline().split(' ');
        let arr = readline().split(' ').map(Number);
        console.log(N, arr);
        console.log(solve(arr, N));
    }

    function solve(arr, N){
        let itms = new Set();
        for(let i=0;i<N;i++){
            itms.add(arr[i]);
        }
        return (itms.size === N) ? 'YES' : 'NO';
    }

const fs = require('fs');
const input = fs.readFileSync(0, 'utf8').trim().split('\n');

let currentline = 0;
function readline(){
    return input[currentline++];
}

let T = readline();
for(let i = 1; i <= T; i++){
    let N = readline().split(' ');
    let arr = readline().split(' ').map(Number);
    console.log(solve(arr, N));
}

function solve(arr, N){
    let itms = new Set();
    for(let i=0;i<N;i++){
        itms.add(arr[i]);
    }
    return (itms.size === N) ? 'YES' : 'NO';
}

// run on javascript V8 4.8.0
// https://codeforces.com/contest/1742/problem/A
// You are given an array a of n positive integers. Determine if, by rearranging the elements, you can make the array strictly increasing. In other words, determine if it is possible to rearrange the elements such that a1<a2<⋯<an holds.
function main() {
    var tn = +readline(); // Number of test cases
    for (var i = 0; i < tn; i++) {
        var n = +readline();
        var a = readline().split(' ').map(Number);
        // Call solve()
        solve(n, a);
    }
}

function solve(n, a) {
    // Sort array in ascending order using quicksort
    var quicksort = function (a) {
        if (a.length <= 1) {
            return a;
        }
        var pivot = a[0];
        var left = [];
        var right = [];
        for (var i = 1; i < a.length; i++) {
            if (a[i] < pivot) {
                left.push(a[i]);
            } else {
                right.push(a[i]);
            }
        }
        return quicksort(left).concat(pivot, quicksort(right));
    }
    var a = quicksort(a);
    // Check if a is in non-decreasing order
    var isDecreasing = function (a) {
        for (var i = 1; i < a.length; i++) {
            if (a[i-1] > a[i]) {
                return true;
            }
        }
        return false;
    }
    if (!isDecreasing(a)) {
        print('YES');
    }
    else {
        print('NO');
    }
}

main();

// run on javascript V8 4.8.0
// https://codeforces.com/contest/1742/problem/A
// You are given an array a of n positive integers. Determine if, by rearranging the elements, you can make the array strictly increasing. In other words, determine if it is possible to rearrange the elements such that a1<a2<⋯<an holds.
function main() {
    var tn = +readline(); // Number of test cases
    for (var i = 0; i < tn; i++) {
        var n = +readline();
        var a = readline().split(' ').map(Number);
        // Call solve()
        solve(n, a);
    }
}

function solve(a) {
    // Sort array in ascending order using quicksort
    var quickSort = function (a) {
        if (a.length <= 1) {
            return a;
        }
        var pivot = a[0];
        var left = [];
        var right = [];
        for (var i = 1; i < a.length; i++) {
            if (a[i] < pivot) {
                left.push(a[i]);
            } else {
                right.push(a[i]);
            }
        }
        return quickSort(left).concat(pivot, quickSort(right));
    }
    var a = quickSort(a);
    for (var i = 0; i < a.length; i++) {
        if (a[i] == a[i+1]) {
            print('NO');
            print(a[i]);
            return;
        }
    }
    print('YES');
}

main();

// run on javascript V8 4.8.0
// https://codeforces.com/contest/1742/problem/A
// You are given an array a of n positive integers. Determine if, by rearranging the elements, you can make the array strictly increasing. In other words, determine if it is possible to rearrange the elements such that a1<a2<⋯<an holds.
function main() {
    var tn = +readline(); // Number of test cases
    for (var i = 0; i < tn; i++) {
        var n = +readline();
        var a = readline().split(' ').map(Number);
        // Call solve()
        solve(n, a);
    }
}

function solve(a) {
    // Sort array in ascending order using quicksort
    var quickSort = function (a) {
        if (a.length <= 1) {
            return a;
        }
        var pivot = a[0];
        var left = [];
        var right = [];
        for (var i = 1; i < a.length; i++) {
            if (a[i] < pivot) {
                left.push(a[i]);
            } else {
                right.push(a[i]);
            }
        }
        return quickSort(left).concat(pivot, quickSort(right));
    }
    var a = quickSort(a);
    for (var i = 0; i < a.length; i++) {
        if (a[i] == a[i+1]) {
            print('NO');
            return;
        }
    }
    print('YES');
}

main();

const tc = readline();
for (var t =0 ; t<tc;t++){
   var n = readline();
   var input = readline().split(" ").map(i=>Number(i));
   input = input.sort();
   var b = true;
   for(var i=1;i<n;i++){
       if(input[i]<=input[i-1]){
           if(b)
           print("NO")
           b = false;
       }
   }
   if(b)
   print("YES")
}

var limit = parseInt(readline());
for (var i = 0; i < limit; i++)
{
    var caseLength = parseInt(readline());
    var caseArray = readline().split(" ");
    var caseMap = new Map();
    var flag = true;
    for (var j = 0; j < caseLength; j++)
    {
        var current = parseInt(caseArray[j]);
        if (caseMap.has(current))
        {
            flag = false;
            break;
        }
        else
        {
            caseMap[current] = current;
        }
    }
    if (flag) print("YES"); else print("NO");

}


const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});
let c = 0;
let n, m;
const points = [];
const strs = [];

rl.on('line', (d) => {
  if (c === 0) {
    c++;
    [n, m] = d.split(' ').map(Number);
    return;
  }

  if (n) {
    strs.push(d);
    n--;
    return;
  }

  points.push(...d.split(' ').map(Number));

  c++;
});

rl.on('close', () => {
  let ans = 0;

  for (let i = 0; i < strs[0].length; i++) {
    const obj = {};
    for (let j = 0; j < strs.length; j++) {
      if (obj[strs[j][i]]) {
        obj[strs[j][i]]++;
      }
      else {
        obj[strs[j][i]] = 1;
      }
    }

    const values = Object.values(obj).sort((a, b) => b - a);
    ans += values[0] * points[i];
  }

  console.log(ans);
});

let i = '';
process.stdin.on('data', (c) => {
  i += c;
});
process.stdin.on('end', () => {
  const { EOL } = require('os');
  const lines = i.split(EOL);
  const scores = [];
  for (let i = 1; i < lines.length - 2; i++) {
    scores.push(lines[i]);
  }
  let values = lines[lines.length - 2].split(' ');
  values = values.map(val => parseInt(val, 10));
  getMaxScore(scores, values);
});

function getMaxScore(scores, values) {
  const buckets = [];
  buckets.length = 5;
  buckets.fill(0);

  const mapping = {
    A: 0,
    B: 1,
    C: 2,
    D: 3,
    E: 4,
  };

  let score = 0;
  for (let i = 0; i < scores[0].length; i++) {
    for (let j = 0; j < scores.length; j++) {
      const answer = scores[j][i];
      buckets[mapping[answer]]++;
    }
    const max = Math.max(...buckets);
    score += (max * values[i]);
    buckets.fill(0);
  }
  console.log(score);
}

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

const solution = () => {
	let line = data.split('\n');
	let [n, k] = line.shift().split(' ').map(v  => parseInt(v,10));
	let ans = [];
	for(let i = 0; i < n; i++){
		ans.push(line.shift());
	}
	let point = line.shift().split(' ').map(v => parseInt(v, 10));

	let sum = 0;
	let a = 'A'.charCodeAt(0);
	for(let i = 0; i < k; i++){
		let o = [0,0,0,0,0];
		for(let j = 0 ; j < n; j++){
			o[ans[j].charCodeAt(i) - a]++;
		}

		sum +=  Math.max(...o) * point[i];
	}
	console.log(sum);
}

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

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

const solution = () => {
	let line = data.split('\n');
	let [n, k] = line.shift().split(' ').map(v  => parseInt(v,10));
	let ans = [];
	for(let i = 0; i < n; i++){
		ans.push(line.shift());
	}
	let point = line.shift().split(' ').map(v => parseInt(v, 10));

	let sum = 0;
	for(let i = 0; i < k; i++){
		let o = {A: 0, B: 0, C: 0, D: 0, E: 0};
		for(let j = 0 ; j < n; j++){
			o[ans[j][i]]++;
		}

		let max = 0;
		for(let m in o){
			max = Math.max(o[m], max);
		}
		sum +=  max * point[i];
	}
	console.log(sum);
}

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

var keys = { A: 0, B: 1, C: 2, D: 3, E: 4 };

var nm = readline().split(' ').map(item => +item);

var answers = [];
for(var i = 0; i < nm[0]; i++) {
  answers.push(readline());
}

var sum = 0, vals = readline().split(' ').map(item => +item), ans = new Array(5);

for(var i = 0; i < nm[1]; i++) {
  ans.fill(0);
  for(var j = 0; j < nm[0]; j++) {
    ans[keys[answers[j][i]]]++;
  }
  sum += Math.max(...ans) * vals[i];
}

print(sum);

(function() {
var INPUT = ``;
var OUTPUT = ``;

var main = function() {"use strict";
    // TODO
    var input = rdArN();
    var n = input[0];
    var m = input[1];
    var M = crAr(m);
    for (var i = 0; i < M.length; ++i) {
        M[i] = {};
        M[i]['A'] = 0;
        M[i]['B'] = 0;
        M[i]['C'] = 0;
        M[i]['D'] = 0;
        M[i]['E'] = 0;
    }
    for (var i = 0; i < n; ++i) {
        var s = rdS();
        for (var j = 0; j < s.length; ++j) {
            ++M[j][s[j]];
        }
    }
    //prOb(M);
    var A = rdArN();
    var res = 0;
    for (var i = 0 ; i < m; ++i) {
        var max = -Infinity;
        for (var key in M[i]) {
            max = Math.max(max, M[i][key]);
        }
        res += max*A[i];
        //pr(max*A[i])
    }
    wr(res);
};

if(INPUT){INPUT=INPUT.split('\n').reverse();
readline=()=>INPUT.pop();
write=(...s)=>{OUTPUT+=[...s].join(' ')};
print=(...s)=>{write(...s);OUTPUT+='\n'};}
const
rdS=readline,
rdN=()=>+rdS(),
rdArS=()=>rdS().split(' '),
rdArN=()=>rdArS().map(v=>+v),
wr=write,
pr=print,
prAr=(a)=>pr(...a),
prOb=(o)=>pr(JSON.stringify(o,null,4)),
crAr=function(length,...fillArgs){return new Array(length).fill(...fillArgs);},
getPrimes=function(n){var sieve=crAr(n+1,true),primes=[],i,j;for(i=2,j=4;j<sieve.length;j=Math.pow(++i,2)){if(sieve[j]){for(;j<sieve.length;j+=i){sieve[j]=false;}}}for(i=2;i<sieve.length;++i){if(sieve[i]){primes.push(i);}}return primes;},
getPrimeFactors=function(n){var primes=getPrimes(Math.floor(Math.sqrt(n))),last=primes.push(n)-1,factors=[],i,p;for(i=0,p=primes[0];primes[last]>1;){if(primes[last]%p===0){primes[last]/=p;factors.push(p);}else{p=primes[++i];}}return factors;},
defineProperty=(o,pN,v)=>Object.defineProperty(o,pN,{value:v,writable:true,enumerable:false,configurable:true});
defineProperty(Array.prototype,'sortLt',function(){return this.sort((a,b)=>a-b);});
defineProperty(Array.prototype,'sortGt',function(){return this.sort((a,b)=>b-a);});

main();
return OUTPUT;
})();

let i = '';
process.stdin.on('data', (c) => {
  i += c;
});
process.stdin.on('end', () => {
  const { EOL } = require('os');
  const lines = i.split(EOL);
  const scores = [];
  for (let i = 1; i < lines.length - 1; i++) {
    scores.push(lines[i]);
  }
  let values = lines[lines.length - 1].split(' ');
  values = values.map(val => parseInt(val, 10));
  getMaxScore(scores, values);
});

function getMaxScore(scores, values) {
  const buckets = [];
  buckets.length = 5;
  buckets.fill(0);

  const mapping = {
    A: 0,
    B: 1,
    C: 2,
    D: 3,
    E: 4,
  };

  let score = 0;
  for (let i = 0; i < scores[0].length; i++) {
    for (let j = 0; j < scores.length; j++) {
      const answer = scores[j][i];
      buckets[mapping[answer]]++;
    }
    const max = Math.max(...buckets);
    score += (max * values[i]);
    buckets.fill(0);
  }
  console.log(score);
}


//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n');
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr('time : ' + end + 'ms');
  myerr('memory : ' + Math.round(process.memoryUsage().heapTotal / 1024) + 'KB');
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
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';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//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 output = new Array(t);
  for(var i = 0; i < t; i++){
    var N = nextInt();
    if(N == 2){
      output[i] = 2;
    }else{
      output[i] = N % 2;
    }
  }
  myout(myconv(output, 9));
}

const readline = require('readline');

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

let cases, arr = [], toBuy = [];

rl.on('line', n => {
  if (!cases) { cases = n } else {
    arr.push(n);
    cases--;
    if (cases === 0) {
      arr.map(Number).forEach(num => {
        num < 4 ? toBuy.push(4 - num) : num % 2 === 0 ? toBuy.push(0) : toBuy.push(1);
      });
      toBuy.forEach(num => console.log(num));
      rl.close();
    }
  }
});

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;
  }

  const n = +d;

  if (n === 2) {
    console.log(2);
  }
  else if (n % 2 === 0) {
    console.log(0);
  }
  else {
    console.log(1);
  }

  c++;
});

let fs=require('fs');
let txt=fs.readFileSync(0,"utf-8").split("\r\n").filter(data=>{return data.length>0});
txt.shift()

txt.forEach(data=>{
     matches(data*1);
})

function matches(num){
     let res=Math.ceil(num/2);
     let other=Math.floor(num/2);
     let add=0
     if(other<res){
          ++other;
          ++add;
     }
     let nums=[Math.ceil(other/2),Math.floor(other/2)];
     if(nums[1]<1){
         add+=2;
     }

     console.log(add);

}

let data = '';
process.stdin.on('data', c => data += c);
const sol = () => {
   let [k, ...nums] = data.trim().split('\n').map(v => Number(v));
   let ans = [];
   for(let n of nums){
   	ans.push((n < 3)?(4 - n):(n%2));
   }
   console.log(ans.join('\n'));
}
process.stdin.on('end', sol);

var s = '';
var n = 0;

process.stdin.on('data', function (c) {
    s += c;
});

process.stdin.on('end', function () {
    s = s.trim().split('\n');
    main();
});

function readline() {
    return s[n++];
}

function main() {
    var T = parseInt(readline());
    for (var t = 0; t < T; ++t) {
        var n = parseInt(readline());
        if (n === 2) {
            console.log(2);
        } else if (n % 2 == 1) {
            console.log(1);
        } else {
            console.log(0);
        }
    }
}

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

let t = Date.now();

let currentLine = 0;
let i = '';
process.stdin.on('data', c => {
  i += c;
});
process.stdin.on('end', () => {
  const { EOL } = require('os');
  i = i.trim()
    .split('\n')
    .map(string => {
      return string.trim();
    });
  main();
});

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

function main() {
  var x = readLine();
  let j = 0;
  for (j = 0; j < x; j++) {
    var cq = readLine();
    //console.log('current query' + cq);
    if (cq == 2) {
      console.log(2);
    } else {
      var rs = cq - Math.floor(cq / 2); //console.log('rs ' + rs);
      var ls = Math.floor(cq / 2); //console.log('ls ' + ls);
      if (ls === rs)
        console.log('0');
      else {
        console.log(rs - ls);
      }
    }
  }
}

(function() {
    var q = Number(readline());
    while (q--) {
        var n = parseInt(readline());
        if (n == 2)
            print(2);
        else
            print(n % 2);
    }
})();

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

const input = [];
readline.on('line', line => { input.push(line); });

readline.on('close', () => {
    const n = Number(input[0]);
    const queries = input.slice(1).map(Number);
    queries.forEach(v => {
        if (v === 1) console.log(3);
        else if (v === 2) console.log(2);
        else {
            if (v % 2 === 1) console.log(1);
            else console.log(0);
        }
    })
});

const readline = require("readline").createInterface(process.stdin, process.stdout);
var linesLeft,
    result = '';
readline.on("line", line => {
  if (linesLeft === undefined)
    linesLeft = parseInt(line);
  else{
    solution(line);
    if (!(--linesLeft > 0))
    readline.close();
  }
}).on("close",() => {
  console.log(result)
  process.exit(0);
});

function solution (input){
    result += (input > 2 ? input % 2 : 2) + '\n';
    return input % 2;
}

'use strict'

let n; readline();
while(n = parseInt(readline())) { write((n < 5 ? 4 - n : n % 2) + '\n'); }

'use strict';

main();

function main() {
  let cases = parseInt(readline());
  while ( cases-- > 0 ) {
    print(solve());
  }
}

function solve() {
  let matches = parseInt(readline());
  matches -= 4; // 1 + 1 = 2, basic equation

  return ( ( matches < 0 ) ? -1 * matches : matches % 2 );
}

var q = parseInt(readline());
var input = []
while (q != 0) {
    q--;
    input.push(parseInt(readline()));
}
input
    .map(n => n == 2 ? 2 : n % 2)
    .forEach(z => print(z))

var q = parseInt(readline())
var mass = []
mass.length = q
for (var i = 0; i < q; i++) mass[i] = parseInt(readline())
for (var i = 0; i < q; i++) {
    var n = mass[i]
    if (n == 2) print(2)
    else if (n % 2 == 0)
        print(0)
    else print(1)
}

n = +readline();
var q;
for (var i = 0; i < n;i ++){
    q = +readline();
    if (q === 1) { print(2)}
    else if (q === 2) { print(2)}
    else {
        if (q % 2 === 0){
            print(0);
        }
        else { print(1)}
    }
}

var q = readline();
var n;
for (var i = 0; i<q; i++) {
    n = readline();
    if (n%2 == 1) n = 1;
    else if (n == 2) n = 2;
    else n = 0;
    print(n);
};

'use strict'

let n; readline();
while(n = parseInt(readline())) { write(n < 5 ? 4 - n : n % 2); }

'use strict'

let n; readline();
while(n = parseInt(readline())) { write(n < 5 ? 4 - n : n % 2 + '\n'); }

var q = parseInt(readline());
var input = []
while (q != 0) {
    q--;
    input.push(parseInt(readline()));
}
input
    .map(num => (num % 2) + (num < 4 ? (4 - num) : 0))
    .forEach(z => print(z))

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

let t = Date.now();

let currentLine = 0;
let i = '';
process.stdin.on('data', c => {
  i += c;
});
process.stdin.on('end', () => {
  const { EOL } = require('os');
  i = i.trim()
    .split('\n')
    .map(string => {
      return string.trim();
    });
  main();
});

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

function main() {
  var x = readLine();
  console.log(x);
  let j = 0;
  for (j = 0; j < x; j++) {
    var cq = readLine();
    //console.log('current query' + cq);
    if (cq == 2) {
      console.log(2);
    } else {
      var rs = cq - Math.floor(cq / 2); //console.log('rs ' + rs);
      var ls = Math.floor(cq / 2); //console.log('ls ' + ls);
      if (ls === rs)
        console.log('0');
      else {
        console.log(rs - ls);
      }
    }
  }
}

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

const input = [];
readline.on('line', line => { input.push(line); });

readline.on('close', () => {
    const n = Number(input[0]);
    const queries = input.slice(1).map(Number);
    console.log(queries);
    queries.forEach(v => {
        if (v === 1) console.log(3);
        else if (v === 2) console.log(2);
        else {
            if (v % 2 === 1) console.log(1);
            else console.log(0);
        }
    })
});

let data = '';
process.stdin.on('data', c => data += c);
const sol = () => {
   let nums = data.split('\n').map(v => Number(v));
   nums.shift();
   let ans = [];
   for(let n of nums){
   	ans.push((n < 3)?(4 - n):(n%2));
   }
   console.log(ans.join('\n'));
}
process.stdin.on('end', sol);

let data = '';
process.stdin.on('data', c => data += c);
const sol = () => {
   let [k, ...nums] = data.split('\n').map(v => Number(v));
   let ans = [];
   for(let n of nums){
   	ans.push((n < 3)?(4 - n):(n%2));
   }
   console.log(ans.join('\n'));
}
process.stdin.on('end', sol);

let data = '';
process.stdin.on('data', c => data += c);
const sol = () => {
   let nums = data.split('\n').map(v => parseInt(v,10));
   nums.shift();
   let ans = [];
   for(let n of nums){
   	ans.push((n < 3)?(4 - n):(n%2));
   }
   console.log(ans.join('\n'));
}
process.stdin.on('end', sol);


const main = (input) => {
  input = input.split('\n')

  const t = Number(input[0])
  for (let i = 0; i < t; i++) {
    const n = parseInt(input[1 + i * 2])
    const a = input[1 + i * 2 + 1].split(' ').map((x) => parseInt(x))

    const ans =
      a.reduce((prev, current) => prev + current, 0) - Math.min(...a) * n
    console.log(ans)
  }
}

main(require('fs').readFileSync(0).toString())

let i = '';//.map(Number).sort(function(a, b){return a - b})
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0], e= 0, g = 0
    for(j = 1; j <= n * 2; j++){
        if(j % 2 == 1){
            e = lines[j], g= 0
        }else{
            var k = lines[j].split(' ').map(Number).sort(function(a, b){return a - b}), a = k[0]
            for(l = 1; l < e; l++){
                g += k[l] - a
            }
            console.log(g)
        }
    }

});//k[k.length - 1] == '' ||

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0];
    var e = 0;
    for(j = 1; j <= n * 2; j++){
        if(j % 2 == 1){
            e = lines[j];
        }else{
            var k = lines[j].split(' ').map(Number).sort(function(a, b){return a - b});
            var ans = 0;
            var a = k[0];
            for(i = 1; i < e; i++){
                ans += k[i] - a;
            }
            console.log(ans);
        }
    }
});

/*
File Created: Tuesday, 17 May 2022
Author: Lukas Rimkus
*/
'use strict';

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

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--) {
        const n = parseInt(readLine());
        const arr = get_ints();
        console.log(solve([n,arr]));
    }
});
function get_ints() {
    return data[currentLine++].split(' ').map(Number);
}

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

function solve(input){
    let candies = 0;
    const min = Math.min(...input[1]);
    for (let index = 0; index < input[1].length; index++) {
        candies+= input[1][index] - min;
    }
    return candies;
}

module.exports = solve;

const { createInterface } = require('readline');
/*
const { createWriteStream, createReadStream } = require('fs');
const { format } = require('util');
const log_file = createWriteStream('output.txt', { flags: 'w' }
);
const log_stdout = process.stdout;
console.log = function (d) {
  log_file.write(format(d) + '\n');
  log_stdout.write(format(d) + '\n');
};
const fileStream = createReadStream('input.txt');
*/
function main() {
  const readline = createInterface({
    input: process.stdin,
    output: process.stdout
  });
  let lineNb = 0;
  let n;
  let t = [];
  let currentLength = -1;
  readline.on('line', line => {
    if (!lineNb)
      n = parseInt(line) * 2;
    else if (!(lineNb % 2)) {
      let sum = 0;
      let array = line.split(" ");
      let min = parseInt(array[0])
      t = (line.split(" ").map(i => {
        let currentNumber = Number(i);
        sum += currentNumber
        if (min > currentNumber) min = currentNumber
        return Number(i);
      }));
      console.log(sum - min * currentLength)
    } else {
      currentLength = parseInt(line)
    }
    if (lineNb === n)
      readline.close();
    lineNb++;
  });

}

main()

const { createInterface } = require('readline');
/*
const { createWriteStream, createReadStream } = require('fs');
const { format } = require('util');
const log_file = createWriteStream('output.txt', { flags: 'w' }
);
const log_stdout = process.stdout;
console.log = function (d) {
  log_file.write(format(d) + '\n');
  log_stdout.write(format(d) + '\n');
};
const fileStream = createReadStream('input.txt');
*/
function main() {
  const readline = createInterface({
    input: process.stdin,
    output: process.stdout
  });
  let lineNb = 0;
  let n;
  let t = [];
  let currentLength = -1;
  readline.on('line', line => {
    if (!lineNb)
      n = parseInt(line) * 2;
    else if (!(lineNb % 2)) {
      let sum = 0;
      t = (line.split(" ").map(i => {
        var currentNumber = Number(i);
        sum += currentNumber
        return Number(i);
      }));
      const min = Math.min(...t);
      console.log(sum - min * currentLength)
    } else {
      currentLength = parseInt(line)
    }
    if (lineNb === n)
      readline.close();
    lineNb++;
  });

}

main()

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
	var t = lines[0];
    var e = 0;
    for(i = 1; i <= t * 2; i++){
        if(i % 2 == 1){
            e = lines[i];
        }else{
            var k = lines[i].split(' ').map(Number).sort(function(a, b){return a - b});
            var a = k[0];
            var ans = 0;
            for(j = 1; j < e; j++){
                ans += k[j] - a;
            }
            console.log(ans);
        }
    }
});

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(j = 1; j <= n * 2; j++){
        if(j % 2 == 1){
            e = lines[j];
        }else{
            var k = lines[j].split(' ').map(Number).sort(function(a, b){return a - b});
            var ans = 0;
            var a = k[0];
            for(i = 1; i < e; i++){
                ans += k[i] - a;
            }
            console.log(ans);
        }
    }
});

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 !== 0) {
    c++;
    return;
  }

  const arr = d
    .split(" ")
    .map(Number)
    .sort((a, b) => a - b);
  const min = arr[0];
  let ans = 0;

  for (let i = 1; i < arr.length; i++) {
    if (min < arr[i]) {
      ans += arr[i] - min;
    }
  }

  console.log(ans);

  c++;
});

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

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

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

function output(x) {
    if (typeof x !== 'string') {
        x = x.toString();
    }
    //process.stdout.write(x);   // without auto '\n' (newline)
    console.log(x);  // with auto '\n' (newline)
}

function main() {
    let N = readline();

    for (let test = 0; test < N; test++) {
        let n = parseInt(readline(), 10);
        let arr = readline().split(' ').map(Number);

        let min = Math.min(...arr);

        let sum = 0;
        for (let i = 0; i < n; i++) {
            sum += arr[i] - min;
        }

        output(sum);
    }
}

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

let lines = [];
rl.on('line', (line) => {
    lines.push(line);
}).on('close', () => {
    // input in lines
    solve();
});

let line = 0;
const readline = () => lines[line++];
solve = () => {
    const t = parseInt(readline());
    for (let i = 0; i < t; i++) {
        var n = parseInt(readline());
        var a = readline().split(" ").map(Number).sort(function(a, b) {
            return a - b;
          });
        var sum = 0;
        var min = a[0];
            for (let j = 0; j < n; j++) {

                if (a[j] === min) {
                    sum = 0 + sum;
                } else {
                    sum = sum + a[j] - min;
                }
            }

        console.log(sum)
    }
}

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 = () => {
	//your code this
	let t = nl.num();
	let ans = [];
	for(let i = 0; i < t; i++){
		let n = nl.num();
		let a = nl.nums();
		let s = a.reduce((x, ac) => ac + x, 0);
		let m = a.reduce((x, ac) => x < ac?x:ac, a[0]);
		ans.push(s - m*n);
	}
	console.log(ans.join('\n'));
};

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

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

    function foo (data) {
        const numberData = data.split(' ').map(Number);
        const min = Math.min(...numberData);

        return numberData.reduce((acc, value) => {
          const diff = value - min;
          return acc + diff;
        }, 0);
    }

    let testCount = 1;
    const rowsInTest = 2;
    let answer = '';
    while(testCount <= +lines[0]) {
        let data = lines[testCount * rowsInTest];
        let result = foo(data);
        answer += result +"\n";
        testCount += 1;
    }
    console.log(answer);
})

const solve = (arr,n) => {
     let min = Infinity,cnt = 0;
     for(let i=0;i<n;i++) if(arr[i]<min) min=arr[i];
     for(let i=0;i<n;i++){
          cnt+=arr[i]-min;
     }
     console.log(cnt);
};
function main() {
  const fs = require("fs");
  const input = fs.readFileSync(0, "utf8").trim().split("\n");
  let line = 0;
  function readline() {
    return input[line++];
  }
  let n = parseInt(readline());
  for(let i=0;i<n;i++){
       let l = parseInt(readline());
       let arr = readline().trim().split(" ").map(cur=>parseInt(cur));
       solve(arr,l);
  }
}
main();

'use strict';

var readline = require('readline');

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

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

function solve(n, a) {
  let min = Math.min(...a);
  let res = 0;
  for (let num of a) {
    res += num - min;
  }
  return res;
}

async function main(read) {
  let t = Number(await read());
  let res = [];
  while (t--) {
    const n = Number(await read());
    const a = (await read()).split(' ').map(Number);
    res.push(solve(n, a));
  }
  console.log(res.join('\n'));
}

const rl = readline__default["default"].createInterface({
  input: process.stdin,
  output: process.stdout
});
void async function () {
  const inputs = [];
  let i = 0;
  for await (const line of rl) {
    inputs.push(line.trim());
  }
  function read() {
    return inputs[i++];
  }
  await main(read);
}();

let readline = require("readline");
let rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false,
});
const findMinimum = (array) => {
  let result = array[0];
  for (let index = 0; index < array.length; index++) {
    const element = array[index];
    if (result > element) {
      result = element;
    }
  }

  return result;
};

let lines = 0;

rl.on("line", function (line) {
  if (lines !== 0 && lines % 2 === 0) {
    let input = line.split(" ").map(Number);
    const minimum = findMinimum(input);
    console.log(input.reduce((sum, candies) => sum + candies - minimum, 0));
  }
  lines++;
});

'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 input() {
  return inputString[currentLine++];
}

function main() {
  let tc = parseInt(input());
  while(tc--){
    let n = parseInt(input());
    const a = input().split(' ').map(Number);
    let min_a = 1e7;
    for(let i of a) min_a = Math.min(min_a, i);
    let ans = 0;
    for(let i of a) if(i > min_a) ans += i-min_a;
    console.log(ans);
  }
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});
function readLine() {
    return inputString[currentLine++];
};
process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    main();
    // cmd(not powershell): node cp.js < input.txt
});

function main() {
    let t = parseInt(readLine());
    while (t-- > 0) {
        console.log(solve());
    }
}
function solve() {
    readLine();
    let arr = readLine().split(" ").map(i => parseInt(i));
    let min = Number.MAX_VALUE;
    for (let i = 0; i < arr.length; i++) {
        min = Math.min(min, arr[i]);
    }
    let eat = 0;
    for (let i = 0; i < arr.length; i++) {
        eat += arr[i] !== min ? arr[i] - min : 0;
    }
    return eat;
}

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;
}
var T = readline();
for(var q=1;q<=T;q++) {
  var n = readline();
  var a = readline().split(' ').map((x)=>parseInt(x));
  var ans = 0;
  var mn = 100000001;
  var sum = 0;
  for(var i=0;i<n;i++) {
    sum += a[i];
    mn = min(mn, a[i]);
  }
  ans = sum-(n*mn);
  console.log(ans);
  //fs.appendFileSync('output.txt', ans+' '+mn+'\r\n');

  //os.EOL
}
//fs.writeFileSync('output.txt', f.join(' '));

//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;}}

function Main(){
    // test case in nodeJs
	var t = nextInt();
	while(hasNext()){
		solve();
	}
}

function solve() {
	const num = nextInt();
    const arr = nextIntArray(num);

    let min = Math.min(...arr);
    let sum = 0;
    for (const value of arr) {
        sum += value - min
    }
    myout(sum);
}

'use strict';
// HEADER:
const print = console.log;
let IS_MULTITEST, testN;
const pcalc = testN=>{
  let res = calc(testN);
  if (Array.isArray(res)){
    pa(res);
  } else if (Number.isFinite(res) || typeof res=='string'){
    print(res);
  }
};

const main = ()=>{
  if (IS_MULTITEST){
    let T = +readline()
    for (testN=1; testN<=T; testN++)
      pcalc(T);
  } else
   pcalc();
};

const lines = [];
const rl = require('readline').createInterface({
   input: process.stdin, output: process.stdout});
rl.on('line', line=>{
  lines.push(line);
});
rl.on('close', main);
let rli = 0;
const readline = ()=>lines[rli++];
const L = process.env.DEBUG ? console.log : ()=>{};
const LT = obj=>L(`Test #${testN}`, obj);

const ra = ()=>readline().split(' ').map(a=>+a)
const pa = arr=>print(arr.join(' '));

// SOLUTION:
IS_MULTITEST = 1;

const calc = ()=>{
  // READING:
  let [n] = ra();
  let A = ra();
  LT({n, A});
  // PROCESSING:
  let min = Math.min.apply(null, A);
  let ans = 0;
  for (let a of A)
    ans += a-min;
  return ans;
};

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 n = +lines[l++]
        const arr = lines[l++].trim().split(' ').map(Number)
        output[i] = solve(n, arr)
    }
    console.log(output.join('\n'))
// })()
})

function solve(n, arr) {
    let min = arr[0]
    for (let i = 0; i < arr.length; i++) {
        min = Math.min(min, arr[i])
    }
    let ans = 0
    for (let i = 0; i < arr.length; i++) {
        ans += arr[i] - min
    }
    return ans
}

//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();
	while(hasNext()){
		var N = nextInt();
		var list = nextIntArray(N);
		var min = 100000000;
		for(var i = 0; i < N; i++){
			min = Math.min(min, list[i]);
		}
		var output = 0;
		for(var i = 0; i < N; i++){
			output += list[i] - min;
		}
		myout(output);
	}
}

var testCase = +readline(),counter
for(var i=0;i<testCase;i++){
    var a=+readline(),b=[],counter=0
    var sequence=readline().split(" ").map(node=>+node)
    var minValue=sequence.reduce((a,b)=>Math.min(a,b))
    for(var j=0;j<sequence.length;j++){
        if((minValue!==sequence[j])){
            counter=counter+(Math.abs(sequence[j]-minValue))
        }
    }
    print(counter)
}

var limit = parseInt(readline());
    for (var i = 0; i < limit; i++) {
        var caseLength = parseInt(readline());
        var caseArray = readline().split(" ");
        var caseIntArray = new Array();
        for (var _i = 0, caseArray_1 = caseArray; _i < caseArray_1.length; _i++) {
            var element = caseArray_1[_i];
            caseIntArray.push(parseInt(element));
        }
        var sortedCaseIntArray = caseIntArray.sort(function (a, b) { return a - b; });
        var totalCandies = 0;
        for (var j = 1; j < caseLength; j++) {
            totalCandies += sortedCaseIntArray[j] - sortedCaseIntArray[0];
        }
        print(totalCandies);
    }

const readStr = () => readline();
const readStrArr = () => readline().split(' ');

const n = readStr();
for(var i = 0; i < n; i++) {
  var k = readStr();
  var a = readStrArr();
  if(k === '1'){
    print(0);
    continue;
  }
  var min = Math.min(...a), sum = 0;
  for(var j = 0; j < k; j++) {
    sum += a[j] - min;
  }
  print(sum);
}

var t = parseInt(readline());

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

    var sum = parseInt(arr[0]);
    var min = parseInt(arr[0]);

    for (var i = 1; i < n; i++) {
        sum += parseInt(arr[i]);
        min = Math.min(min, parseInt(arr[i]));
    }

    print(sum - min * n);
}

var t = readline();
for(var i = 0 ; i < t ;i++){
    var n = readline();
    var a = readline().split(' ');
    a.sort( (a,b) => {return a-b});
    var min = a[0] , counter = 0;
    for(var  j = 0 ; j < n ; j++){
        counter+= (a[j] - a[0]);
    }
        print(counter);
}

var n = +readline()

for(var i=0;i<n;++i){
    var q = +readline();
    var arr = readline().split(" ")
    var min = 10000000;
    var max = 0;

    for(var j=0;j<arr.length;++j){
        if(+arr[j] < min){
            min = +arr[j]
        }else if(+arr[j] > max){
            max =+arr[j];
        }
    }

    if(min === max){
        print(0);
    }else{
        var op = 0;
        for(var j=0;j<arr.length;++j){
            if(+arr[j] > min){
                op += +arr[j] - min;
            }
        }
        print(op)
    }
}

T = readline()
while (T--) {
   n = +readline()
   a = readline().split(' ').map(a => +a)
   a.sort((prev, next) => prev - next)

   ans = 0
   for(i=1; i< n; i++){
      ans += a[i] - a[0]
   }
   print(ans)
}

t = parseInt(readline());
for(i = 0; i < t; i++)
{
    var n = readline();
    n = readline().split(" ");
    var min = 10000001;
    var sum = 0;
    for(j = 0; j < n.length; j++)
    {
        sum += parseInt(n[j]);
        if(parseInt(n[j]) < min) min = n[j];
    }
    print(sum - min*n.length);
}

var n = readline()

for(var i=0 ; i<n ; i++){
    var box = readline()
    var arr = readline().split(' ').map(function(x) { return parseInt(x); });
    var m = Math.min(...arr);
  //  print(m)
    var total = 0;
   for(var j=0 ; j<box ; j++){
       if(arr[j] == m)continue;
       else{
            total += (arr[j]-m);
       }
   }
   print(total);
}

var t = +readline();

for(var i = 0; i< t; i ++) {
    var a = readline();
    var b = readline().split(' ').map((t) => +t);

    print(Task2(b));
}

function Task2 (arr){

  var min = Math.min(...arr);
  var count = 0;
  for(var i = 0; i<arr.length; i++){
    count += arr[i] - min;
  }
  return count;

}

//import { readline, print } from '@ip-algorithmics/codeforces-io';
var t = +readline();
while (t--) {
    readline();
    var a = readline().split(' ').map(function (v) { return +v; });
    print(a.reduce(function (a, b) { return a + b; }) - a.length * Math.min.apply(Math, a));
}

let i = '';//.map(Number).sort(function(a, b){return a - b})
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0], e= 0, g = 0
    for(j = 1; j <= n; j++){
        if(j % 2 == 1){
            e = lines[j], g= 0
        }else{
            var k = lines[j].split(' ').map(Number).sort(function(a, b){return a - b}), a = k[0]
            for(l = 1; l < e; l++){
                g += k[l] - a
            }
            console.log(g)
        }
    }

});//k[k.length - 1] == '' ||

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

function main() {
    let tc = parseInt(input());
    while(tc--){
         const n = input().split('').map(Number);
         const a = input().split('').map(Number);
         console.log(solve([n,a]))
    }
}

function solve(input){
    let candies = 0;
    const min = Math.min(...input[1]);
    for (let index = 0; index < input[1].length; index++) {
        candies+= input[1][index] - min;
    }
    console.log(candies)
    return candies;
}

module.exports = solve;

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

function main() {
    let tc = parseInt(input());
    while(tc--){
         const n = input().split('').map(Number);
         const a = input().split('').map(Number);
         ans = solve([n,a]);
         console.log(ans)
    }
}

function solve(input){
    let candies = 0;
    const min = Math.min(...input[1]);
    for (let index = 0; index < input[1].length; index++) {
        candies+= input[1][index] - min;
    }
    return candies;
}

module.exports = solve;

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

function main() {
    let tc = parseInt(input());
    while(tc--){
         const n = input().split('').map(Number);
         const a = input().split('').map(Number);
         console.log(solve([n,a]))
    }
}

function solve(input){
    let candies = 0;
    const min = Math.min(...input[1]);
    for (let index = 0; index < input[1].length; index++) {
        candies+= input[1][index] - min;
    }
    return candies;
}

module.exports = solve;

var testCase = readline().split(""),counter
for(var i=0;i<testCase;i++){
    var a=+readline(),b=[],counter=0
    var sequence=readline().split(" ").map(node=>+node)
    var minValue=sequence.reduce((a,b)=>Math.min(a,b))
    for(var j=0;j<sequence.length;j++){
        if((minValue!==sequence[j])){
            counter=counter+(Math.abs(sequence[j]-minValue))
        }
    }
    print(counter)
}


function solve() {
   var T = Number(read());
   for (var t = 0; t < T; t++) {
      var n = Number(read());
      var a = read().split(' ').map(Number);
      var sum = a[0];
      var x = 0;
      var y = 0;
      var ans = 0;
      for (var i = 1; i < n; i += 2) {
         x += (a[i] - a[i - 1]);
         if (x > ans) {
            ans = x;
         }
         if (x < 0) {
            x = 0;
         }
         if (i + 1 < n) {
            sum += a[i + 1];
            y += (a[i] - a[i + 1]);
            if (y > ans) {
               ans = y;
            }
            if (y < 0) {
               y = 0;
            }
         }
      }
      write(ans + sum);
   }
}

var isNode = typeof console !== 'undefined';
var MEMORY = [];
var MEMORY_INDEX = 0;
if (isNode) {
   var fs = require('fs');
   var path = require('path');

   var inTextName;
   var outTextName;
   if (process.argv.length === 5) {
      inTextName = process.argv[3];
      outTextName = process.argv[4];
   }

   if (inTextName) {
      fs.readFile(path.join(__dirname, inTextName), 'utf8', (err, data) => {
         MEMORY = data.split('\r\n');
         solve();
      });
   } else {
      var RL = require('readline').createInterface({
         input : process.stdin,
         output : process.stdout
      });

      RL.on('line', (line) => {
         MEMORY.push(line);
      });

      RL.on('close', solve);
   }
} else {
   solve();
}

function write(value) {
   isNode ? console.log(value) : print(value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}

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')

    main();
});

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

const s2i = s => parseInt(s, 10)

function main() {
  let T = s2i(readLine())
  let out = ''
  while (T--) {
    const n = s2i(readLine())
    const arr = readLine().split(' ').map(s2i)

    let sumEven = arr[0]
    let sum01 = 0
    let sum12 = 0
    let max = 0
    for (let i = 1, even = false, curr = sumEven; i < n; i++, even = !even) {
      const prev = curr
      curr = arr[i]
      if (even) {
        sumEven += curr
        sum01 += prev - curr
        if (sum01 < 0) {
          sum01 = 0
        } else {
          max = Math.max(max, sum01)
        }
      } else {
        sum12 += curr - prev
        if (sum12 < 0) {
          sum12 = 0
        } else {
          max = Math.max(max, sum12)
        }
      }
    }

    out += (sumEven + max) + '\n'
  }
  console.log(out)
}

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();
    });

    D();
});

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 C(){
    let [n,m] = ti(readline().split(' '));
    let a = ti(readline().split(' '));
    let b = ti(readline().split(' '));
    let o = new Array(10);
    let z = new Array(10);
    o.fill(0);
    z.fill(0);
    for(let i = 0; i < m; i++){
        let t = 1;
        for(let j = 0; j < 10; j++){
            if(b[i] & t !== 0)
                o[j] = 1;
            else
                z[j] = 1;

            t << 1;
        }
    }

    let c = new Array(10);
    for(let i = 0; i < n; i++){
        let t = 1;
        for(let j = 0; j < 10; j++){
            if(a[i] & t !== 0){
                if(z[j] === 1)
                    c[j] = 0;
                else
                    c[j] = 1;
            }
            t << 1;
        }
    }

    let res = 0;
    for(let i = 9; i >= 0; i--){
        res += pi(c[i])*Math.pow(2,9-i);
    }
    console.log(res);
}

function B(){
    let t = pi(readline());
    while(t){
        t--;
        let [n,k,z] = ti(readline().split(' '));
        let a = ti(readline().split(' '));

        // pre -> 0,1 -> right,left
        let dp = new Array(z+1);
        for(let i = 0; i < z+1; i++){
            dp[i] = new Array(n);
            dp[i].fill(-1);
        }

        let solve = (i,j,index,pre) => {
            if(index < 0 || index >= n)
                return 0;
            if(i > k)
                return 0;
            if(dp[j][index] !== -1)
                return dp[j][index];
            if(pre){
                return dp[j][index] = a[index] + solve(i+1, j, index+1, 0);
            }else{
                return dp[j][index] = a[index] + Math.max(j < z ? solve(i+1,j+1,index-1,1) : 0, solve(i+1,j,index+1,0));
            }
        }

        console.log(solve(0,0,0,1));
    }
}

function E1(){
    let [n,k] = ti(readline().split(' '));
    let t = new Array(n);
    for(let i = 0; i < n; i++){
        t[i] = ti(readline().split(' '));
    }
    let ab = [];
    let a = [];
    let b = [];
    let unlikeCount = 0;

    for(let i = 0; i < n; i++){
        if(t[i][1] === 1 && t[i][2] === 1){
            ab.push(t[i]);
        }else if(t[i][1] === 1){
            a.push(t[i]);
        }else if(t[i][2] === 1){
            b.push(t[i]);
        }else{
            unlikeCount += 1;
        }
    }

    ab.sort((x,y) => x[0]-y[0]);
    a.sort((x,y) => x[0]-y[0]);
    b.sort((x,y) => x[0]-y[0]);
    // let max = Math.max(max, ab.length, a.length, b.length);
    // let min = Math.min(min, ab.length, a.length, b.length);
    // let inf = 9999999999;
    // for(let i = min+1; i <= max; i++){
    //     if(i >= ab.length) ab.push(inf);
    //     if(i >= a.length) a.push(inf);
    //     if(i >= b.length) b.push(inf);
    // }

    let p1 = p2 = p3 = 0;
    let ka = k;
    let kb = k;
    let res = 0;
    while(p1 < ab.length || p2 < a.length || p3 < b.length){
        if(ka === 0 && kb === 0)
            break;
        if(p2 < a.length && p3 < b.length){
            if(p1 < ab.length){
                if(a[p2][0]+b[p3][0] > ab[p1][0]){
                    res += ab[p1][0];
                    p1++;
                }else{
                    res += a[p2][0]+b[p3][0];
                    p2++;
                    p3++;
                }
            }else{
                res += a[p2][0]+b[p3][0];
                p2++;
                p3++;
            }
            ka--;
            kb--;
        }else{
            if(p1 >= ab.length){
                console.log(-1);
                return;
            }
            res += ab[p1][0];
            ka--;
            kb--;
            p1++;
        }
    }
    if(ka !== 0 || kb !== 0){
        console.log(-1);
        return;
    }
    console.log(res);
}

function D(){
    let t = pi(readline());
    while(t){
        t--;
        let n = pi(readline());
        let a = ti(readline().split(' '));
        let sum1 = new Array(n);
        let sum2 = new Array(n);
        sum1[0] = -1*a[0];
        sum2[0] = a[0];
        for(let i = 1; i < n; i++){
            if(i%2 === 0){
                sum1[i] = sum1[i-1] - a[i];
            }else{
                sum1[i] = sum1[i-1] + a[i];
            }
        }

        let min = 99999999999;
        let [l,r] = [-1,-1];
        let max = 0;
        let minIndex = 0;
        for(let i = 0; i < n; i+=2){
            if(min > sum1[i]){
                min = sum1[i];
                minIndex = i;
            }

            if(max < sum1[i]-min){
                max = sum1[i]-min;
                [l,r] = [minIndex+1,i];
            }
        }

        min = 0;
        minIndex = -1;
        for(let i = 1; i < n; i+=2){
            if(min > sum1[i]){
                min = sum1[i];
                minIndex = i;
            }

            if(max < sum1[i]-min){
                max = sum1[i]-min;
                [l,r] = [minIndex+1,i];
            }
        }

        let res = 0;
        for(let i = 0; i < n; i++){
            if(i < l || i > r){
                if(i%2 === 0)
                    res += a[i];
            }
            else{
                if(i%2 !== 0)
                    res += a[i];
            }
        }

        console.log(res);
    }
}


function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i]);
	};
	return tokens;
}

function main() {
	var digitNum = parseInt(readline());
	var s = trim(readline());

	var pos = (digitNum%2 == 0 ? 2 : 3);
	write(s.substring(0, pos));

	while (pos < digitNum) {
		write("-"+s.substring(pos, pos+2));
		pos += 2;
	}
	print();
}

main();

var size = readline(), number = readline(), ans = []
var go = number.length, index = 0
while (go){
	var nxt = (go%2) ? 3 : 2
	ans.push(number.slice(index,index+nxt))
	index+= nxt; go-=nxt
}
print(ans.join("-"))

'use strict'

let N = +readline()
let L = readline()

let res = []

for (let i = 0; i <= N; i = i + 2) {
  res.push(L.slice(i, i + 2))
}

res = res.filter(Boolean)

if (N % 2) {
  res[res.length - 2] += res[res.length - 1]
  res.length--
}

print(res.filter(Boolean).join('-'))

var n=readline(); n=parseInt(n);
var arr=readline();
var three=0,two=0;
for(var i=0;i<=100;i++)
{
    for(var j=0;j<=100;j++)
    {
        var temp=n-i*2-j*3;
        if(temp==0)
        {
            three=j; two=i;
        }
    }
}
var num=0; var ans="";
for(var i=0;i<three;i++){for(var j=0;j<3;j++)write(arr[num++]); if(n!=num)write('-');}
for(var i=0;i<two;i++){for(var j=0;j<2;j++)write(arr[num++]); if(n!=num)write('-');}

var n = readline();
n = parseInt(n);

var tel = readline();

var output = '' ;

if (tel.length%2 == 0){
	output += tel[0] + tel[1];
	for(var i=2; i<tel.length; i = i + 2){
		output += '-' + tel[i] + tel[i+1];
	}
} else {
	output += tel[0] + tel[1] + tel[2];
	for(var i=3; i<tel.length; i = i + 2){
		output += '-' + tel[i] + tel[i+1];
	}
}
print(output);

'use strict'

let N = +readline()
let L = readline()

let res = []

for (let i = 0; i <= N / 2 + 3; i = i + 2) {
  res.push(L.slice(i, i + 2))
}

res = res.filter(Boolean)

if (N % 2) {
  res[res.length - 2] += res[res.length - 1]
  res.length--
}

print(res.filter(Boolean).join('-'))

'use strict'

let N = +readline()
let L = readline()

let res = []

for (let i = 0; i <= N / 2 + 3; i = i + 2) {
  res.push(L.slice(i, i + 2))
}

if (N % 2) {
  res[res.length - 2] += res[res.length - 1]
  res.length--
}

print(res.filter(Boolean).join('-'))

'use strict'

let N = +readline()
let L = readline()

let res = []

for (let i = 0; i <= N / 2 + 4; i = i + 2) {
  res.push(L.slice(i, i + 2))
}

res = res.filter(Boolean)

if (N % 2) {
  res[res.length - 2] += res[res.length - 1]
  res.length--
}

print(res.filter(Boolean).join('-'))


var N = parseInt(readline());
var ans = [];
for (var i = N; i--; ) {
  ans.push(Math.max.apply(this, readline().split(' ')));
}
print(ans.join(' ').replace(` ${N-1}`, ` ${N}`));

var permutationLength = readline();
var permutation = [];
var object = {};
var biggestIntegerUsed = false;

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

    var rowOfMatrix = readline().split(" ");
    object = {};

    for (var j = 0; j < permutationLength; j++) {
        if (object[rowOfMatrix[j]]) {
            permutation[i] = rowOfMatrix[j];
            break;
        } else {
            object[rowOfMatrix[j]] = true;
        }
    }

    if (!permutation[i]) {
        permutation[i] = biggestIntegerUsed ? permutationLength - 1 : permutationLength;
        biggestIntegerUsed = true;
    }
}

print(permutation.join(" "));

var N = parseInt(readline());
var q = [], max;
var updateMax = (num) => {if (num > max) max = num;}
for (var i = N; i--; ) {
  max = -Infinity;
  readline().split(' ').forEach(updateMax);
  q.push(max);
}
print(q.join(' ').replace(N-1, N));

var N = parseInt(readline());
var q = [], ans = [];
for (var i = N; i--; ) {
  q.push(' '+readline().replace(/0/g, ''));
}
for (var i = 1, flag; i < N; ++i) {
  flag = false;
  for (var j = 0; j < N; ++j) {
    q[j] = q[j].replace(new RegExp(` ${i}`, 'g'), '');
    if (q[j] === ' ' && !ans[j] && !flag) {
      ans[j] = i;
      flag = true;
    }
  }
}
for (var i = 0; i < N; ++i) {
  if (typeof ans[i] === 'undefined') {
    ans[i] = N;
  }
}
print(ans.join(' '));


var cnt = new Array(4).fill(0);
cnt[0] =  Number.MAX_SAFE_INTEGER;
readline();
readline().split(" ").map((x)=>{ cnt[x]++; });
var out = 0;
var min = Math.min(...cnt);
out += min;
cnt.splice(cnt.indexOf(min),1);
out += Math.min(...cnt);
print(out);

'use strict'

let N = +readline()
let lll = readline().split(' ').map(v => parseInt(v))

let c = [0, 0, 0]
for (let i = 0; i < N; i++) {
  c[lll[i] - 1]++
}
print(c[0] + c[1] + c[2] - Math.max(c[0], c[1], c[2]))

var getNums = function() {
	return readline().split(' ').map(function(a) {return parseInt(a)});
};

var n = parseInt(readline());
var input = getNums();
var hash = {};

for(var j = 1; j <= 3; j++) {
	hash[j] = 0;
}

for (var i = 0; i < n; i++) {
	hash[input[i]]++;
}

print(Math.min(hash[1] + hash[2], hash[1] + hash[3], hash[3] + hash[2]));

const readline = require('readline');

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
let indicator = 0, N;
rl.on('line', (input) => {
    if (indicator == 0){
        N = parseInt(input);
        indicator++;
    }
    else {
        let cont = input.split(' ').map(item => parseInt(item))
        let dict = {};
        let maxval = 0;
        cont.forEach(item => {
            if (item in dict)
                dict[item]++;
            else
                dict[item] = 1;

            if (maxval < dict[item])
                maxval = dict[item];

        });
        console.log(N - maxval);
        rl.close();
    }
});

var cnt = new Array(4).fill(0);
readline();
readline().split(" ").map((x)=>{ cnt[x]++; });
var max = Math.max(...cnt);
var out = 0;
cnt.map((x)=>{if(x!=max)out+=x;});
print(out);

var cnt = new Array(4).fill(0);
cnt.splice(cnt.indexOf(0),1);
readline();
readline().split(" ").map((x)=>{ cnt[x]++; });
var out = 0;
var min = Math.min(...cnt);
out += min;
cnt.splice(cnt.indexOf(min),1);
out += Math.min(...cnt);
print(out);

var cnt = new Array(4).fill(0);
readline();
readline().split(" ").map((x)=>{ cnt[x]++; });
var out = 0;
var min = Math.min(...cnt);
out += min;
cnt.splice(cnt.indexOf(min),1);
out += Math.min(...cnt);
print(out);

var getNums = function() {
	return readline().split(' ').map(function(a) {return parseInt(a)});
};

var n = parseInt(readline());
var input = getNums();
var hash = {};

for (var i = 0; i < n; i++) {
	var a = input[i];
	if (hash[a]) {
		hash[a]++;
	} else {
		hash[a] = 1;
	}
}

print(Math.min(hash[1] + hash[2], hash[1] + hash[3], hash[3] + hash[2]));