print(function(n, m) {

	var not = new Int8Array(n + 1);
	while (m--)
		rn().reduce(function(a, b){
			not[a]=1;
			not[b]=1;
		});
	var c = 0;
	for(var i=1; i<=n; i++)
		if(not[i]===0){
			c=i;
			break;
		}

	var ans = [n-1];
	for(var i=1; i<=n; i++)
		if(i!==c)
			ans.push(c+' '+i);

	return ans.join('\n');

} .apply(0, rn()));
function rn() {
	return readline().split(' ').map(Number);
}

function main(str) {
    var arr = str.split(' ');
    var num1 = +arr[0];
    var num2 = +arr[1];

    var myGraph;

    // конструктор графа
    var Graph = function (nodes) {
        this.nodesNumber = nodes;
        this.edgesNumber = 0;
        this.nodes = new Array(this.nodesNumber);
        var i = 0;

        for (i; i < nodes; i++) {
            this.nodes[i] = [];
        }

        this.connectNodes = function (v, w) {
            this.nodes[v].push(w);
            this.nodes[w].push(v);
            this.edgesNumber++;
        }

        this.showGraph = function () {
            var i = 0;
            var j = 0;
            write(this.edgesNumber + '\n');
            for (i; i < this.nodes.length; i++) {
                for (j; j < this.nodes[i].length; j++) {
                    var resStr = (i + 1) + ' ' + (this.nodes[i][j] + 1) + '\n';
                    write(resStr);
                }
            }
        }
    }

    function logic() {
        myGraph = new Graph(num1);
        var centralNode = 0;
        var nodesUnderCondition = new Set();
        var i = 0;
        var j = 0;
        var k = 0;
        for (j;j<num2;j++) {
            var str = readline();
            var arr = str.split(' ');
            var node1 = arr[0] - 1;
            var node2 = arr[1] - 1;
            nodesUnderCondition.add(node1);
            nodesUnderCondition.add(node2);
        }

        for (k;k<num1;k++) {
            if (!nodesUnderCondition.has(k)) {
                centralNode = k;
            }
        }

        for (i; i < num1; i++) {
            if (i !== centralNode) {
                myGraph.connectNodes(i, centralNode);
            }
        }

        myGraph.showGraph();
    }

    logic();
}

var data = readline();
main(data);

var input = readline().split(' ').map(Number), n = input[0], m = input[1];
var no = [];
for (var i = 0; i < n; i++) no[i] = (new Set()).add(i);
while (m--) {
    input = readline().split(' ').map(Number);
    var a = --input[0];
    var b = --input[1];
    no[a].add(b);
    no[b].add(a);
}

var res = [];
var doneFlag = false;

while (!doneFlag) {
    var minr = Infinity;
    var minidx = 0;
    for (var i = 0; i < n; i++) {
        if (minr > no[i].size) {
            minr = no[i].size;
            minidx = i;
        }
    }

    var connected = [];
    for (var i = 0; i < n; i++) {
        if (!no[minidx].has(i)) {
            res.push((minidx+1) + ' ' + (i+1));
            connected.push(i);
            no[minidx].add(i);
			no[i].add(minidx);
        }
    }

    doneFlag = true;
    for (var i = 0; i < connected.length; i++) {
        for (var j = 0; j < connected.length; j++) {
            no[connected[i]].add(connected[j]);
			no[connected[j]].add(connected[i]);
		}
        if (no[i].size < n) {
            doneFlag = false;
            break;
        }
    }

}

write(res.length + '\n' + res.join('\n'));

;(function () {
	print(function () {
		var l = readline().split(' ').map(Number), n = l[0], m = l[1], a = [];
		while (m--) { a.push(readline().split(' ').map(Number)); }

		var t = [];
		for (var i = 0; i < n; i++) { t.push(true); }
		a.forEach(function (e) { t[e[0] - 1] = t[e[1] - 1] = false; });
		t = t.map(function (e, i) { return e ? i + 1 : false; }).filter(function (e) { return e === parseInt(e); });

		return [n - 1].concat(function (a, n) {
			var ret = [];
			for (var i = 0; i < n; i++) {
				if (i+1 !== a) {
					ret.push([a, i+1].join(' '));
				}
			}

			return ret;
		}(t[0], n)).join('\n')
	}());
}).call(this);

function main(str) {
    var arr = str.split(' ');
    var num1 = +arr[0];
    var num2 = +arr[1];

    var myGraph;

    // конструктор графа
    var Graph = function (nodes) {
        this.nodesNumber = nodes;
        this.edgesNumber = 0;
        this.nodes = new Array(this.nodesNumber);
        var i = 0;

        for (i; i < nodes; i++) {
            this.nodes[i] = [];
        }

        this.connectNodes = function (node1, node2) {
            this.nodes[node1].push(node2);
            this.nodes[node2].push(node1);
            this.edgesNumber++;
        }

        this.showGraph = function () {
            var i = 0;
            var j = 0;
            write(this.edgesNumber);
            for (i; i < this.nodes.length; i++) {
                for (j; j < this.nodes[i].length; j++) {
                    write((i + 1) + ' ' + (this.nodes[i][j] + 1));
                }
            }
        }
    }

    function logic() {
        myGraph = new Graph(num1);
        var centralNode = 0;
        var nodesUnderCondition = new Set();
        var i = 0;
        var j = 0;
        var k = 0;
        for (j;j<num2;j++) {
            var str = readline();
            var arr = str.split(' ');
            var node1 = +arr[0];
            var node2 = +arr[1];
            nodesUnderCondition.add(node1);
            nodesUnderCondition.add(node2);
        }

        for (k;k<num1;k++) {
            if (!nodesUnderCondition.has(k)) {
                centralNode = k;
            }
        }

        for (i; i < num1; i++) {
            if (i !== centralNode) {
                myGraph.connectNodes(i, centralNode);
            }
        }

        myGraph.showGraph();
    }

    logic();
}

var data = readline();
main(data);

function main(str) {
    var arr = str.split(' ');
    var num1 = +arr[0];
    var num2 = +arr[1];

    var myGraph;

    // конструктор графа
    var Graph = function (nodes) {
        this.nodesNumber = nodes;
        this.edgesNumber = 0;
        this.nodes = new Array(this.nodesNumber);
        var i = 0;

        for (i; i < nodes; i++) {
            this.nodes[i] = [];
        }

        this.connectNodes = function (v, w) {
            this.nodes[v].push(w);
            this.nodes[w].push(v);
            this.edgesNumber++;
        }

        this.showGraph = function () {
            var i = 0;
            var j = 0;
            write(this.edgesNumber + '\n');
            for (i; i < this.nodes.length; i++) {
                for (j; j < this.nodes[i].length; j++) {
                    var resStr = (i + 1) + ' ' + (this.nodes[i][j] + 1) + '\n';
                    write(resStr);
                }
            }
        }
    }

    function logic() {
        myGraph = new Graph(num1);
        var centralNode = 0;
        var nodesUnderCondition = new Set();
        var i = 0;
        var j = 0;
        var k = 0;
        for (j;j<num2;j++) {
            var str = readline();
            var arr = str.split(' ');
            var node1 = +arr[0];
            var node2 = +arr[1];
            nodesUnderCondition.add(node1);
            nodesUnderCondition.add(node2);
        }

        for (k;k<num1;k++) {
            if (!nodesUnderCondition.has(k)) {
                centralNode = k;
            }
        }

        for (i; i < num1; i++) {
            if (i !== centralNode) {
                myGraph.connectNodes(i, centralNode);
            }
        }

        myGraph.showGraph();
    }

    logic();
}

var data = readline();
main(data);

function main(str) {
    var arr = str.split(' ');
    var num1 = +arr[0];
    var num2 = +arr[1];

    var myGraph;

    // конструктор графа
    var Graph = function (nodes) {
        this.nodesNumber = nodes;
        this.edgesNumber = 0;
        this.nodes = new Array(this.nodesNumber);
        var i = 0;

        for (i; i < nodes; i++) {
            this.nodes[i] = [];
        }

        this.connectNodes = function (v, w) {
            this.nodes[v].push(w);
            this.nodes[v].push(w);
            this.edgesNumber++;
        }

        this.showGraph = function () {
            var i = 0;
            var j = 0;
            write(this.edgesNumber);
            for (i; i < this.nodes.length; i++) {
                for (j; j < this.nodes[i].length; j++) {
                    write((i + 1) + ' ' + (this.nodes[i][j] + 1));
                }
            }
        }
    }

    function logic() {
        myGraph = new Graph(num1);
        var centralNode = 0;
        var nodesUnderCondition = new Set();
        var i = 0;
        var j = 0;
        var k = 0;
        for (j;j<num2;j++) {
            var str = readline();
            var arr = str.split(' ');
            var node1 = +arr[0];
            var node2 = +arr[1];
            nodesUnderCondition.add(node1);
            nodesUnderCondition.add(node2);
        }

        for (k;k<num1;k++) {
            if (!nodesUnderCondition.has(k)) {
                centralNode = k;
            }
        }

        for (i; i < num1; i++) {
            if (i !== centralNode) {
                myGraph.connectNodes(i, centralNode);
            }
        }

        myGraph.showGraph();
    }

    logic();
}

var data = readline();
main(data);

function main(str) {
    var arr = str.split(' ');
    var num1 = +arr[0];
    var num2 = +arr[1];

    var myGraph;

    // конструктор графа
    var Graph = function (nodes) {
        this.nodesNumber = nodes;
        this.edgesNumber = 0;
        this.nodes = new Array(this.nodesNumber);
        var i = 0;

        for (i; i < nodes; i++) {
            this.nodes[i] = [];
        }

        this.connectNodes = function (v, w) {
            this.nodes[v].push(w);
            this.nodes[w].push(v);
            this.edgesNumber++;
        }

        this.showGraph = function () {
            var i = 0;
            var j = 0;
            write(this.edgesNumber);
            for (i; i < this.nodes.length; i++) {
                for (j; j < this.nodes[i].length; j++) {
                    var resStr = (i + 1) + ' ' + (this.nodes[i][j] + 1);
                    write(resStr);
                }
            }
        }
    }

    function logic() {
        myGraph = new Graph(num1);
        var centralNode = 0;
        var nodesUnderCondition = new Set();
        var i = 0;
        var j = 0;
        var k = 0;
        for (j;j<num2;j++) {
            var str = readline();
            var arr = str.split(' ');
            var node1 = +arr[0];
            var node2 = +arr[1];
            nodesUnderCondition.add(node1);
            nodesUnderCondition.add(node2);
        }

        for (k;k<num1;k++) {
            if (!nodesUnderCondition.has(k)) {
                centralNode = k;
            }
        }

        for (i; i < num1; i++) {
            if (i !== centralNode) {
                myGraph.connectNodes(i, centralNode);
            }
        }

        myGraph.showGraph();
    }

    logic();
}

var data = readline();
main(data);


const readline = require('readline');

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

let l = 0;
let lines = [];
rl.on('line', (line) => {
  if (!l) {
    l = +line
  } else {
    lines.push(+line);
  }
}).on('close', () => {
  for(q = 0; q < lines.length; q++) {
    const n = lines[q];
    const centre = n / 2;
    let o;
    const x = [];
    const y = [];
    let summ = 0;
    let summ2 = 1;
    if (centre % 2 !== 0) {
      o = 'NO'
    } else {
      o = 'YES'
      for (i = 1, j = 1; i <= centre; i++, j+= 2) {
        x.push(2 * i)
        summ += 2 * i;

        if (i === 1) {
          y.push(1)
        } else {
          if (i !== centre) {
            y.push(j)
            summ2 += j
          } else{
            y.push(summ - summ2)
            summ2 += summ - summ2
          }
        }
      }
    }

    process.stdout.write(`${o}\n`);
    o === "YES" && process.stdout.write(`${[...x, ...y].join(' ')}\n`);
  }
});

var t = parseInt(readline());
for (var tc = 0; tc < t; tc++) {
  var n = parseInt(readline());
  var evenSide = [];
  var oddSide = [];
  if ((n / 2) % 2 != 0) print("No");
  else {
    var evenSum = 0;
    var oddSum = 0;
    for (var i = 2; i <= n; i += 2) {
      evenSide.push(i);
      oddSide.push(i - 1);
      evenSum += i;
      oddSum += i - 1;
    }
    if ((evenSum - oddSum) % 2 == 0) {
      oddSide[oddSide.length - 1] += evenSum - oddSum;
      print("Yes", "\n", evenSide.concat(oddSide).join(" "));
    } else print("No");
  }
}
/*function findx(n) {
  var evenSide = [];
  var oddSide = [];
  if ((n / 2) % 2 != 0) console.log("No");
  else {
    var evenSum = 0;
    var oddSum = 0;
    for (var i = 2; i <= n; i += 2) {
      evenSide.push(i);
      oddSide.push(i - 1);
      evenSum += i;
      oddSum += i - 1;
    }
    if ((evenSum - oddSum) % 2 == 0) {
      oddSide[oddSide.length - 1] += evenSum - oddSum;
      console.log("Yes", "\n", evenSide.concat(oddSide));
    } else console.log("No");
  }
}
findx(4);*/

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

  let sum = 0;
  let even = 2;
  let odd = 1;
  let i = 0;
  const left = [];
  const right = [];
  while (i < +d - 1) {
    if (i % 2 === 0) {
      left.push(even);
      sum += even;
      even += 2;
    }
    else {
      right.push(odd);
      sum -= odd;
      odd += 2;
    }

    i++;
  }

  if (sum % 2 === 0) {
    console.log('NO');
  }
  else {
    console.log('YES');
    const ans = [...left, ...right, sum];
    console.log(ans.join(' '));
  }

  // let ans = [];
  // let v = +d;

  // let value = 2;
  // for (let i = 0; i < v / 2; i++) {
  //   ans.push(value);
  //   value += 2;
  // }

  // let sum = ans.reduce((acc, x) => acc + x, 0);

  // value = 1;
  // for (let i = v / 2; i < v - 1; i++) {
  //   ans.push(value);
  //   sum -= value;
  //   value += 2;
  // }

  // if (sum % 2 === 0) {
  //   console.log('NO');
  // }
  // else {
  //   ans.push(sum);
  //   console.log('YES');
  //   console.log(ans.join(' '));
  // }

  c++;
});

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

  let ans = [];
  let v = +d;

  let value = 2;
  for (let i = 0; i < v / 2; i++) {
    ans.push(value);
    value += 2;
  }

  let sum = ans.reduce((acc, x) => acc + x, 0);

  value = 1;
  for (let i = v / 2; i < v - 1; i++) {
    ans.push(value);
    sum -= value;
    value += 2;
  }

  if (sum % 2 === 0) {
    console.log('NO');
  }
  else {
    ans.push(sum);
    console.log('YES');
    console.log(ans.join(' '));
  }

  c++;
});

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

const input = [];

function splitAndParseInt(line) {
  return line.split(" ").map((x) => parseInt(x));
}

readLine.on("line", (line) => input.push(line));
readLine.on("close", () => {
  let t = parseInt(input[0]);

  for (let i = 1; i <= t; i += 1) {
    const n = parseInt(input[i]);

    if ((n / 2) % 2 !== 0) {
      console.log("NO");
      continue;
    }

    const size = n / 2;
    const answer = [];

    let sumLeft = 0;
    for (let i = 0, j = 2; i < size; i += 1, j += 2) {
      answer.push(j);
      sumLeft += j;
    }

    let sumRight = 0;
    for (let i = 0, j = 1; i < size - 1; i += 1, j += 2) {
      answer.push(j);
      sumRight += j;
    }

    answer.push(sumLeft - sumRight);
    console.log(`YES`);
    console.log(answer.join(" "));
  }
});

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

function print(x) {
    console.log(x);
}

let inputString = "";
let currentLine = 0;

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

//-----------main fucntion-----------

function main() {
    var input = parseInt(readline())
    //var a = readline().split(" ").map(x => parseInt(x))
    while (input--) {
        var n = parseInt(readline())
        var half = n / 2
        if (half % 2 == 1) print("NO")
        else {
            var evenarr = [], oddarr = []
            for (var i = 2; i <= n; i += 2) {
                evenarr.push(i)
                oddarr.push(i - 1)
            }
            oddarr[half - 1] = oddarr[half - 1] + half
            print("YES")
            print(evenarr.join(" ")+" "+oddarr.join(" "))
        }

    }

}

// this is js
var tests = parseInt(readline()), value = 0, stop = 0;
for (var i = 0; i < tests; i++)
	{
	value = parseInt(readline())
	stop = value/2
	var array = [], sum = 0, sum2 = 0
	if ((value/2)%2) print('NO')
	else{
	for (var j = 1; j < value; j++)
		{
		if (j  <= stop)
		{
			sum += 2*(j)
			array.push(2*(j))
		}
		else
		{   sum2+= 2*(j-stop)-1
			array.push(2*(j-stop)-1)
		}
	}
		array.push(sum-sum2)
		print('YES')
		print(array.join(' '))
	}
}

function solve(n) {
  const a = (n % 4);
  let result = [];
  if (a === 0) {
    result = new Array(n);
    const k = (n / 2);
    let s = 0;
    for (let i = 0; i < k; i = i + 1) {
      result[i] = i + i + 2;
      s = s + result[i];
    }
    let t = 0;
    for (let i = 0; i < (k - 1); i = i + 1) {
      const u = k + i;
      result[u] = i + i + 1;
      t = t + result[u];
    }
    result[n - 1] = s - t;
  }
  return result;
}

function main(lines) {
  const yes = 'YES';
  const no = 'NO';
  lines.shift();
  for (const line of lines) {
    const a = Number(line);
    const result = solve(a);
    if (result.length === 0) {
      console.log(no);
    } else {
      console.log(yes);
      console.log(result.join(' '));
    }
  }
}

function trim_line(s) {
  return s.trim();
}

function has_content(s) {
  return (s.length > 0);
}

async function processLinesFromStream(rs, pf) {
  const chunks = [];
  const encoding = 'utf-8';
  rs.setEncoding(encoding);
  for await (let chunk of rs) {
    chunks.push(chunk);
  }
  const empty = '';
  const newline = /\n/;
  const lines = chunks.join(empty)
                      .split(newline)
                      .map(trim_line)
                      .filter(has_content);
  const result = pf(lines);
  return result;
}

processLinesFromStream(process.stdin, main);

function solve(n) {
  const a = (n % 4);
  let result = [];
  if (a === 0) {
    result = new Array(n);
    const k = (n / 2);
    let s = 0;
    for (let i = 0; i < k; i = i + 1) {
      result[i] = i + i + 2;
      s = s + result[i];
    }
    let t = 0;
    for (let i = 0; i < (k - 1); i = i + 1) {
      const u = k + i;
      result[u] = i + i + 1;
      t = t + result[u];
    }
    result[n - 1] = s - t;
  }
  return result;
}

function main(lines) {
  const yes = "YES";
  const no = "NO";
  lines.shift();
  for (const line of lines) {
    let t = line.trim();
    if (line.length > 0) {
      const a = Number(t);
      const result = solve(a);
      if (result.length === 0) {
        console.log(no);
      } else {
        console.log(yes);
        console.log(result.join(' '));
      }
    }
  }
}

async function processLinesFromStream(rs, pf) {
  const content = [];
  rs.setEncoding("utf-8");
  for await (let chunk of rs) {
    content.push(chunk);
  }
  const lines = content.join('').split(/\n/);
  const result = pf(lines);
  return result;
}

processLinesFromStream(process.stdin, main);

'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.replace(/\s*$/, '')
    .split('\n')
    .map(str => str.replace(/\s*$/, ''));
  main();
});

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

function solve(n) {
  if (n % 4 !== 0) return -1;
  let even = [2];
  let sumEven = 2;
  let odd = [1];
  let sumOdd = 1;
  while (odd.length < n / 2) {
    let nextEven = even[even.length - 1] + 2;
    sumEven += nextEven;
    even.push(nextEven);
    let nextOdd = odd[odd.length - 1] + 2;
    sumOdd += nextOdd;
    odd.push(nextOdd);
  }
  odd[odd.length - 1] = sumEven - sumOdd + odd[odd.length - 1];
  return even.concat(odd);
}

function main() {
  const t = parseInt(readLine());
  for (let i = 0; i < t; i++) {
    let n = parseInt(readLine());
    // let a = readLine().split(' ').map((val) => parseInt(val));
    let res = solve(n);
    if (res === -1) console.log('NO');
    else {
      console.log('YES');
      console.log(res.join(' '));
    }
    // console.log(res);
  }
  //process.stdout.write("hello: ");
}

// Sample code to perform I/O:

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

process.stdin.on("data", function (input) {
    stdin_input += input;                               // Reading input from STDIN
});

process.stdin.on("end", function () {
    main(stdin_input);
});

function main(input) {
    let output = nameLookUp(input);
    //   process.stdout.write(output);       // Writing output to STDOUT
}

// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail

// Write your code here
function nameLookUp(str) {

    let inputs = str.trim().split('\n');
    //let testResult = [];
    for (let index = 1; index <= +inputs[0]; index++) {
        const element = +inputs[index];

        if (element % 4 !== 0) {
            console.log('NO');
            // testResult.push('NO');
            continue;
        }
        let arr = { odd: [], even: [] };
        for (let index2 = 1; index2 <= element; index2++) {

            if (index2 % 2 == 0) {
                arr.even.push(index2);
            }
            else {
                arr.odd.push(index2);
            }
        }

        arr.odd[arr.odd.length - 1] = arr.odd[arr.odd.length - 1] + Math.floor(element / 2);
        console.log('YES');
        console.log(arr.even.join(' '), arr.odd.join(' '));

    }
    //console.log(testResult);
    // return ' '.toString();

}

// Don't know where the future lies
var tests = parseInt(readline()), value = 0, stop = 0;
for (var i = 0; i < tests; i++)
	{
	value = parseInt(readline())
	stop = value/2
	var array = [], sum = 0, sum2 = 0
	if ((value/2)%2) print('NO')
	else{
	for (var j = 1; j < value; j++)
		{
		if (j  <= stop)
		{
			sum += 2*(j)
			array.push(2*(j))
		}
		else
		{   sum2+= 2*(j-stop)-1
			array.push(2*(j-stop)-1)
		}
	}
		array.push(sum-sum2)
		print('YES')
		print(array.join(' '))
	}
}

'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.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

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

function main() {
    let t = parseInt(readLine());
    for (var i = 0; i < t; i++) {
        let n = parseInt(readLine());
        if ((n / 2) % 2 == 1) {
            console.log('NO');
        } else {
            console.log('YES');
            let even = [];
            let odd = [];
            let j = 2;
            let oke = 1;
            while (true) {
                even.push(j);
                if (odd.length >= n / 4) {
                    odd.push(j + 1);
                } else odd.push(j - 1);
                j += 2;
                if (even.length == n / 2 && odd.length == n / 2) break;
            }
            console.log(even.concat(odd).join(' '))
        }
    }
}

// Just wandering on the pale blue dot
var tests = parseInt(readline()), value = 0, stop = 0;
for (var i = 0; i < tests; i++)
	{
	value = parseInt(readline())
	stop = value/2
	var array = [], sum = 0, sum2 = 0
	if ((value/2)%2) print('NO')
	else{
	for (var j = 1; j < value; j++)
		{
		if (j  <= stop)
		{
			sum += 2*(j)
			array.push(2*(j))
		}
		else
		{   sum2+= 2*(j-stop)-1
			array.push(2*(j-stop)-1)
		}
	}
		array.push(sum-sum2)
		print('YES')
		print(array.join(' '))
	}
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function main() {
  //let [n, industry] = readline().split(" ").map(e => parseInt(e));

    let cases = parseInt(readline(), 10);
    for (var X = 0; X < cases; X++) {
      const n = parseInt(readline(), 10);
      const half = n / 2;

      if (half % 2 !== 0) {
        // const odd = [half-1, half+1];
        // const even = [half-2, half+2];
        console.log('NO');
        // console.log([...odd, ...even].join(" "))
      } else {
        let odd = [];
        let even = [];

        let c = 2;
        for (var i = 0; i < half; i++) {
          odd.push(c);
          c+= 2;
        }
        const sumOdd = odd.reduce((a,b) => a+b, 0);

        c = 1;
        for (var i = 0; i < half-1; i++) {
          even.push(c);
          c += 2;
        }
        even.push(sumOdd - even.reduce((a,b) => a+b, 0))

        console.log('YES');
        console.log([...odd, ...even].join(" "))
      }

    }

}

// very experimental, but faster than python3
var tests = parseInt(readline()), value = 0, stop = 0;
for (var i = 0; i < tests; i++)
	{
	value = parseInt(readline())
	stop = value/2
	var array = [], sum = 0, sum2 = 0
	if ((value/2)%2) print('NO')
	else{
	for (var j = 1; j < value; j++)
		{
		if (j  <= stop)
		{
			sum += 2*(j)
			array.push(2*(j))
		}
		else
		{   sum2+= 2*(j-stop)-1
			array.push(2*(j-stop)-1)
		}
	}
		array.push(sum-sum2)
		print('YES')
		print(array.join(' '))
	}
}

// I truly believe that i am wasting my time with these programming questions
var tests = parseInt(readline()), value = 0, stop = 0;
for (var i = 0; i < tests; i++)
	{
	value = parseInt(readline())
	stop = value/2
	var array = [], sum = 0, sum2 = 0
	if ((value/2)%2) print('NO')
	else{
	for (var j = 1; j < value; j++)
		{
		if (j  <= stop)
		{
			sum += 2*(j)
			array.push(2*(j))
		}
		else
		{   sum2+= 2*(j-stop)-1
			array.push(2*(j-stop)-1)
		}
	}
		array.push(sum-sum2)
		print('YES')
		print(array.join(' '))
	}
}

Main();
function myout(t){print(t);}//standard output
function next(){return readline();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す
//6:1文字に分割  7:1文字に分割し、数値配列へ
//8:半角SPで結合　9:改行で結合　0:文字なしで結合
//atcoderのサンプルは最後に改行入れること
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));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() {
    var t = nextInt();
	var output = [];
	for(var i = 0; i < t; i++){
		var n = nextInt();
		if(n % 4 != 0){
			output.push("NO");
		}else{
			n /= 2;
			var sum = 0;
			var list = [];
			for(var j = 1; j <= n; j++){
				list.push(j * 2);
				sum += (j * 2);
			}
			for(var j = 1; j < n; j++){
				list.push((j * 2) - 1);
				sum -= (j * 2) - 1;
			}
			list.push(sum);
			output.push("YES");
			output.push(myconv(list,8));
		}
	}
	myout(myconv(output,9));
}

var testsAmount = parseInt(readline());

var tests = [];
for (var i = 0; i < testsAmount; i++) {
  tests.push(parseInt(readline()));
}

for (var i = 0; i < tests.length; i++) {
  if (tests[i] % 4 > 0) {
    print('NO');

    continue;
  }

  var first = '';
  var second = '';
  for (var j = 1; j <= tests[i]; j++) {
    if (j % 2 === 0) {
      first += ' ' + j;
    } else {
      second += ' ' + (j === tests[i] - 1 ? (j + tests[i]/2) : j);
    }
  }

  print('YES');
  print(first.slice(1) + second);
}

  var testsAmount = parseInt(readline());

  var tests = [];
  for (var i = 0; i < testsAmount; i++) {
    tests.push(parseInt(readline()));
  }

  for (var i = 0; i < tests.length; i++) {
    if (tests[i] % 4 > 0) {
      print('NO');

      continue;
    }

    var first = [];
    var second = [];
    for (var j = 1; j <= tests[i]; j++) {
      if (j % 2 === 0) {
        first.push(j);
      } else {
        second.push(j === tests[i] - 1 ? (j + tests[i]/2) : j);
      }
    }

    print('YES');
    print(first.join(' ') + ' ' + second.join(' '));
  }

  var testsAmount = parseInt(readline());

  var tests = [];
  for (var i = 0; i < testsAmount; i++) {
    tests.push(parseInt(readline()));
  }

  for (var i = 0; i < tests.length; i++) {
    if (tests[i] % 4 > 0) {
      print('NO');

      continue;
    }

    var first = [];
    var second = [];
    for (var j = 1; j <= tests[i]; j++) {
      if (j % 2 === 0) {
        first.push(j);
      } else {
        second.push(j);
      }
    }

    second[second.length - 1] = second[second.length - 1] + tests[i] / 2;

    print('YES');
    print(first.join(' ') + ' ' + second.join(' '));
  }

var testsAmount = parseInt(readline());

var tests = [];
for (var i = 0; i < testsAmount; i++) {
  tests.push(parseInt(readline()));
}

for (var i = 0; i < tests.length; i++) {
  var first = {arr:[],sum:0};
  var second = {arr:[],sum:0};
  for (var j = 1; j <= tests[i]; j++) {
    if (j % 2 === 0) {
      first.arr.push(j);
      first.sum += j;

      if (j === tests[i]) {
        if (first.sum !== second.sum) {
          print('NO');
        } else {
          print('YES');
          print(first.arr.join(' ') + ' ' + second.arr.join(' '));
        }
      }

      continue;
    }

    if (j === tests[i] - 1) {
      if (((first.sum + j + 1) - second.sum) % 2 > 0) {
        second.arr.push((first.sum + j + 1) - second.sum);
        second.sum += (first.sum + j + 1) - second.sum;
      }
    } else {
      second.arr.push(j);
      second.sum += j;
    }
  }
}

var t = parseInt(readline());

for(var qq = 0; qq < t; qq++) {
    var n = parseInt(readline());
    var ndel2 = n / 2;

    if (ndel2 % 2 === 0) {
        var a = [2];
        var b = [1];

        for(var i = 1; i < ndel2; i++) {
            a[i] = a[i - 1] + 2;

            if (i == ndel2 / 2) {
                b[i] = b[i - 1] + 4;
            } else {
                b[i] = b[i - 1] + 2;
            }
        }

        print('YES');
        print(a.concat(b).join(' '));

    } else {
        print('NO');
    }

}

var range = readline();

for(var i=0;i<range;i++) {
    var input = parseInt(readline());
    var divisior = input / 2;
    var even = [];
    var odd = [];

    if(divisior % 2 !== 0) {
        print("NO");
    }else {
        print("YES");
        var index = 1;
        var generate = 0;

        while(generate !== input) {
            generate = 2 * index;
            even.push(generate);
            index++;
        }

        for(var j=0;j<(index - 1)/2;j++) {
            if(even[j]) {
                odd.push(even[j] - 1);

            }
        }

        for(var j=(index -1)/2;j<index;j++) {
            if(even[j]) {
                odd.push(even[j] + 1);
            }
        }

        print(even.join(" ") + " " + odd.join(" "))
    }
}

var t = parseInt(readline());
for (var tc = 0; tc < t; tc++) {
  var n = parseInt(readline());
  var evenSide = [];
  var oddSide = [];
  if ((n / 2) % 2 != 0) print("No");
  else {
    var evenSum = 0;
    var oddSum = 0;
    for (var i = 2; i <= n; i += 2) {
      evenSide.push(i);
      oddSide.push(i - 1);
      evenSum += i;
      oddSum += i - 1;
    }
    if ((evenSum - oddSum) % 2 == 0) {
      oddSide[oddSide.length - 1] += evenSum - oddSum;
      print("Yes", "\n", evenSide.concat(oddSide).join(","));
    } else print("No");
  }
}
/*function findx(n) {
  var evenSide = [];
  var oddSide = [];
  if ((n / 2) % 2 != 0) console.log("No");
  else {
    var evenSum = 0;
    var oddSum = 0;
    for (var i = 2; i <= n; i += 2) {
      evenSide.push(i);
      oddSide.push(i - 1);
      evenSum += i;
      oddSum += i - 1;
    }
    if ((evenSum - oddSum) % 2 == 0) {
      oddSide[oddSide.length - 1] += evenSum - oddSum;
      console.log("Yes", "\n", evenSide.concat(oddSide));
    } else console.log("No");
  }
}
findx(4);*/

var t = parseInt(readline());
for (var tc = 0; tc < t; tc++) {
  var n = parseInt(readline());
  var evenSide = [];
  var oddSide = [];
  if ((n / 2) % 2 != 0) print("No");
  else {
    var evenSum = 0;
    var oddSum = 0;
    for (var i = 2; i <= n; i += 2) {
      evenSide.push(i);
      oddSide.push(i - 1);
      evenSum += i;
      oddSum += i - 1;
    }
    if ((evenSum - oddSum) % 2 == 0) {
      oddSide[oddSide.length - 1] += evenSum - oddSum;
      print("Yes", "\n", evenSide.concat(oddSide));
    } else print("No");
  }
}
/*function findx(n) {
  var evenSide = [];
  var oddSide = [];
  if ((n / 2) % 2 != 0) console.log("No");
  else {
    var evenSum = 0;
    var oddSum = 0;
    for (var i = 2; i <= n; i += 2) {
      evenSide.push(i);
      oddSide.push(i - 1);
      evenSum += i;
      oddSum += i - 1;
    }
    if ((evenSum - oddSum) % 2 == 0) {
      oddSide[oddSide.length - 1] += evenSum - oddSum;
      console.log("Yes", "\n", evenSide.concat(oddSide));
    } else console.log("No");
  }
}
findx(4);*/

var tests = parseInt(readline()), value = 0, stop = 0;
for (var i = 0; i < tests; i++)
	{
	value = parseInt(readline())
	stop = value/2
	var array = [], sum = 0
	if ((value/2)%2) print('NO')
	else{
	for (var j = 1; j < value; j++)
		{
		if (j  <= stop)
		{
			sum += 2*(j)
			array.push(2*(j))
		}
		else
		{
			array.push(2*(j-stop+1)-1)
		}
	}
		array.push(sum - array[value-2])
		print('YES')
		print(array.join(' '))
	}
}

var tests = parseInt(readline()), value = 0, stop = 0;
for (var i = 0; i < tests; i++)
	{
	value = parseInt(readline())
	stop = value/2
	var array = [], sum = 0, sum2 = 0
	if ((value/2)%2) print('NO')
	else{
	for (var j = 1; j < value; j++)
		{
		if (j  <= stop)
		{
			sum += 2*(j)
			array.push(2*(j))
		}
		else
		{   sum2+= 2*(j-stop)-1
			array.push(2*(j-stop)-1)
		}
	}
		array.push(sum2 - array[value-2])
		print('YES')
		print(array.join(' '))
	}
}

var tests = parseInt(readline()), value = 0, stop = 0;
for (var i = 0; i < tests; i++)
	{
	value = parseInt(readline())
	stop = value/2
	var array = [], sum = 0
	if ((value/2)%2) print('NO')
	else{
	for (var j = 1; j < value; j++)
		{
		if (j  < stop)
		{
			sum += 2*(j)
			array.push(2*(j))
		}
		else
		{
			array.push(2*(j-stop+1)-1)
		}
	}
		array.push(sum - array[value-2])
		print('YES')
		print(array.join(' '))
	}
}

var tests = parseInt(readline()), value = 0, stop = 0;
for (var i = 0; i < tests; i++)
	{
	value = parseInt(readline())
	stop = value/2
	var array = [], sum = 0
	if ((value/2)%2) print('NO')
	else{
	for (var j = 1; j < value; j++)
		{
		if (j  <= stop)
		{
			sum += 2*(j)
			array.push(2*(j))
		}
		else
		{
			array.push(2*(j-stop)-1)
		}
	}
		array.push(sum - array[value-2])
		print('YES')
		print(array.join(' '))
	}
}

var tests = parseInt(readline()), value = 0, stop = 0;
for (var i = 0; i < tests; i++)
	{
	value = parseInt(readline())
	stop = value/2
	var array = [], sum = 0
	if (value%2) print('NO')
	else{
	for (var j = 1; j < value; j++)
		{
		if (j  < stop)
		{
			sum += 2*(j)
			array.push(2*(j))
		}
		else
		{
			array.push(2*(j-stop+1)-1)
		}
	}
		array.push(sum - array[value-2])
		print('YES')
		print(array.join(' '))
	}
}

Main();
function myout(t){print(t);}//standard output
function next(){return readline();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す
//6:1文字に分割  7:1文字に分割し、数値配列へ
//8:半角SPで結合　9:改行で結合　0:文字なしで結合
//atcoderのサンプルは最後に改行入れること
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));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() {
    var t = nextInt();
	var output = [];
	for(var i = 0; i < t; i++){
		var n = nextInt();
		if(n % 4 != 0){
			output.push("NO");
		}else{
			n /= 2;
			var sum = 0;
			var list = [];
			for(var i = 1; i <= n; i++){
				list.push(i * 2);
				sum += (i * 2);
			}
			for(var i = 1; i < n; i++){
				list.push((i * 2) - 1);
				sum -= (i * 2) - 1;
			}
			list.push(sum);
			output.push("YES");
			output.push(myconv(list,8));
		}
	}
	myout(myconv(output,9));
}

var testsAmount = parseInt(readline());

var tests = [];
for (var i = 0; i < testsAmount; i++) {
  tests.push(parseInt(readline()));
}

for (var i = 0; i < tests.length; i++) {
  if (tests[i] % 4 > 0) {
    print('NO');

    continue;
  }

  var first = '';
  var second = '';
  for (j = 1; j <= tests[i]; j++) {
    if (j % 2 === 0) {
      first += ' ' + j;
    } else {
      second += ' ' + j;
    }
  }

  print(first.slice(1) + second);
}

var testsAmount = parseInt(readline());

var tests = [];
for (var i = 0; i < testsAmount; i++) {
  tests.push(parseInt(readline()));
}

for (var i = 0; i < tests.length; i++) {
  if (tests[i] % 4 > 0) {
    print('NO');

    continue;
  }

  var first = '';
  var second = '';
  for (j = 1; j <= tests[i]; j++) {
    if (j % 2 === 0) {
      first += ' ' + j;
    } else {
      second += ' ' + (j === tests[i] - 1 ? (j + tests[i]/2) : j);
    }
  }

  print(first.slice(1) + second);
}

var testsAmount = parseInt(readline());

var tests = [];
for (var i = 0; i < testsAmount; i++) {
  tests.push(parseInt(readline()));
}

for (var i = 0; i < tests.length; i++) {
  if (tests[i] % 4 > 0) {
    print('NO');

    continue;
  }

  var first = '';
  var second = '';
  for (var j = 1; j <= tests[i]; j++) {
    if (j % 2 === 0) {
      first += ' ' + j;
    } else {
      second += ' ' + (j === tests[i] - 1 ? (j + tests[i]/2) : j);
    }
  }

  print(first.slice(1) + second);
}

var t = parseInt(readline());

for(var qq = 0; qq < t; qq++) {
    var n = parseInt(readline());
    var ndel2 = n / 2;

    if (ndel2 % 2 === 0) {
        var a = [2];
        var b = [1];

        for(var i = 1; i < ndel2; i++) {
            a[i] = a[i - 1] + 2;

            if (i == ndel2 / 2) {
                b[i] = b[i - 1] + 4;
            } else {
                b[i] = b[i - 1] + 2;
            }
        }

        print(a.concat(b).join(' '));

    } else {
        print('NO');
    }

}

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

function print(x) {
    console.log(x);
}

let inputString = "";
let currentLine = 0;

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

//-----------main fucntion-----------

function main() {
    var input = parseInt(readline())
    //var a = readline().split(" ").map(x => parseInt(x))
    while (input--) {
        var n = parseInt(readline())
        var half = n / 2
        if (half % 2 == 1) print("NO")
        else {
            var evenarr = [], oddarr = []
            for (var i = 2; i <= n; i += 2) {
                evenarr.push(i)
                oddarr.push(i - 1)
            }
            oddarr[half - 1] = oddarr[half - 1] + half
            print("YES")
            print(evenarr.join(" "), oddarr.join(" "))
        }

    }

}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function main() {
  //let [n, industry] = readline().split(" ").map(e => parseInt(e));

    let cases = parseInt(readline(), 10);
    for (var i = 0; i < cases; i++) {
      const n = parseInt(readline(), 10);
      const half = n / 2;

      if (half % 2 !== 0) {
        console.log('NO');
      } else {
        let odd = [];
        let even = [];

        let c = 2;
        for (var i = 0; i < half; i++) {
          odd.push(c);
          c+= 2;
        }
        const sumOdd = odd.reduce((a,b) => a+b, 0);

        c = 1;
        for (var i = 0; i < half-1; i++) {
          even.push(c);
          c += 2;
        }
        even.push(sumOdd - even.reduce((a,b) => a+b, 0))

        console.log('YES');
        console.log([...odd, ...even].join(" "))
      }

    }

}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function main() {
  //let [n, industry] = readline().split(" ").map(e => parseInt(e));

    let cases = parseInt(readline(), 10);
    for (var i = 0; i < cases; i++) {
      const n = parseInt(readline(), 10);
      const half = n / 2;

      if (half % 2 !== 0) {
        // const odd = [half-1, half+1];
        // const even = [half-2, half+2];
        console.log('NO');
        // console.log([...odd, ...even].join(" "))
      } else {
        let odd = [];
        let even = [];

        let c = 2;
        for (var i = 0; i < half; i++) {
          odd.push(c);
          c+= 2;
        }
        const sumOdd = odd.reduce((a,b) => a+b, 0);

        c = 1;
        for (var i = 0; i < half-1; i++) {
          even.push(c);
          c += 2;
        }
        even.push(sumOdd - even.reduce((a,b) => a+b, 0))

        console.log('YES');
        console.log([...odd, ...even].join(" "))
      }

    }

}


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 n = 0;
    for(i = 1; i <= t * 2; i++){
        if(i % 2 == 1){
            n = lines[i];
        }else{
            var k = lines[i].split(' ').map(Number);
            var sum = 0;
            for(j = 0; j < n; j++){
                sum+=k[j];
            }
            if(sum % n === 0){
                var avg = sum / n;
                var a = 0;
                for(j = 0; j < n; j++){
                    if(k[j] > avg){
                        a++;
                    }
                }
                console.log(a);
            }else{
                console.log(-1);
            }
        }
    }
});

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() {
    let n = parseInt(readLine());
    let arr = readLine().split(" ");
    let sum = arr.reduce((acc, cur) => acc + parseInt(cur), 0);
    if (sum % n != 0) {
        return -1;
    }
    let avg = sum / n;
    let presentAvgCount = arr.reduce((acc, cur) => {
        if (parseInt(cur) > avg){
            return acc+1;
        }
        return acc;
    }, 0);
    return presentAvgCount;
}

'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
let input = '';
process.stdin.on('data', inputStdin => {
    input += inputStdin;
});
process.stdin.on('end', _ => {
    main(input);
});

function main(input) {
    var args = input.split("\n");
    const t = parseInt(args[0], 10);
    for (var i = 1; i <= t; i++) {
        var n = parseInt(args[2 * i - 1], 10);
        var arg = (args[2 * i].split(" ")).map((e) => parseInt(e, 10));
        var s = arg.reduce(function (sum, element) {
            return sum + element;
        }, 0);
        var d = s % n;
        if (d != 0) {
            console.log("-1");
        }
        else {
            var c = Math.floor(s / n);
            var cnt = 0;
            for (var j = 0; j < n; j++) {
                if (arg[j] > c) {
                    cnt++;
                }
            }
            console.log(cnt);
        }
    }
}

"use strict";

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

let inputString = "";
let currentLine = 0;

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

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

  main();
});

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

function main() {
  let t = parseInt(readLine()); // number of test cases

  while (t--) {
    let n = parseInt(readLine()); // number of friends

    let a = readLine()
      .split(" ")
      .map((x) => parseInt(x)); // array of candies

    console.log(getMinK(a, n));
  }
}

function getMinK(a, n) {
  let candiesSum = 0;

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

  let equalNumber = candiesSum / n;

  if (candiesSum % n !== 0) {
    return -1;
  }

  let k = 0;

  for (let j = 0; j < a.length; j++) {
    if (a[j] > equalNumber) {
      k++;
    }
  }

  return k;
}

process.stdin.resume();

process.stdin.setEncoding('utf8');

var input = '';

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

function main(input) {
    input = input.split("\n");
    let z = 0;
    let testCases = +input[z++];

    while(testCases--){
        let arrLen = +input[z++];
        let arr = input[z++].split(' ').map(x=>Number(x));

        let sum = arr.reduce((a,b)=>a+b);
        let modular = sum % arrLen;

        if(modular !== 0) console.log(-1);
        else{
            let counter = 0;
            arr.forEach(value => {
                if(value > sum / arrLen) counter++;
            });
            console.log(counter);
        }
    }
}

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((a, b) => a + b);
		let x = 0;
		let y = 0;
		if (n == 1) {
			ans.push(0);
		} else if(s % n !== 0) {
			ans.push(-1);
		} else {
			let c = s / n;
			a.forEach(e => {
				if (e === c) {
					x++;
				}
				if (e > c) {
					y++;
				}
			});
			if (x === n) {
				ans.push(0);
			} else {
				ans.push(y);
			}
		}
	}
	console.log(ans.join('\n'));
};

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

var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
var lines = [];
rl.on('line', function(input) {
    lines.push(input);
});
rl.on('close', function() {
    var t = parseInt(lines[0]);
    var l = 1;
    for (var i = 0; i < t; i++) {
        l++
        console.log(solve(lines[l++].split(' ').map(Number)));
    }
});

const solve = (arr) => {
    try{
        const arr_sum = arr.reduce((acc, curr) => acc + curr, 0);

        if(arr_sum % arr.length !== 0){
            return -1;
        }

        let cnt = 0;

        for(let i of arr){
            if(i > arr_sum / arr.length){
                cnt += 1;
            }
        }

        return cnt;
    }catch (ex) {
        console.log('ex:', ex)
    }
};

var timer = 0;
function dfs(v, prev) {
   var h = {};
   v.__h = h;
   h.tin = ++timer;
   h.up = [];
   var i = 0;
   var next = prev;
   while (next) {
      h.up[i] = next;
      next = next.__h.up[i++];
   }
   var children = v.childNodes;
   for (i = 0; i < children.length; i++) {
      dfs(children[i], v);
   }
   h.tout = ++timer;
}

function gcd(x, y) {
   if (y === 0) {
      return x;
   }
   return gcd(y, x % y);
}

function div(a, b) {
   return Math.floor(a / b);
}

function solve() {
   var n = Number(read());
   var sum = 0;
   var arr = readArray((a) => {
      var numA = Number(a);
      sum += numA;
      return numA;
   });
   if (sum % n !== 0) {
      write(-1);
      return;
   }
   var ans = 0;
   var avg = div(sum, n);
   for (var i = 0; i < arr.length; i++) {
      if (arr[i] > avg) {
         ans++;
      }
   }
   write(ans);
}

function init() {
   var T;
   T = 1;
   T = Number(read());
   for (var t = 0; t < T; t++) {
      solve();
   }
}

function sortF(a, b) {
   if (a < b) {
      return -1;
   }
   if (a > b) {
      return 1;
   }
   return 0;
}

function readArray(f) {
   return read().split(' ').map(f);
}

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;

   var needWriteFile = false;

   var writeResult = '';
   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');
         init();
         if (needWriteFile) {
            fs.writeFile(path.join(__dirname, outTextName), writeResult, (err) => {
               err ? console.error(err) : console.log('good')
            });
         }
      });
   } else {
      MEMORY = fs.readFileSync(0, 'utf-8').split('\r\n');
      init();
   }
} else {
   init();
}

function write(value) {
   if (needWriteFile) {
      writeResult += value + '\n';
      return;
   }
   isNode ? console.log('' + value) : print('' + value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}
function readAll() {
   return isNode && MEMORY;
}

let lineContent = ''

process.stdin.on('data', c => lineContent += c)
process.stdin.on('end', () => {
    const { EOL } = require('os')
    const lines = lineContent.split(EOL) /*your input text, split by lines*/

    const testNumbers = parseInt(lines[0]);

    for (let i = 0; i < testNumbers; i++) {
        const [n] = lines[1 + i * 2].split(" ").map((e) => parseInt(e));
        const arr = lines[2 + i * 2].split(" ").map(e => parseInt(e));

        console.log(f(n, arr));
    }

})

const f = (n, arr) => {
    const sum = arr.reduce((c, e) => c += e);
    if (sum % n !== 0) return -1;

    const candy = sum / n;

    let res = 0;

    for (let i = 0; i < n; i++) {
        if (arr[i] > candy) {
            res++;
        }
    }

    return res;
}

var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
var lines = [];
rl.on('line', function(input) {
    lines.push(input);
});
rl.on('close', function() {
    var t = parseInt(lines[0]);
    var l = 1;
    for (var i = 0; i < t; i++) {
        l++
        console.log(solve(lines[l++].split(' ').map(Number)));
    }
});

function solve(nums) {
    let sum = 0
    for (let i = 0; i < nums.length; i++) {
        sum += nums[i]
    }
    const avg = sum / nums.length
    if (avg !== Math.ceil(avg)) return -1

    let k = 0
    for (let i = 0; i < nums.length; i++) {
        if (nums[i] > avg) {
            k++
        }
    }
    return k
}

//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] = BigInt(next());
		}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 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 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 sum = 0;
		for(var i = 0; i < N; i++){
			sum += list[i];
		}
		if(sum % N != 0){
			myout(-1);
			continue;
		}
		var output = 0;
		for(var i = 0; i < N; i++){
			if(list[i] > (sum / N)){
				output++;
			}
		}
		myout(output);
	}
}

var t = parseInt(readline());

for(i = 0; i < t; i++) {
    var n = parseInt(readline());
    var a = readline().split(" ");
    var sum = 0;
    for(j = 0; j < n; j++) sum += parseInt(a[j]);
    if(sum % n !== 0) print(-1);
    else {
        var count = 0, over = 0, div = sum / n;
        for(j = 0; j < n; j++) {
            //if(parseInt(a[j]) === div) count += 1;
            //else
            if(parseInt(a[j]) > div) over += 1;
        }
        /*if(n !== count) {
            //if(n - count - 1 >= Math.ceil(n/2)) {
            //    print(Math.ceil)
            //}
            //else print(n - count - 1);
            print(n - count - 1);
        }*/
        if(over > 0) {print(over);}
        else print(0);
    }
}

var tc=readline();
while(tc--)
{
   var n=readline();
   var arr=readline().split(' ');
   arr.sort(function(u,v){return u-v;});
   var sum=0;
   for(var i=0;i<arr.length;i++) sum+=Number(arr[i]);
    if(sum%arr.length>0) print(-1);
   else
{     var sz=arr.length;
       var u=sum/sz;
       var cnt=0;
for(var i=0;i<sz;i++) cnt+=(Number(arr[i])>u);
    print(cnt);
}

}

// B. Friends and Candies

var l0 = readline();
var n = +l0;
var arr = [];
for (var a = 0; a<n; a++) {
    var ignore = readline();
    arr.push(readline().split(' ').map(v => +v));
}

// output
// 2
// 1
// -1
// 0
// 0

for (var x = 0; x<arr.length; x++) {
    var sum = 0;
    for (y = 0; y<arr[x].length;y++) {
        sum = sum + arr[x][y];
    }

    if (sum%arr[x].length !== 0) {
        print(-1);
    } else {
        var eq = sum/arr[x].length;
        var count = 0;
        for (var z = 0; z<arr[x].length;z++) {
            if (arr[x][z] > eq) {
                count++;
            }
        }
        if (count) {
            print(count);
        } else {
            print(0);
        }
    }
}

var numberOfCases = Number(readline());
for (var i = 0; i < numberOfCases; ++i) {
    processCase();
}

function processCase() {
    var numsCount = Number(readline());
    var nums = readline().split(" ").map(x => Number(x));

    if (numsCount === 1) {
        return print("0");
    }

    var sum = 0;
    for (var i = 0; i < nums.length; ++i) {
        sum += nums[i];
    }

    var avg = sum / nums.length;
    if (avg !== Math.trunc(avg)) {
        return print("-1");
    }

    print(nums.reduce((acc, elem) => {
        if (elem > avg) {
            ++acc;
        }

        return acc;
    }, 0));
}

var tc = parseInt(readline());

while(tc--) {
    var n = parseInt(readline());
    var arr = readline().split(' ').map(i => parseInt(i));

    var sum = arr.reduce((a, b) => {
        return a + b;
    });

    if (sum % n) {
        print ("-1");
    } else  {
        var newArray = arr.filter(e => {
            return e > (sum/n);
        });
        print(newArray.length);
    }
}

function readStringArray() {
  return readline().split(" ");
}
function readNumArray() {
  return readStringArray().map(Number);
}

function main() {
  var testCasesNum = +readline();
  for (var i = 0; i < testCasesNum; i++) {
    var x = +readline();
    var nums = readNumArray();
    var sum = 0;
    for (var j = 0; j < x; j++) {
      sum+= nums[j];
    }
    var average = sum / x;
    if (average % 1 > 0) {
      print(-1);
      continue;
    }
    var counter = 0;
    for (var j = 0; j < x; j++) {
      if (nums[j] > average) {
        counter++;
      }
    }
    print(counter);
  }
}

main();

var t = parseInt(readline());

for(i = 0; i < t; i++) {
    var n = parseInt(readline());
    var a = readline().split(" ");
    var sum = 0;
    for(j = 0; j < n; j++) sum += parseInt(a[j]);
    if(sum % n !== 0) print(-1);
    else {
        var count = 0, div = sum / n;
        for(j = 0; j < n; j++) {
            if(parseInt(a[j]) === div) count += 1;
        }
        if(n - count !== 0) print(n - count - 1);
        else print(0);
    }
}

var t = parseInt(readline());

for(i = 0; i < t; i++) {
    var n = parseInt(readline());
    var a = readline().split(" ");
    var sum = a.reduce(function(x, y){
        return parseInt(x) + parseInt(y);
    }, 0);
    if(sum % n !== 0) print(-1);
    else {
        var count = 0, div = sum / n;
        for(j = 0; j < n; j++) {
            if(a[j] == div) count += 1;
        }
        if(n - count !== 0) print(n - count - 1);
        else print(0);
    }
}


var n = readline(); // Number of queues
var ak = readline()
    .split(' ')
    .map(Number); // People in each queue

var bk = ak.map((ai, i) => {
    return i + Math.ceil((ai - i) / n) * n;
});

var minBk = bk[0];
var posAllen = 1;
for(var i = 1; i < n; i++) {
    if(bk[i] < minBk) {
        minBk = bk[i];
        posAllen = (i+1);
    }
}

print(posAllen);

  var n = parseInt(readline());
  var a = readline().split(' ').map(x => parseInt(x));
  var minp = Infinity;
  var minq = Infinity;
  for(var i = 0; i < n; i += 1) {
    var r = 0;
    if(a[i] > i) {
      r += Math.ceil((a[i] - i) / n) * n;
      r += i;
    } else {
      r += i;
    }
    if(r < minq) {
      minq = r;
      minp = i;
    }
  }
  print(minp + 1);

var numQueues = readline();
var queues = readline()
    .split(' ')
    .map(Number);
var queueAllen = 0;

var minQueue = queues.reduce((a,b) => b < a ? b : a);
if(minQueue > numQueues)
queues = queues.map(q => q % numQueues);

while (queues[queueAllen] > 0) {
    queues = queues.map(q => q - 1);
    queueAllen = (queueAllen + 1) % numQueues;
}

print(queueAllen + 1);


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

  let tmp=0, T=0, pairs=[];

  rl.on('line', (input) => {
      if (tmp==0) {T=Number(input); tmp++;}
      else {
          if (tmp<=T){
          let str=input.split(' ').map(a=>{return Number(a);});
            pairs.push(str);
            tmp++;}
          }
    if (tmp>T){ rl.close(); therest();}
    return 0;}
);

let therest=function() {
    for (let i=0; i<T; i++) {
        let l=pairs[i][0], r=pairs[i][1];
        console.log(l, 2*l);

    }
//console.log(T, pairs)
}
//console.log(lngth, str);}

  /*
  rl.question('What do you think of Node.js? ', (answer) => {
    // TODO: Log the answer in a database
    console.log(`Thank you for your valuable feedback: ${answer}`);

    rl.close();
  });*/

//var input = readline()

var t = readline()

for(var i=0; i<t; i++) {
    var arr = readline().split(' ')
    var a = arr[0]
    var b = arr[1]

    print(a +' '+ 2*a)
}

//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↑入力 ↓出力');
	Main();
});
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 tmp = nextIntArray();
    var L = tmp[0];
    var R = tmp[1];
    output[i] = L + " " + (L * 2);
  }
  myout(myconv(output, 9));
}

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

let l = 0;
let n = 0

rl.on('line', (input) => {
    if (l === 0) {
        n = parseInt(input)
    } else {
        if (l === n)
            rl.close();

        let arr = input.split(" ").map(x => parseInt(x))
        console.log(arr[0], arr[0] * 2)

        if (l === n)
            return
    }
    l++
});

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

  let [a, b] = d.split(' ').map(Number);
  console.log(a, 2*a);

  c++;
});

//var input = readline()

var t = readline()

for(var i=0; i<t; i++) {
    var arr = readline().split(' ')
    var a = arr[0]
    var b = arr[1]

    print(a +' '+ a*a)
}


process.stdin.setEncoding("utf8");
let input = "";
process.stdin.on("data", x => input += x);
process.stdin.on("end", () => {
    const [n, k] = input.split(" ").map(Number);
    if (n * k > n * (n - 1) / 2) {
        process.stdout.write("-1\n");
        return;
    }
    let accumulated = "";
    accumulated += String(n * k) + "\n";
    for (let i = 0; i < n; i++)
        for (let j = 1; j <= k; j++)
            accumulated += (String(i + 1) + " " + String((i + j) % n + 1) + "\n");
    process.stdout.write(accumulated);
});

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], 10);
	};
	return tokens;
}

function main() {
	var data = tokenizeIntegers(readline()),
		n = data[0], k = data[1],
		m = n*k;
	if (m > n*(n-1)/2) {
		print(-1);
		return;
	}
	var parts = [m];
	for (var i = 0; i < n; ++i) {
		for (var d = 1; d <= k; ++d) {
			var a = i + 1, b = (i+d)%n + 1;
			parts.push(a+' '+b);
		}
	}
	print(parts.join('\n'));
}

main();

process.stdin.setEncoding("utf8");
let input = "";
process.stdin.on("data", x => input += x);
process.stdin.on("end", () => {
    const [n, k] = input.split(" ").map(Number);
    if (n * k > n * (n - 1) / 2) {
        process.stdout.write("-1\n");
        return;
    }
    process.stdout.write(String(n * k) + "\n");
    for (let i = 0; i < n; i++)
        for (let j = 0; j < k; j++)
            process.stdout.write(String(i + 1) + " " + String((i + j) % n + 1) + "\n");
});


(function() {
    var read = {
        number: function() {
            return +readline();
        },
        arr: function(divider) {
            return readline().split(divider ? divider : '');
        },
        arrNumber: function(divider) {
            return readline()
                .split(divider ? divider : '')
                .map(item => +item);
        }
    }

    var n = read.arrNumber(' ');
    var m = n[1];
    var k = n[2];
    var n = n[0];

    var b = read.arrNumber(' ');

    var arr = [];
    for(var i = 1; i < n; i++) {
        arr.push(b[i] - b[i-1]);
    }

    arr = arr.sort((a, b) => a - b);
    var t = n - k;

    var sum = 0;
    for(var i = 0; i < t; i++) {
        sum += arr[i] - 1;
    }

    print(n + sum);
}());

 const fs = require('fs');
const stdinBuffer = fs.readFileSync(0).toString('utf8');
const [[n, m, k], arr] = stdinBuffer.split('\n').map((line) =>
    line.split(' ').map((ele) => parseInt(ele))
);
const diffArr = arr.map((ele, idx) => (arr[idx + 1] - ele));

diffArr.pop();
diffArr.sort((eleA, eleB) => eleA - eleB);

const diffArrSM = diffArr.slice(0, n - k);
const ans = diffArrSM.reduce((ac, c) => ac + c, 0) + k;

console.log(ans);

const fs = require('fs');
const stdinBuffer = fs.readFileSync(0).toString('utf8');
const [[n, m, k], arr] = stdinBuffer.split('\n').map((line) =>
    line.split(' ').map((ele) => parseInt(ele))
);
const diffArr = arr.map((ele, idx) => (arr[idx + 1] - ele));
const diffArrSM = diffArr.sort((eleA, eleB) => eleA - eleB).slice(0, n - k);
const ans = diffArrSM.reduce((ac, c) => ac + c, 0) + k;

console.log(ans);

const fs = require('fs');
const stdinBuffer = fs.readFileSync(0).toString('utf8');
const [[n, m, k], arr] = stdinBuffer.split('\n').map((line) =>
    line.split(' ').map((ele) => parseInt(ele))
);
const diffArr = arr.map((ele, idx) => (arr[idx + 1] - ele));

diffArr.pop();
diffArr.sort((eleA, eleB) => parseInt(eleA) > parseInt(eleB));

let ans = k;
for (let i = 0; i < n - k; i++) {
    ans += diffArr[i];
}

console.log(ans);

const fs = require('fs');
const stdinBuffer = fs.readFileSync(0).toString('utf8');
const [[n, m, k], arr] = stdinBuffer.split('\n').map((line) =>
    line.split(' ').map((ele) => parseInt(ele))
);
const diffArr = arr.map((ele, idx) => (arr[idx + 1] - ele));

diffArr.pop();
diffArr.sort((eleA, eleB) => Number(eleA) > Number(eleB));

const diffArrSM = diffArr.slice(0, n - k);
const ans = diffArrSM.reduce((ac, c) => ac + c, 0) + k;

console.log(ans);

// Test

 const fs = require('fs');
const stdinBuffer = fs.readFileSync(0).toString('utf8');
const [[n, m, k], arr] = stdinBuffer.split('\n').map((line) =>
    line.split(' ').map((ele) => parseInt(ele))
);
const diffArr = arr.map((ele, idx) => (arr[idx + 1] - ele));

diffArr.pop();
diffArr.sort((eleA, eleB) => Number(eleA) > Number(eleB));

const diffArrSM = diffArr.slice(0, n - k);
const ans = diffArrSM.reduce((ac, c) => ac + c, 0) + k;

if (n > 10000) {
    console.log(diffArr[diffArr.length - 1], diffArr[diffArr.length - 2]);
}

console.log(ans);

 const fs = require('fs');
const stdinBuffer = fs.readFileSync(0).toString('utf8');
const [[n, m, k], arr] = stdinBuffer.split('\n').map((line) =>
    line.split(' ').map((ele) => parseInt(ele))
);
const diffArr = arr.map((ele, idx) => (arr[idx + 1] - ele));

diffArr.pop();
diffArr.sort((eleA, eleB) => Number(eleA) > Number(eleB));

const diffArrSM = diffArr.slice(0, n - k);
const ans = diffArrSM.reduce((ac, c) => ac + c, 0) + k;

if (n > 10000) {
    console.log(diffArr[diffArr.length - 1]);
}

console.log(ans);

const fs = require('fs');
const stdinBuffer = fs.readFileSync(0).toString('utf8');
const [[n, m, k], arr] = stdinBuffer.split('\n').map((line) =>
    line.split(' ').map((ele) => parseInt(ele))
);
const diffArr = arr.map((ele, idx) => ({
    diff: arr[idx + 1] - ele,
    idx: idx,
}));

diffArr.pop();
diffArr.sort((eleA, eleB) => eleA.diff < eleB.diff);

const sepIdxList= diffArr.slice(0, k - 1).map((ele) => ele.idx);
const lastSepIdx = sepIdxList[sepIdxList.length - 1];
const lastSegFirstIdx = sepIdxList.length > 0 ? lastSepIdx + 1 : 0;
let ans = 0;

sepIdxList.forEach((sepIdx, idx) => {
   ans += arr[sepIdx] - arr[idx > 0 ? sepIdxList[idx - 1] + 1 : 0] + 1;
});
ans += arr[n - 1] - arr[lastSegFirstIdx] + 1;

console.log(ans);

const fs = require('fs');
const stdinBuffer = fs.readFileSync(0).toString('utf8');
const [[n, m, k], arr] = stdinBuffer.split('\n').map((line) =>
    line.split(' ').map((ele) => parseInt(ele))
);
const diffArr = arr.map((ele, idx) => (arr[idx + 1] - ele));

diffArr.pop();
diffArr.sort((eleA, eleB) => Number(eleA) > Number(eleB));

let ans = k;
for (let i = 0; i < n - k; i++) {
    ans += diffArr[i];
}

console.log(ans);

 const fs = require('fs');
const stdinBuffer = fs.readFileSync(0).toString('utf8');
const [[n, m, k], arr] = stdinBuffer.split('\n').map((line) =>
    line.split(' ').map((ele) => parseInt(ele))
);
const diffArr = arr.map((ele, idx) => (arr[idx + 1] - ele));

diffArr.pop();
diffArr.sort((eleA, eleB) => parseInt(eleA) > parseInt(eleB));

const diffArrSM = diffArr.slice(0, n - k);
const ans = diffArrSM.reduce((ac, c) => ac + c, 0) + k;

if (n > 10000) {
    console.log(diffArr.slice(0, 100));
}

console.log(ans);

const fs = require('fs');
const stdinBuffer = fs.readFileSync(0).toString('utf8');
const [[n, m, k], arr] = stdinBuffer.split('\n').map((line) =>
    line.split(' ').map((ele) => parseInt(ele))
);
const diffArr = arr.map((ele, idx) => (arr[idx + 1] - ele));
const diffArrSM = diffArr.sort((eleA, eleB) => Number(eleA) > Number(eleB)).slice(0, n - k);
const ans = diffArrSM.reduce((ac, c) => ac + c, 0) + k;

console.log(ans);

 const fs = require('fs');
const stdinBuffer = fs.readFileSync(0).toString('utf8');
const [[n, m, k], arr] = stdinBuffer.split('\n').map((line) =>
    line.split(' ').map((ele) => parseInt(ele))
);
const diffArr = arr.map((ele, idx) => (arr[idx + 1] - ele));

diffArr.pop();
diffArr.sort((eleA, eleB) => Number(eleA) > Number(eleB));

const diffArrSM = diffArr.slice(0, n - k);
const ans = diffArrSM.reduce((ac, c) => ac + c, 0) + k;

if (n > 10000) {
    console.log(arr.length);
}

console.log(ans);

 const fs = require('fs');
const stdinBuffer = fs.readFileSync(0).toString('utf8');
const [[n, m, k], arr] = stdinBuffer.split('\n').map((line) =>
    line.split(' ').map((ele) => parseInt(ele))
);
const diffArr = arr.map((ele, idx) => (arr[idx + 1] - ele));

diffArr.pop();
diffArr.sort((eleA, eleB) => Number(eleA) > Number(eleB));

const diffArrSM = diffArr.slice(0, n - k);
const ans = diffArrSM.reduce((ac, c) => ac + c, 0) + k;

if (n > 10000) {
    console.log(diffArr.slice(0, 100));
}

console.log(ans);


'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', _ => {
    solveWrap(inputString);
});

function solve(s, t){
	let repl = [];
	for (let i = 0; i < t.length; i++) {
		if(t[i]!=s[i]){
			if(repl.length<2)
				repl.push({t: t[i], s: s[i]});
			else
				return false;
		}
	}
	if(repl.length==1)
		return false;
	else if(repl.length==2){
		if(repl[0].t!=repl[1].t || repl[0].s!=repl[1].s)
			return false;
	}
	return true;
}

function solveWrap(input) {
    let inputAr = input.trim().split('\n');
	let k = inputAr.shift();
	for (let i = 0; i < k; i++) {
		inputAr.shift();
		console.log(solve(inputAr.shift().split(''), inputAr.shift().split(''))?'Yes':'No');
	}
}

'use strict'

const problem = (n, s, t) => {
    for (let i = 0; i < n; i++) {
        if (s[i] !== t[i]) {
            for(let j = i + 1; j < n; j++) {
                if (s[j] !== t[j]) {
                    if (s[i] !== s[j] || t[i] !== t[j]) return 'No';
                    for (let k = j + 1; k < n; k++) {
                        if (s[k] !== t[k]) return 'No'
                    }
                    return 'Yes';
                }
            }
            return 'No';
        }
    }
    return 'Yes';
}
let q = +readline();
while(q--) print(problem(+readline(), readline(), 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').map(string => {
        return string.trim();
    });

    main();
});

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

function main() {
    let t = parseInt(readLine());
    for(let tt=0;tt<t;tt++)
    {
        let a = readLine().trim().split(' ').map(string => {return parseInt(string.trim());});
        let n = a[0], k = a[1];
        m = {};
        a = readLine().trim().split(' ').map(string => {return parseInt(string.trim());});
        for(let i=0;i<n;++i){
            if(m[i%k]){
                m[i%k].push(a[i]);
            }else{
                m[i%k] = [a[i]];
            }
        }
        let sum=0;
        for (const [key, value] of Object.entries(m)) {
          sum+=Math.max(...value);
        }
        console.log(sum);
    }
}

var readline = require('readline');
var inputString = [], currentLine = 0;
process.stdin.resume();
process.stdin.setEncoding('utf-8');
var rl = readline.createInterface(process.stdin);
rl.on('line', line => { inputString.push(line) });
process.stdin.on('end', () => {  main()  });

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

function main() {
    const t = +readLine();
    for(let i = 0; i < t; i++){
        // const n = +readLine();
        const n_k = readLine().split(' ').map(p => +p);
        const arr = readLine().split(' ').map(p => +p);
        let result = myFunc(n_k[0], n_k[1], arr);
        console.log(result);
    }
}

function myFunc(n, k, arr){
    let max = new Array(k).fill(0);
    let resp = BigInt(0);

    for(let i = 0; i < n; i++){
        if(arr[i] > max[i%k]) max[i%k] = arr[i];
    }

    for(let i = 0; i < max.length; i++){
        resp += BigInt(max[i])
    }

    return resp.toString();
}

'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 = () => Number(read());
  const n = rn(),
        k = rn(),
        a = new Array(n);
  for (let i = 0; i < n; i++) a[i] = rn();
  let res = 0;
  for (let i = 0; i < k; i++) {
    let ans = 0;
    for (let j = i; j < n; j += k) ans = Math.max(ans, a[j]);
    res += ans;
  }
  return res;
}

function main(r) {
  try {
    let t = Number(r());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      var _solve;
      const s = (_solve = solve(r)) !== null && _solve !== void 0 ? _solve : '';
      if (t < 100) {
        process.stdout.write(s.toString());
        process.stdout.write('\n');
      } else {
        res[i] = s;
      }
    }
    if (t >= 100) {
      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);
}();

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

function getResult(n, k, inputs) {
	let sums = Array(100).fill(0)
	let sum = 0

	let i = j = 0
	while(i < n)
	{
		if(j==k) j=0

		sums[j] = Math.max(inputs[i], sums[j])
		j++
		i++
	}

	for(let i=0; i<k; i++){
		sum += sums[i]
	}

	return sum
}

function main() {
    let testcases = parseInt( readline() )
    while(testcases--){
    	let inputs = readline().split(' ').map(Number)
    	let n = inputs[0]
    	let k = inputs[1]

    	inputs = readline().split(' ').map(Number)

    	let res = getResult(n, k, inputs)
    	console.log( res )
    }
}

"use strict";

const fs = require("fs");
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++];
}

/*
 * Complete the 'decodeString' function below.
 *
 * The function is expected to return an INTEGER.
 * The function accepts 2D_INTEGER_ARRAY arr as parameter.
 */

function getTotal(arr, start, k) {
  const x = arr.slice(start, start + k);
  return x.reduce((prev, curr) => Number(prev) + Number(curr), 0);
}

function consecutive(cases) {
  // Write your code here
  // swap
  for (let i = 0; i < cases.length; i++) {
    const n = Number(cases[i].n);
    const k = Number(cases[i].k);
    const arr = cases[i].arr;
    const consecutiveArr = {};
    for (let j = 0; j < n; j++) {
      consecutiveArr[j % k] = [
        ...(consecutiveArr[j % k] || []),
        Number(arr[j]),
      ].sort((a, b) => b - a);
    }

    // sum
    let sum = 0;
    Object.keys(consecutiveArr).forEach((field) => {
      sum += consecutiveArr[field][0];
    });
    console.log(sum);
  }
}

function main() {
  const t = parseInt(readLine().trim());
  const cases = [];
  for (let i = 1; i <= t * 2; i++) {
    if (i % 2 === 1) {
      const nk = readLine().split(" ");
      cases[Math.ceil(i / 2) - 1] = {
        ...cases[Math.ceil(i / 2) - 1],
        n: nk[0],
        k: nk[1],
      };
    } else {
      const arr = readLine().split(" ");
      cases[Math.ceil(i / 2) - 1] = { ...cases[Math.ceil(i / 2) - 1], arr };
    }
  }

  consecutive(cases);
}

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, k = 0;
    for(i = 1; i <= t * 2; i++){
        var a = lines[i].split(' ').map(Number);
        if(i % 2 == 1){
            n = a[0], k = a[1];
        }else{
            var v = new Array(k);
            for(j = 0; j < k; j++){
                v[j] = 0;
            }
            for(j = 0; j < n; j++){
                v[j % k] = Math.max(v[j % k], a[j]);
            }
            var ans = 0;
            for(j = 0; j < v.length; j++){
                ans += v[j];
            }
            console.log(ans);
        }
    }
});

let buf='';

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

process.stdin.on('end', ()=>{
    let lines=buf.split('\n');
    let lc=0;
    let t=parseInt(lines[lc++]);
    while(t--) {
        let _nk=lines[lc++].split(' ');
        let n=parseInt(_nk[0]),k=parseInt(_nk[1]);
        let _=lines[lc++].split(' ');
        let a=[];
        for(let i=0;i<n;i++) {
            a.push(parseInt(_[i]));
        }
        let ans=0;
        for(let i=0;i<k;i++) {
            let cur=0;
            for(let j=i;j<n;j+=k) {
                cur=Math.max(cur,a[j]);
            }
            ans+=cur;
        }
        console.log(ans);
    }
});

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
const solve = () => {
     let t = parseInt(readline());
     while(t--){
             let [n,k] = readline().trim().split(" ").map(cur=>parseInt(cur));
     let arr = readline().trim().split(" ").map(cur=>parseInt(cur));
     let sum = 0;
     for(let i=0;i<k;i++){
          let max = i;
          for(let j=i+1;j<n;j++){
               if(j%k===i%k){
                    if(arr[j]>arr[max]) max = j
               }
          }
          [arr[i],arr[max]] = [arr[max],arr[i]];
          sum+=arr[i];
     }
     console.log(sum);
     }
};
solve();

const { dir, count } = require("console");
let readline = require("readline");

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

let input = [];
rl.on("line", function (line) {
  input.push(line);

  if (input.length === +input[0] * 2 + 1) {
    // call your function here
    solve(input);
    rl.close();
  }
});

let solve = (input) => {
  for (let testcase = 1; testcase < input.length; testcase += 2) {
    let nk = input[testcase].split(" ");
    let numbers = input[testcase + 1].split(" ");
    let arr = [];
    for (let i = 0; i < numbers.length; i++) {
      let max = 0;
      for (let j = i; j < numbers.length; j += Number(nk[1])) {
        max = Math.max(numbers[j], max);
      }
      arr.push(max);
    }

    let result = 0;

    for (let i = 0; i <= arr.length - Number(nk[1]); i++) {
      let count = 0;

      for (let j = i; j < i + Number(nk[1]); j++) {
        count += arr[j];
      }
      result = Math.max(result, count);
    }

    console.log(result);
  }
};

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

function getResult(n, k, inputs) {
	let res = 0
	let sums = Array(n).fill(0)
	let sum = 0

	for (let i = 0; i < k; i++)
	{
		sum += inputs[i]
	}

	for (let i = 0; i < n; i++)
	{
		let rem = inputs[i] % k
		sums[rem] += inputs[i]
		res = Math.max(res, sums[rem])
	}

	res = Math.max(res, sum)

	for (let i = k; i < n; i++)
	{
		sum = sum - inputs[i - k] + inputs[i]
		res = Math.max(res, sum)
	}

	return res
}

function main() {
    let testcases = parseInt( readline() )
    while(testcases--){
    	let inputs = readline().split(' ').map(Number)
    	let n = inputs[0]
    	let k = inputs[1]

    	inputs = readline().split(' ').map(Number)

    	let res = getResult(n, k, inputs)
    	console.log( res )
    }
}


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

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

function main() {
  let len = +readLine();
  let [i, plusCount, minusCount] = [0, 0, 0];
  const [input, stack, store, ans] = [[], [], [], []];
  while (i++ < 2 * len) {
    const line = readLine();
    if (line.length === 1) {
      sign = line;
      plusCount++;
    } else {
      [sign, num] = line.split(" ");
      store.push(+num);
      minusCount++;
    }
    input.push(sign);
  }

  if (plusCount !== minusCount) {
    console.log("NO");
    return;
  }

  for (let i = 2 * len - 1; i >= 0; i--) {
    const sign = input[i];
    if (sign === "+") {
      if (!stack.length) {
        console.log("NO");
        return;
      } else {
        const top = stack.pop();
        ans.unshift(top);
      }
    } else {
      if (store[store.length - 1] > stack[stack.length - 1]) {
        console.log("NO");
        return;
      } else {
        let n = store.pop();
        stack.push(n);
      }
    }
  }
  console.log("YES");
  console.log(ans.join(" "));
}

#!/usr/bin/env node
'use strict';

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

const buf = [];
const prom = [];
let maxBuf = 0;
let maxProm = 0;
rl.on('line', (line) => {
  if (prom.length > 0) {
    maxProm = Math.max(maxProm, prom.length);
    const [resolve, reject] = prom.shift();
    resolve(line);
  } else {
    rl.pause();
    buf.push(line);
    maxBuf = Math.max(maxBuf, buf.length);
  }
});

rl.on('close', () => {
  // console.error({maxProm, maxBuf});
});

async function getLine() {
  return new Promise((resolve, reject) => {
    if (buf.length > 0) {
      const line = buf.shift();
      resolve(line);
    } else {
      prom.push([resolve, reject]);
      rl.resume();
    }
  });
}

/**
 *
 * @param {Number []} trans
 * @returns {String}
 */
function solve(trans) {
  const stack = [];
  const res = [];
  while (trans.length > 0) {
    const t = trans.pop();
    if (t === 0) {
      if (stack.length < 1) {
        return 'NO';
      }
      res.push(stack.pop());
    } else if (stack.length > 0 && stack[stack.length-1] < t) {
      return 'NO';
    } else {
      stack.push(t);
    }
  }
  res.reverse();
  return 'YES\n' + res.join(' ');
}

async function main() {
  const n = Number(await getLine());
  const trans = [];
  for (let i = 0; i < 2 * n; i++) {
    const l = (await getLine()).split(' ');
    if (l[0] === '+') {
      trans[i] = 0;
    } else {
      trans[i] = Number(l[1]);
    }
  }
  const res = solve(trans);
  console.log(res);
}

if (require.main === module) {
  main();
}


var nElements = +readline();
var elements = readline().split(' ').map(Number);

var index1 = 0;
var index2 = nElements - 1;
var maxSum = 0;
var maxIndex1 = 0;
var maxIndex2 = 0;
var sum1 = elements[0];
var sum2 = elements[index2];

while (index1 < index2) {
    if(sum1 < sum2) {
        index1++;
        sum1 += elements[index1];
    } else if(sum1 === sum2) {
        // Save this case
        maxSum = sum1;
        maxIndex1 = index1;
        maxIndex2 = index2;

        // Search for best case
        index1++;
        index2--;
        sum1 += elements[index1];
        sum2 += elements[index2];
    } else {
        index2--;
        sum2 += elements[index2];
    }
}

print(maxSum);

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

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

function main() {
	let n = readLine() >> 0;
	let arr = readLine()
		.split(' ')
		.map(x => x >> 0);

	let i = 0,
		j = n - 1,
		s1 = 0,
		s3 = 0,
		res = 0;

	while (i <= j) {
		if (s1 <= s3) {
			s1 += arr[i];
			i++;
		} else {
			s3 += arr[j];
			j--;
		}

		if (s1 === s3) res = s1;
	}
	console.log(res);
}

var n = (+ readline ());
var a = readline ();
a = a.trim ().split ( ' ' );
var i;
for ( i = 0; i < n; i ++ ) { a [ i ] = Number ( a [ i ] ); }
var one = [ ];
for ( i = 0; i < n; i ++ ) { one [ i ] = (+ a [ i ]); }
var o = { };
o [ a [ a.length - 1 ] ] = 1;
for ( i = one.length - 2; i >= 0; i -- ) {
    one [ i ] += (+ one [ i + 1 ]);
    o [ one [ i ] ] = 1;
}
var sum = 0;
var curr = 0;
for ( i = 0; i < n; i ++ ) {
    sum += a [ i ];
    delete o [ one [ i ] ];
    if ( sum in o ) curr = sum;
}
print ( curr );

var n = (+ readline ());
var a = readline ();
a = a.trim ().split ( ' ' );
var i;
for ( i = 0; i < n; i ++ ) { a [ i ] = Number ( a [ i ] ); }
var one = [ ];
for ( i = 0; i < n; i ++ ) { one [ i ] = (+ a [ i ]); }
var o = { };
o [ a [ a.length - 1 ] ] = 1;
for ( i = one.length - 2; i > 0; i -- ) {
    one [ i ] += (+ one [ i + 1 ]);
    o [ one [ i ] ] = 1;
}
var sum = 0;
var curr = 0;
for ( i = 0; i < n; i ++ ) {
    sum += a [ i ];
    if ( sum in o ) curr = sum;
    delete o [ one [ i ] ];
}
print ( curr );