You are given an array $$$d_1, d_2, \dots, d_n$$$ consisting of $$$n$$$ integer numbers.Your task is to split this array into three parts (some of which may be empty) in such a way that each element of the array belongs to exactly one of the three parts, and each of the parts forms a consecutive contiguous subsegment (possibly, empty) of the original array. Let the sum of elements of the first part be $$$sum_1$$$, the sum of elements of the second part be $$$sum_2$$$ and the sum of elements of the third part be $$$sum_3$$$. Among all possible ways to split the array you have to choose a way such that $$$sum_1 = sum_3$$$ and $$$sum_1$$$ is maximum possible.More formally, if the first part of the array contains $$$a$$$ elements, the second part of the array contains $$$b$$$ elements and the third part contains $$$c$$$ elements, then:$$$$$$sum_1 = \sum\limits_{1 \le i \le a}d_i,$$$$$$ $$$$$$sum_2 = \sum\limits_{a + 1 \le i \le a + b}d_i,$$$$$$ $$$$$$sum_3 = \sum\limits_{a + b + 1 \le i \le a + b + c}d_i.$$$$$$The sum of an empty array is $$$0$$$.Your task is to find a way to split the array such that $$$sum_1 = sum_3$$$ and $$$sum_1$$$ is maximum possible.

The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of elements in the array $$$d$$$. The second line of the input contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$1 \le d_i \le 10^9$$$) — the elements of the array $$$d$$$.

Print a single integer — the maximum possible value of $$$sum_1$$$, considering that the condition $$$sum_1 = sum_3$$$ must be met. Obviously, at least one valid way to split the array exists (use $$$a=c=0$$$ and $$$b=n$$$).

NoteIn the first example there is only one possible splitting which maximizes $$$sum_1$$$: $$$[1, 3, 1], [~], [1, 4]$$$.In the second example the only way to have $$$sum_1=4$$$ is: $$$[1, 3], [2, 1], [4]$$$.In the third example there is only one way to split the array: $$$[~], [4, 1, 2], [~]$$$.

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

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


Alexander is a well-known programmer. Today he decided to finally go out and play football, but with the first hit he left a dent on the new Rolls-Royce of the wealthy businessman Big Vova. Vladimir has recently opened a store on the popular online marketplace "Zmey-Gorynych", and offers Alex a job: if he shows his programming skills by solving a task, he'll work as a cybersecurity specialist. Otherwise, he'll be delivering some doubtful products for the next two years.You're given $$$n$$$ positive integers $$$a_1, a_2, \dots, a_n$$$. Using each of them exactly at once, you're to make such sequence $$$b_1, b_2, \dots, b_n$$$ that sequence $$$c_1, c_2, \dots, c_n$$$ is lexicographically maximal, where $$$c_i=GCD(b_1,\dots,b_i)$$$ - the greatest common divisor of the first $$$i$$$ elements of $$$b$$$. Alexander is really afraid of the conditions of this simple task, so he asks you to solve it.A sequence $$$a$$$ is lexicographically smaller than a sequence $$$b$$$ if and only if one of the following holds: $$$a$$$ is a prefix of $$$b$$$, but $$$a \ne b$$$; in the first position where $$$a$$$ and $$$b$$$ differ, the sequence $$$a$$$ has a smaller element than the corresponding element in $$$b$$$.

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^3$$$). Description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 10^3$$$)  — the length of the sequence $$$a$$$. The second line of each test case contains $$$n$$$ integers $$$a_1,\dots,a_n$$$ ($$$1 \le a_i \le 10^3$$$)  — the sequence $$$a$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^3$$$.

For each test case output the answer in a single line  — the desired sequence $$$b$$$. If there are multiple answers, print any.

NoteIn the first test case of the example, there are only two possible permutations $$$b$$$  — $$$[2, 5]$$$ and $$$[5, 2]$$$: for the first one $$$c=[2, 1]$$$, for the second one $$$c=[5, 1]$$$.In the third test case of the example, number $$$9$$$ should be the first in $$$b$$$, and $$$GCD(9, 3)=3$$$, $$$GCD(9, 8)=1$$$, so the second number of $$$b$$$ should be $$$3$$$.In the seventh test case of the example, first four numbers pairwise have a common divisor (a power of two), but none of them can be the first in the optimal permutation $$$b$$$.

let input = '';
let inputResolve;
let inputPromise = new Promise(resolve => inputResolve = resolve);
process.stdin.on('data', c => input += c);
process.stdin.on('end', () => inputResolve());

function For(a, b, step, fn) {
  let res;
  for (let i = a; i <= b; i += step) {
    if ((res = fn(i)) != null) return res;
  }
}

function Arr(a, b, step, fn, init) {
  let arr = Array(Math.max(a, b) + 1).fill(0);
  if (init) init(arr);
  for (let i = a; i <= b; i += step) arr[i] = fn(i, arr);
  return arr;
}

Object.defineProperty(Object.prototype, '$k', {
  value: function () { return Object.keys(this) }
});
Object.defineProperty(Object.prototype, '$v', {
  value: function () { return Object.values(this) }
});
Object.defineProperty(Object.prototype, '$kv', {
  value: function () { return Object.entries(this) }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0) }
Array.prototype.uniq = function (fn) {
  var set = new Set();
  return this.filter(v => {
    var newValue = !set.has(fn ? fn(v) : v);
    set.add(fn ? fn(v) : v);
    return newValue;
  });
}
Array.prototype.toObj = function (fn) {
  return this.map(v => fn(v)).reduce((p, v) => {
    p[v[0]] = v[1];
    return p;
  }, {})
}
Array.prototype.min = function (fn) {
  let min = Math.min(...this.map((v, i) => fn ? fn(v, i) : v));
  let i = this.findIndex((v, i) => fn ? fn(v, i) == min : v == min);
  return [this[i], i, min];
}
Array.prototype.max = function (fn) {
  let max = Math.max(...this.map((v, i) => fn ? fn(v, i) : v));
  let i = this.findIndex((v, i) => fn ? fn(v, i) == max : v == max);
  return [this[i], i, max];
}

function gcd(a, b) {
  if (!b) return a;
  return gcd(b, a % b);
}
function mod(a, n, m) {
  if (n == 0n) return 1n;
  if (n % 2n == 0n) return mod(a * a % m, n / 2n, m);
  return a * mod(a, n - 1n, m) % m;
}
function extendedEuclid(a, b) {
  if (!b) return [1, 0];
  else {
    let [x, y] = extendedEuclid(b, a % b);
    return [y, x - (a / b | 0) * y];
  }
}
// [m] = extendedEuclid(a, 998244353);
// let MOD = 998244353n;
// let gt = Arr(0, n, (i, a) => i == 0 ? 1n : a[i - 1] * BigInt(i) % MOD);
// let rgt = Arr(0, n, (i, a) => i <= 1 ? 1n : MOD - MOD / BigInt(i) * a[998244353 % i] % MOD);
// for (let i = 2; i < n; i++) rgt[i] = rgt[i] * rgt[i - 1] % MOD;
// let nCk = (n, k) => {
//   return gt[n] * rgt[k] * rgt[n - k] % MOD;
// }
// for (let i = dm[l.l]; i <= n + n; i += i & -i) s[i]++; // start from index 1

(async () => {
  await inputPromise;
  let inp = input.split(/\s+/).map(v => +v), _i = 0, $ = n => n != null ? inp.slice(_i, _i += n) : inp[_i++], out = [], log = console.log;
  let t = $()
  while (t--) {
    let n = $()
    let a = $(n).sort((a, b) => b - a);
    let c = a[0]
    For(1, n - 1, 1, i => {
      let [, j] = Arr(i, n - 1, 1, j => gcd(c, a[j])).max();
      [a[i], a[j]] = [a[j], a[i]];
      c = gcd(c, a[i]);
    });
    log(a.join(' '))
  }
})();

let input = '';
let inputResolve;
let inputPromise = new Promise(resolve => inputResolve = resolve);
process.stdin.on('data', c => input += c);
process.stdin.on('end', () => inputResolve());

function For(a, b, step, fn) {
  let res;
  for (let i = a; i <= b; i += step) {
    if ((res = fn(i)) != null) return res;
  }
}

function Arr(a, b, step, fn, init) {
  let arr = Array(Math.max(a, b) + 1).fill(0);
  if (init) init(arr);
  for (let i = a; i <= b; i += step) arr[i] = fn(i, arr);
  return arr;
}

Object.defineProperty(Object.prototype, '$k', {
  value: function () { return Object.keys(this) }
});
Object.defineProperty(Object.prototype, '$v', {
  value: function () { return Object.values(this) }
});
Object.defineProperty(Object.prototype, '$kv', {
  value: function () { return Object.entries(this) }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0) }
Array.prototype.uniq = function (fn) {
  var set = new Set();
  return this.filter(v => {
    var newValue = !set.has(fn ? fn(v) : v);
    set.add(fn ? fn(v) : v);
    return newValue;
  });
}
Array.prototype.toObj = function (fn) {
  return this.map(v => fn(v)).reduce((p, v) => {
    p[v[0]] = v[1];
    return p;
  }, {})
}
Array.prototype.min = function (fn) {
  let min = Math.min(...this.map((v, i) => fn ? fn(v, i) : v));
  let i = this.findIndex((v, i) => fn ? fn(v, i) == min : v == min);
  return [this[i], i, min];
}
Array.prototype.max = function (fn) {
  let max = Math.max(...this.map((v, i) => fn ? fn(v, i) : v));
  let i = this.findIndex((v, i) => fn ? fn(v, i) == max : v == max);
  return [this[i], i, max];
}

function gcd(a, b) {
  if (!b) return a;
  return gcd(b, a % b);
}
function mod(a, n, m) {
  if (n == 0n) return 1n;
  if (n % 2n == 0n) return mod(a * a % m, n / 2n, m);
  return a * mod(a, n - 1n, m) % m;
}
function extendedEuclid(a, b) {
  if (!b) return [1, 0];
  else {
    let [x, y] = extendedEuclid(b, a % b);
    return [y, x - (a / b | 0) * y];
  }
}
// [m] = extendedEuclid(a, 998244353);
// let MOD = 998244353n;
// let gt = Arr(0, n, (i, a) => i == 0 ? 1n : a[i - 1] * BigInt(i) % MOD);
// let rgt = Arr(0, n, (i, a) => i <= 1 ? 1n : MOD - MOD / BigInt(i) * a[998244353 % i] % MOD);
// for (let i = 2; i < n; i++) rgt[i] = rgt[i] * rgt[i - 1] % MOD;
// let nCk = (n, k) => {
//   return gt[n] * rgt[k] * rgt[n - k] % MOD;
// }
// for (let i = dm[l.l]; i <= n + n; i += i & -i) s[i]++; // start from index 1

(async () => {
  await inputPromise;
  let inp = input.split(/\s+/).map(v => +v), _i = 0, $ = n => n != null ? inp.slice(_i, _i += n) : inp[_i++], out = [], log = console.log;
  let t = $()
  while (t--) {
    let n = $()
    let a = $(n).sort((a, b) => b - a);
    let c = a[0]
    For(1, n - 1, 1, i => {
      let [, j] = Arr(i, n - 1, 1, j => gcd(c, a[j])).max()
      let temp = a[i];
      a[i] = a[j];
      a[j] = temp;
      c = gcd(c, a[i]);
    });
    console.log(a.join(' '))
  }
})();

let input = '';
let inputResolve;
let inputPromise = new Promise(resolve => inputResolve = resolve);
process.stdin.on('data', c => input += c);
process.stdin.on('end', () => inputResolve());

function For(a, b, step, fn) {
  let res;
  for (let i = a; i <= b; i += step) {
    if ((res = fn(i)) != null) return res;
  }
}

function Arr(a, b, step, fn, init) {
  if (!step) {
    return a < b
      ? Array(b - a + 1).fill(0).map((v, i) => fn(a + i))
      : Array(a - b + 1).fill(0).map((v, i) => fn(a - i))
  }
  let arr = Array(Math.max(a, b) + 1).fill(0);
  if (init) init(arr);
  for (let i = a; i <= b; i += step) arr[i] = fn(i, arr);
  return arr;
}

Object.defineProperty(Object.prototype, '$k', {
  value: function () { return Object.keys(this) }
});
Object.defineProperty(Object.prototype, '$v', {
  value: function () { return Object.values(this) }
});
Object.defineProperty(Object.prototype, '$kv', {
  value: function () { return Object.entries(this) }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0) }
Array.prototype.uniq = function (fn) {
  var set = new Set();
  return this.filter(v => {
    var newValue = !set.has(fn ? fn(v) : v);
    set.add(fn ? fn(v) : v);
    return newValue;
  });
}
Array.prototype.toObj = function (fn) {
  return this.map(v => fn(v)).reduce((p, v) => {
    p[v[0]] = v[1];
    return p;
  }, {})
}
Array.prototype.min = function (fn) {
  let min = Math.min(...this.map((v, i) => fn ? fn(v, i) : v));
  let i = this.findIndex((v, i) => fn ? fn(v, i) == min : v == min);
  return [this[i], i, min];
}
Array.prototype.max = function (fn) {
  let max = Math.max(...this.map((v, i) => fn ? fn(v, i) : v));
  let i = this.findIndex((v, i) => fn ? fn(v, i) == max : v == max);
  return [this[i], i, max];
}

function gcd(a, b) {
  if (!b) return a;
  return gcd(b, a % b);
}
function mod(a, n, m) {
  if (n == 0n) return 1n;
  if (n % 2n == 0n) return mod(a * a % m, n / 2n, m);
  return a * mod(a, n - 1n, m) % m;
}
function extendedEuclid(a, b) {
  if (!b) return [1, 0];
  else {
    let [x, y] = extendedEuclid(b, a % b);
    return [y, x - (a / b | 0) * y];
  }
}
// [m] = extendedEuclid(a, 998244353);
// let MOD = 998244353n;
// let gt = Arr(0, n, (i, a) => i == 0 ? 1n : a[i - 1] * BigInt(i) % MOD);
// let rgt = Arr(0, n, (i, a) => i <= 1 ? 1n : MOD - MOD / BigInt(i) * a[998244353 % i] % MOD);
// for (let i = 2; i < n; i++) rgt[i] = rgt[i] * rgt[i - 1] % MOD;
// let nCk = (n, k) => {
//   return gt[n] * rgt[k] * rgt[n - k] % MOD;
// }
// for (let i = dm[l.l]; i <= n + n; i += i & -i) s[i]++; // start from index 1

(async () => {
  await inputPromise;
  let inp = input.split(/\s+/).map(v => +v), _i = 0, $ = n => n != null ? inp.slice(_i, _i += n) : inp[_i++],
    out = [], log = console.log, asc = (a, b) => a - b, desc = (a, b) => b - a;
  let t = $()
  while (t--) {
    let n = $()
    let a = $(n).sort(desc);
    let c = a[0]
    For(1, n - 1, 1, i => {
      let j = Arr(i, n - 1, 1, j => gcd(c, a[j])).max()[1];
      [a[i], a[j]] = [a[j], a[i]];
      c = gcd(c, a[i]);
    });
    log(a.join(' '))
  }
})();


You found a painting on a canvas of size $$$n \times m$$$. The canvas can be represented as a grid with $$$n$$$ rows and $$$m$$$ columns. Each cell has some color. Cell $$$(i, j)$$$ has color $$$c_{i,j}$$$.Near the painting you also found a brush in the shape of a $$$2 \times 2$$$ square, so the canvas was surely painted in the following way: initially, no cell was painted. Then, the following painting operation has been performed some number of times:  Choose two integers $$$i$$$ and $$$j$$$ ($$$1 \le i < n$$$, $$$1 \le j < m$$$) and some color $$$k$$$ ($$$1 \le k \le nm$$$).  Paint cells $$$(i, j)$$$, $$$(i + 1, j)$$$, $$$(i, j + 1)$$$, $$$(i + 1, j + 1)$$$ in color $$$k$$$. All cells must be painted at least once. A cell can be painted multiple times. In this case, its final color will be the last one.Find any sequence of at most $$$nm$$$ operations that could have led to the painting you found or state that it's impossible.

The first line of input contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 1000$$$) — the dimensions of the canvas. On the $$$i$$$-th of the next $$$n$$$ lines of input, there will be $$$m$$$ integers. The $$$j$$$-th of them is $$$a_{i,j}$$$ ($$$1 \le a_{i,j} \le nm$$$) — the color of cell $$$(i, j)$$$.

If there is no solution, print a single integer $$$-1$$$. Otherwise, on the first line, print one integer $$$q$$$ ($$$1 \le q \le nm$$$) — the number of operations. Next, print the operations in order. On the $$$k$$$-th of the next $$$q$$$ lines, print three integers $$$i$$$, $$$j$$$, $$$c$$$ ($$$1 \le i < n$$$, $$$1 \le j < m$$$, $$$1 \le c \le nm$$$) — the description of the $$$k$$$-th operation. If there are multiple solutions, print any.

NoteIn the first test case, the solution is not unique. Here's one of them:  In the second test case, there is no way one could obtain the given painting, thus the answer is $$$-1$$$.

'use strict';
 /*jslint node:true, browser:true, es6:true*/
const print = console.log
const E = {};
const lines = []
if (!process.env.JEST_WORKER_ID){
  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;
function readline() {
    return lines[rli++];
}
const L = process.env.DEBUG ? console.log : ()=>{};

module.exports = E;
const ra = ()=>readline().split(' ').map(a=>+a)

const s = (i, j)=>i*10000+j;

const calc = (n, m, A)=>{
  let ops = [];
  let painted = new Set();
  let queue = [], qi = 0;
  for (let i=0; i<n-1; i++){
    for (let j=0; j<m-1; j++){
      let c00 = A[i][j];
      let c01 = A[i][j+1];
      let c10 = A[i+1][j];
      let c11 = A[i+1][j+1];
      if (c00==c01 && c01==c10 && c10==c11){
        if (!painted.has(s(i,j)) &&
          !painted.has(s(i,j+1)) &&
          !painted.has(s(i+1,j)) &&
          !painted.has(s(i+1, j+1))){
            painted.add(s(i,j));
            painted.add(s(i,j+1));
            painted.add(s(i+1,j));
            painted.add(s(i+1,j+1));
            queue.push([i, j]);
            ops.push(`${i+1} ${j+1} ${c00}`);
          }
      }
    }
  }
  const is_valid = (i, j)=>{
    if (i<0 || j<0)
      return false;
    if (i>=n-1 || j>=m-1)
      return false;
    let free_colors = [];
    if (!painted.has(s(i, j))){
      free_colors.push(A[i][j])
    }
    if (!painted.has(s(i, j+1))){
      free_colors.push(A[i][j+1])
    }
    if (!painted.has(s(i+1, j))){
      free_colors.push(A[i+1][j])
    }
    if (!painted.has(s(i+1, j+1))){
      free_colors.push(A[i+1][j+1])
    }
    if (!free_colors.length)
      return false;
    free_colors.sort((a, b)=>a-b);
    if (free_colors[0]==free_colors[free_colors.length-1])
      return free_colors[0];
  };
  //L({painted, queue});
  while (qi<queue.length){
    let [i, j] = queue[qi++];
    for (let bi=i-1; bi<=i+1; bi++){
      for (let bj=j-1; bj<=j+1; bj++){
        let color;
        if (color = is_valid(bi, bj)){
            painted.add(s(bi,bj));
            painted.add(s(bi,bj+1));
            painted.add(s(bi+1,bj));
            painted.add(s(bi+1,bj+1));
            ops.push(`${bi+1} ${bj+1} ${color}`);
            queue.push([bi, bj])
        }
      }
    }
  }
  if (painted.size!=n*m)
    return print(-1)
  print(ops.length);
  print(ops.reverse().join('\n'));
};

function main() {
    let T = 1||+readline()
    while (T--){
      let [n, m] = ra();
      let A = [];
      for (let i=0; i<n; i++)
        A.push(ra())
      L('Ans:')
      calc(n, m, A);
    }
}

E.calc = calc;

'use strict';
 /*jslint node:true, browser:true, es6:true*/
const print = console.log
const E = {};
const lines = []
if (!process.env.JEST_WORKER_ID){
  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;
function readline() {
    return lines[rli++];
}
const L = process.env.DEBUG ? console.log : ()=>{};

module.exports = E;
const ra = ()=>readline().split(' ').map(a=>+a)

const s = (i, j)=>i+';'+j; // optimize

const calc = (n, m, A)=>{
  let ops = [];
  let painted = new Set();
  let queue = [], qi = 0;
  for (let i=0; i<n-1; i++){
    for (let j=0; j<m-1; j++){
      let c00 = A[i][j];
      let c01 = A[i][j+1];
      let c10 = A[i+1][j];
      let c11 = A[i+1][j+1];
      if (c00==c01 && c01==c10 && c10==c11){
        if (!painted.has(s(i,j)) &&
          !painted.has(s(i,j+1)) &&
          !painted.has(s(i+1,j)) &&
          !painted.has(s(i+1, j+1))){
            painted.add(s(i,j));
            painted.add(s(i,j+1));
            painted.add(s(i+1,j));
            painted.add(s(i+1,j+1));
            queue.push([i, j]);
            ops.push(`${i+1} ${j+1} ${c00}`);
          }
      }
    }
  }
  const is_valid = (i, j)=>{
    if (i<0 || j<0)
      return false;
    if (i>=n-1 || j>=m-1)
      return false;
    let free_colors = [];
    if (!painted.has(s(i, j))){
      painted.add(s(i, j))
      free_colors.push(A[i][j])
    }
    if (!painted.has(s(i, j+1))){
      painted.add(s(i, j+1))
      free_colors.push(A[i][j+1])
    }
    if (!painted.has(s(i+1, j))){
      painted.add(s(i+1, j))
      free_colors.push(A[i+1][j])
    }
    if (!painted.has(s(i+1, j+1))){
      painted.add(s(i+1, j+1))
      free_colors.push(A[i+1][j+1])
    }
    if (!free_colors.length)
      return false;
    free_colors.sort((a, b)=>a-b);
    if (free_colors[0]==free_colors[free_colors.length-1])
      return free_colors[0];
  };
  L({painted, queue});
  while (qi<queue.length){
    let [i, j] = queue[qi++];
    for (let bi=i-1; bi<=i+1; bi++){
      for (let bj=j-1; bj<=j+1; bj++){
        let color;
        if (color = is_valid(bi, bj)){
            painted.add(s(bi,bj));
            painted.add(s(bi,bj+1));
            painted.add(s(bi+1,bj));
            painted.add(s(bi+1,bj+1));
            ops.push(`${bi+1} ${bj+1} ${color}`);
            queue.push([bi, bj])
        }
      }
    }
  }
  return ops.reverse().join('\n')
};

function main() {
    let T = 1||+readline()
    while (T--){
      let [n, m] = ra();
      let A = [];
      for (let i=0; i<n; i++)
        A.push(ra())
      L('Ans:')
      print(calc(n, m, A));
    }
}

E.calc = calc;


One day n friends gathered together to play "Mafia". During each round of the game some player must be the supervisor and other n - 1 people take part in the game. For each person we know in how many rounds he wants to be a player, not the supervisor: the i-th person wants to play ai rounds. What is the minimum number of rounds of the "Mafia" game they need to play to let each person play at least as many rounds as they want?

The first line contains integer n (3 ≤ n ≤ 105). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the i-th number in the list is the number of rounds the i-th person wants to play.

In a single line print a single integer — the minimum number of game rounds the friends need to let the i-th person play at least ai rounds. Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.

NoteYou don't need to know the rules of "Mafia" to solve this problem. If you're curious, it's a game Russia got from the Soviet times: http://en.wikipedia.org/wiki/Mafia_(party_game).

//белый снег
//белый porshe
//белый trash
//в бонге воск
var input = readline().split(' ');
var n = parseInt(input[0]);
input = readline().split(' ');
var ar = [], mx = 0, sum = 0;
for(var i = 0; i < n; ++i)
{
    sum += parseInt(input[i]);
    mx = Math.max(mx, parseInt(input[i]));
}
print(Math.max(mx, Math.ceil(sum/(n-1))));


It's election time in Berland. The favorites are of course parties of zublicanes and mumocrates. The election campaigns of both parties include numerous demonstrations on n main squares of the capital of Berland. Each of the n squares certainly can have demonstrations of only one party, otherwise it could lead to riots. On the other hand, both parties have applied to host a huge number of demonstrations, so that on all squares demonstrations must be held. Now the capital management will distribute the area between the two parties.Some pairs of squares are connected by (n - 1) bidirectional roads such that between any pair of squares there is a unique way to get from one square to another. Some squares are on the outskirts of the capital meaning that they are connected by a road with only one other square, such squares are called dead end squares.The mayor of the capital instructed to distribute all the squares between the parties so that the dead end squares had the same number of demonstrations of the first and the second party. It is guaranteed that the number of dead end squares of the city is even.To prevent possible conflicts between the zublicanes and the mumocrates it was decided to minimize the number of roads connecting the squares with the distinct parties. You, as a developer of the department of distributing squares, should determine this smallest number.

The first line of the input contains a single integer n (2 ≤ n ≤ 5000) — the number of squares in the capital of Berland. Next n - 1 lines contain the pairs of integers x, y (1 ≤ x, y ≤ n, x ≠ y) — the numbers of the squares connected by the road. All squares are numbered with integers from 1 to n. It is guaranteed that the number of dead end squares of the city is even.

Print a single number — the minimum number of roads connecting the squares with demonstrations of different parties.

/******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};

/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {

/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId])
/******/ 			return installedModules[moduleId].exports;

/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			exports: {},
/******/ 			id: moduleId,
/******/ 			loaded: false
/******/ 		};

/******/ 		// Execute the module function
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);

/******/ 		// Flag the module as loaded
/******/ 		module.loaded = true;

/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}

/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = modules;

/******/ 	// expose the module cache
/******/ 	__webpack_require__.c = installedModules;

/******/ 	// __webpack_public_path__
/******/ 	__webpack_require__.p = "";

/******/ 	// Load entry module and return exports
/******/ 	return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports, __webpack_require__) {

	var Prelude_1 = __webpack_require__(1);
	var List = __webpack_require__(2);
	var Graph_1 = __webpack_require__(3);
	var n = List.map(parseInt, readline().split(' '))[0];
	var tree = new Graph_1.Graph(n);
	for (var i = 0; i < n - 1; i++) {
	    var _a = List.map(parseInt, readline().split(' ')), a = _a[0], b = _a[1];
	    tree.addEdge({ source: a - 1, target: b - 1 });
	    tree.addEdge({ source: b - 1, target: a - 1 });
	}
	function findroot() {
	    for (var i = 0; i < n; i++) {
	        if (tree.adjacent(i).length > 1)
	            return i;
	    }
	    return 0;
	}
	var leaves = List.replicate(n, 0);
	function countleaves(node, parent) {
	    var adj = tree.adjacent(node);
	    if (adj.length == 1) {
	        leaves[node] = 1;
	    }
	    else {
	        for (var i = 0; i < adj.length; i++) {
	            if (adj[i].target !== parent) {
	                leaves[node] += countleaves(adj[i].target, node);
	            }
	        }
	    }
	    return leaves[node];
	}
	function combine(parent, child) {
	    var p = parent[0].length;
	    var c = child[0].length;
	    for (var i = p - 1; i >= 0; i--) {
	        var x0 = n;
	        var x1 = n;
	        for (var j = 0; j < c && j <= i; j++) {
	            x0 = Prelude_1.min(x0, parent[0][i - j] + Prelude_1.min(child[0][j], child[1][j] + 1));
	            x1 = Prelude_1.min(x1, parent[1][i - j] + Prelude_1.min(child[0][j] + 1, child[1][j]));
	        }
	        parent[0][i] = x0;
	        parent[1][i] = x1;
	    }
	}
	function solve(node, parent) {
	    var adj = tree.adjacent(node);
	    var m = leaves[node];
	    var needed = List.map(function (_) { return List.replicate(m + 1, n); }, [0, 0]);
	    if (adj.length == 1) {
	        needed[0][1] = 0;
	        needed[1][0] = 0;
	        return needed;
	    }
	    var first = true;
	    for (var i = 0; i < adj.length; i++) {
	        if (adj[i].target !== parent) {
	            var x = solve(adj[i].target, node);
	            var c = x[0].length;
	            if (first) {
	                for (var i_1 = 0; i_1 < c; i_1++) {
	                    needed[0][i_1] = Prelude_1.min(x[0][i_1], x[1][i_1] + 1);
	                    needed[1][i_1] = Prelude_1.min(x[1][i_1], x[0][i_1] + 1);
	                }
	                first = false;
	            }
	            else {
	                combine(needed, x);
	            }
	        }
	    }
	    return needed;
	}
	if (n == 2) {
	    print(1);
	}
	else {
	    var root = findroot();
	    var m = countleaves(root, -1);
	    var needed = solve(root, -1);
	    print(Prelude_1.min(needed[0][m / 2], needed[1][m / 2]));
	}

/***/ },
/* 1 */
/***/ function(module, exports) {

	function min(a, b) {
	    return a < b ? a : b;
	}
	exports.min = min;
	function max(a, b) {
	    return a < b ? b : a;
	}
	exports.max = max;
	function curry(f) {
	    return function (x) { return function (y) { return f(x, y); }; };
	}
	exports.curry = curry;
	function uncurry(f) {
	    return function (x, y) { return f(x)(y); };
	}
	exports.uncurry = uncurry;
	function id(x) {
	    return x;
	}
	exports.id = id;
	function constant(x) {
	    return function (_) { return x; };
	}
	exports.constant = constant;
	function flip(f) {
	    return function (y) { return function (x) { return f(x)(y); }; };
	}
	exports.flip = flip;
	function flip2(f) {
	    return function (y, x) { return f(x, y); };
	}
	exports.flip2 = flip2;
	function compose(g, f) {
	    return function (x) { return g(f(x)); };
	}
	exports.compose = compose;

/***/ },
/* 2 */
/***/ function(module, exports, __webpack_require__) {

	var Prelude_1 = __webpack_require__(1);
	function add(xs, ys) {
	    return xs.concat(ys);
	}
	exports.add = add;
	function head(xs) {
	    return xs[0];
	}
	exports.head = head;
	function last(xs) {
	    return xs[xs.length - 1];
	}
	exports.last = last;
	function tail(xs) {
	    return xs.slice(1);
	}
	exports.tail = tail;
	function init(xs) {
	    return xs.slice(0, xs.length - 1);
	}
	exports.init = init;
	function map(f, xs) {
	    var result = new Array(xs.length);
	    for (var i = 0; i < xs.length; i++) {
	        result[i] = f(xs[i]);
	    }
	    return result;
	}
	exports.map = map;
	function reverse(xs) {
	    return xs.slice().reverse();
	}
	exports.reverse = reverse;
	function intersperse(x, xs) {
	    if (xs.length == 0) {
	        return [];
	    }
	    var result = new Array(xs.length + xs.length - 1);
	    for (var i = 0; i + 1 < xs.length; i++) {
	        result[i + i] = xs[i];
	        result[i + i + 1] = x;
	    }
	    result[result.length - 1] = xs[xs.length - 1];
	    return result;
	}
	exports.intersperse = intersperse;
	function intercalate(xs, xss) {
	    return concat(intersperse(xs, xss));
	}
	exports.intercalate = intercalate;
	function foldl(f, initial, xs) {
	    var result = initial;
	    for (var i = 0; i < xs.length; i++) {
	        result = f(result, xs[i]);
	    }
	    return result;
	}
	exports.foldl = foldl;
	function foldr(f, initial, xs) {
	    var result = initial;
	    for (var i = xs.length - 1; i >= 0; i--) {
	        result = f(xs[i], result);
	    }
	    return result;
	}
	exports.foldr = foldr;
	function concat(xss) {
	    var total = sum(map(function (xs) { return xs.length; }, xss));
	    var result = new Array(total);
	    var m = 0;
	    for (var i = 0; i < xss.length; i++) {
	        var xs = xss[i];
	        for (var j = 0; j < xs.length; j++) {
	            result[m++] = xs[j];
	        }
	    }
	    return result;
	}
	exports.concat = concat;
	function sum(xs) {
	    var result = 0;
	    for (var i = 0; i < xs.length; i++) {
	        result += xs[i];
	    }
	    return result;
	}
	exports.sum = sum;
	function product(xs) {
	    var result = 1;
	    for (var i = 0; i < xs.length; i++) {
	        result *= xs[i];
	    }
	    return result;
	}
	exports.product = product;
	function maximum(xs) {
	    var result = xs[0];
	    for (var i = 1; i < xs.length; i++) {
	        if (result < xs[i])
	            result = xs[i];
	    }
	    return result;
	}
	exports.maximum = maximum;
	function minimum(xs) {
	    var result = xs[0];
	    for (var i = 1; i < xs.length; i++) {
	        if (result > xs[i])
	            result = xs[i];
	    }
	    return result;
	}
	exports.minimum = minimum;
	function replicate(n, x) {
	    var result = new Array(n);
	    for (var i = 0; i < result.length; i++) {
	        result[i] = x;
	    }
	    return result;
	}
	exports.replicate = replicate;
	function take(n, xs) {
	    return xs.slice(0, n);
	}
	exports.take = take;
	function drop(n, xs) {
	    return xs.slice(n);
	}
	exports.drop = drop;
	function splitAt(n, xs) {
	    return [take(n, xs), drop(n, xs)];
	}
	exports.splitAt = splitAt;
	function takeWhile(f, xs) {
	    for (var i = 0; i < xs.length; i++) {
	        if (!f(xs[i])) {
	            return xs.slice(0, i);
	        }
	    }
	    return xs.slice();
	}
	exports.takeWhile = takeWhile;
	function dropWhile(f, xs) {
	    for (var i = 0; i < xs.length; i++) {
	        if (!f(xs[i])) {
	            return xs.slice(i);
	        }
	    }
	    return [];
	}
	exports.dropWhile = dropWhile;
	function group(xs) {
	    if (xs.length == 0) {
	        return [];
	    }
	    var result = [];
	    var last = [xs[0]];
	    for (var i = 1; i < xs.length; i++) {
	        if (last[0] === xs[i]) {
	            last.push(xs[i]);
	        }
	        else {
	            result.push(last);
	            last = [xs[i]];
	        }
	    }
	    result.push(last);
	    return result;
	}
	exports.group = group;
	function filter(f, xs) {
	    var result = [];
	    for (var i = 0; i < xs.length; i++) {
	        if (f(xs[i]))
	            result.push(xs[i]);
	    }
	    return result;
	}
	exports.filter = filter;
	function zip(xs, ys) {
	    var n = Prelude_1.min(xs.length, ys.length);
	    var result = new Array(n);
	    for (var i = 0; i < n; i++) {
	        result[i] = [xs[i], ys[i]];
	    }
	    return result;
	}
	exports.zip = zip;
	function unzip(xs) {
	    var r1 = new Array(xs.length);
	    var r2 = new Array(xs.length);
	    for (var i = 0; i < xs.length; i++) {
	        r1[i] = xs[i][0];
	        r2[i] = xs[i][1];
	    }
	    return [r1, r2];
	}
	exports.unzip = unzip;
	function range(from, to) {
	    var result = Array(to - from + 1);
	    for (var i = from; i <= to; i++) {
	        result[i - from] = i;
	    }
	    return result;
	}
	exports.range = range;
	function copy(xs) {
	    return xs.slice(0);
	}
	exports.copy = copy;
	function apply_permutation(p, xs) {
	    var n = xs.length;
	    var result = new Array(n);
	    for (var i = 0; i < n; i++) {
	        result[i] = xs[p[i]];
	    }
	    return result;
	}
	exports.apply_permutation = apply_permutation;
	function next_permutation(p) {
	    var n = p.length;
	    if (n < 2)
	        return null;
	    var r = copy(p);
	    var k = n - 2;
	    for (; k >= 0 && r[k] >= r[k + 1]; k--)
	        ;
	    if (k < 0)
	        return null;
	    for (var i = k + 1, j = n - 1; i < j; i++, j--) {
	        var t_1 = r[i];
	        r[i] = r[j];
	        r[j] = t_1;
	    }
	    var next = k + 1;
	    for (; r[next] <= r[k]; next++)
	        ;
	    var t = r[k];
	    r[k] = r[next];
	    r[next] = t;
	    return r;
	}
	exports.next_permutation = next_permutation;

/***/ },
/* 3 */
/***/ function(module, exports, __webpack_require__) {

	var List = __webpack_require__(2);
	var Graph = (function () {
	    function Graph(size) {
	        this.size = size;
	        this.adjacency = List.map(function (_) { return []; }, new Array(size));
	    }
	    Graph.prototype.fromEdges = function (edges) {
	        for (var _i = 0; _i < edges.length; _i++) {
	            var e = edges[_i];
	            this.addEdge(e);
	        }
	    };
	    Graph.prototype.addEdge = function (edge) {
	        this.adjacency[edge.source].push(edge);
	    };
	    Graph.prototype.adjacent = function (source) {
	        return this.adjacency[source];
	    };
	    Graph.prototype.map = function (source, f) {
	        var edges = this.adjacent(source);
	        for (var i = 0; i < edges.length; i++) {
	            edges[i] = f(edges[i]);
	        }
	    };
	    Graph.prototype.forEach = function (source, f) {
	        var edges = this.adjacent(source);
	        for (var i = 0; i < edges.length; i++) {
	            f(edges[i]);
	        }
	    };
	    Graph.prototype.dfs = function (source) {
	        var mark = List.map(function (_) { return 0; }, new Array(this.size));
	        var time = 1;
	        function go(node) {
	            if (mark[node] !== 0)
	                return;
	            mark[node] = time++;
	            this.forEach(node, function (edge) { return go(edge.target); });
	        }
	        go(source);
	        return mark;
	    };
	    return Graph;
	})();
	exports.Graph = Graph;

/***/ }
/******/ ]);

/******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};

/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {

/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId])
/******/ 			return installedModules[moduleId].exports;

/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			exports: {},
/******/ 			id: moduleId,
/******/ 			loaded: false
/******/ 		};

/******/ 		// Execute the module function
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);

/******/ 		// Flag the module as loaded
/******/ 		module.loaded = true;

/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}

/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = modules;

/******/ 	// expose the module cache
/******/ 	__webpack_require__.c = installedModules;

/******/ 	// __webpack_public_path__
/******/ 	__webpack_require__.p = "";

/******/ 	// Load entry module and return exports
/******/ 	return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports, __webpack_require__) {

	var Prelude_1 = __webpack_require__(1);
	var List = __webpack_require__(2);
	var Graph_1 = __webpack_require__(3);
	var n = List.map(parseInt, readline().split(' '))[0];
	var tree = new Graph_1.Graph(n);
	for (var i = 0; i < n - 1; i++) {
	    var _a = List.map(parseInt, readline().split(' ')), a = _a[0], b = _a[1];
	    tree.addEdge({ source: a - 1, target: b - 1 });
	    tree.addEdge({ source: b - 1, target: a - 1 });
	}
	function findroot() {
	    for (var i = 0; i < n; i++) {
	        if (tree.adjacent(i).length > 1)
	            return i;
	    }
	    return 0;
	}
	var leaves = List.replicate(n, 0);
	function countleaves(node, parent) {
	    var adj = tree.adjacent(node);
	    if (adj.length == 1) {
	        leaves[node] = 1;
	    }
	    else {
	        for (var i = 0; i < adj.length; i++) {
	            if (adj[i].target !== parent) {
	                leaves[node] += countleaves(adj[i].target, node);
	            }
	        }
	    }
	    return leaves[node];
	}
	function combine(parent, child) {
	    var p = parent[0].length;
	    var c = child[0].length;
	    for (var i = p - 1; i >= 0; i--) {
	        var x0 = n;
	        var x1 = n;
	        for (var j = 0; j < c && j <= i; j++) {
	            x0 = Prelude_1.min(x0, parent[0][i - j] + Prelude_1.min(child[0][j], child[1][j] + 1));
	            x1 = Prelude_1.min(x1, parent[1][i - j] + Prelude_1.min(child[0][j] + 1, child[1][j]));
	        }
	        parent[0][i] = x0;
	        parent[1][i] = x1;
	    }
	}
	function solve(node, parent) {
	    var adj = tree.adjacent(node);
	    var m = leaves[node];
	    var needed = List.map(function (_) { return List.replicate(m + 1, n); }, [0, 0]);
	    if (adj.length == 1) {
	        needed[0][1] = 0;
	        needed[1][0] = 0;
	        return needed;
	    }
	    var first = true;
	    for (var i = 0; i < adj.length; i++) {
	        if (adj[i].target !== parent) {
	            var x = solve(adj[i].target, node);
	            var c = x[0].length;
	            if (first) {
	                for (var i_1 = 0; i_1 <= c; i_1++) {
	                    needed[0][i_1] = Prelude_1.min(x[0][i_1], x[1][i_1] + 1);
	                    needed[1][i_1] = Prelude_1.min(x[1][i_1], x[0][i_1] + 1);
	                }
	                first = false;
	            }
	            else {
	                combine(needed, x);
	            }
	        }
	    }
	    return needed;
	}
	if (n == 2) {
	    print(1);
	}
	else {
	    var root = findroot();
	    var m = countleaves(root, -1);
	    var needed = solve(root, -1);
	    print(Prelude_1.min(needed[0][m / 2], needed[1][m / 2]));
	}

/***/ },
/* 1 */
/***/ function(module, exports) {

	function min(a, b) {
	    return a < b ? a : b;
	}
	exports.min = min;
	function max(a, b) {
	    return a < b ? b : a;
	}
	exports.max = max;
	function curry(f) {
	    return function (x) { return function (y) { return f(x, y); }; };
	}
	exports.curry = curry;
	function uncurry(f) {
	    return function (x, y) { return f(x)(y); };
	}
	exports.uncurry = uncurry;
	function id(x) {
	    return x;
	}
	exports.id = id;
	function constant(x) {
	    return function (_) { return x; };
	}
	exports.constant = constant;
	function flip(f) {
	    return function (y) { return function (x) { return f(x)(y); }; };
	}
	exports.flip = flip;
	function flip2(f) {
	    return function (y, x) { return f(x, y); };
	}
	exports.flip2 = flip2;
	function compose(g, f) {
	    return function (x) { return g(f(x)); };
	}
	exports.compose = compose;

/***/ },
/* 2 */
/***/ function(module, exports, __webpack_require__) {

	var Prelude_1 = __webpack_require__(1);
	function add(xs, ys) {
	    return xs.concat(ys);
	}
	exports.add = add;
	function head(xs) {
	    return xs[0];
	}
	exports.head = head;
	function last(xs) {
	    return xs[xs.length - 1];
	}
	exports.last = last;
	function tail(xs) {
	    return xs.slice(1);
	}
	exports.tail = tail;
	function init(xs) {
	    return xs.slice(0, xs.length - 1);
	}
	exports.init = init;
	function map(f, xs) {
	    var result = new Array(xs.length);
	    for (var i = 0; i < xs.length; i++) {
	        result[i] = f(xs[i]);
	    }
	    return result;
	}
	exports.map = map;
	function reverse(xs) {
	    return xs.slice().reverse();
	}
	exports.reverse = reverse;
	function intersperse(x, xs) {
	    if (xs.length == 0) {
	        return [];
	    }
	    var result = new Array(xs.length + xs.length - 1);
	    for (var i = 0; i + 1 < xs.length; i++) {
	        result[i + i] = xs[i];
	        result[i + i + 1] = x;
	    }
	    result[result.length - 1] = xs[xs.length - 1];
	    return result;
	}
	exports.intersperse = intersperse;
	function intercalate(xs, xss) {
	    return concat(intersperse(xs, xss));
	}
	exports.intercalate = intercalate;
	function foldl(f, initial, xs) {
	    var result = initial;
	    for (var i = 0; i < xs.length; i++) {
	        result = f(result, xs[i]);
	    }
	    return result;
	}
	exports.foldl = foldl;
	function foldr(f, initial, xs) {
	    var result = initial;
	    for (var i = xs.length - 1; i >= 0; i--) {
	        result = f(xs[i], result);
	    }
	    return result;
	}
	exports.foldr = foldr;
	function concat(xss) {
	    var total = sum(map(function (xs) { return xs.length; }, xss));
	    var result = new Array(total);
	    var m = 0;
	    for (var i = 0; i < xss.length; i++) {
	        var xs = xss[i];
	        for (var j = 0; j < xs.length; j++) {
	            result[m++] = xs[j];
	        }
	    }
	    return result;
	}
	exports.concat = concat;
	function sum(xs) {
	    var result = 0;
	    for (var i = 0; i < xs.length; i++) {
	        result += xs[i];
	    }
	    return result;
	}
	exports.sum = sum;
	function product(xs) {
	    var result = 1;
	    for (var i = 0; i < xs.length; i++) {
	        result *= xs[i];
	    }
	    return result;
	}
	exports.product = product;
	function maximum(xs) {
	    var result = xs[0];
	    for (var i = 1; i < xs.length; i++) {
	        if (result < xs[i])
	            result = xs[i];
	    }
	    return result;
	}
	exports.maximum = maximum;
	function minimum(xs) {
	    var result = xs[0];
	    for (var i = 1; i < xs.length; i++) {
	        if (result > xs[i])
	            result = xs[i];
	    }
	    return result;
	}
	exports.minimum = minimum;
	function replicate(n, x) {
	    var result = new Array(n);
	    for (var i = 0; i < result.length; i++) {
	        result[i] = x;
	    }
	    return result;
	}
	exports.replicate = replicate;
	function take(n, xs) {
	    return xs.slice(0, n);
	}
	exports.take = take;
	function drop(n, xs) {
	    return xs.slice(n);
	}
	exports.drop = drop;
	function splitAt(n, xs) {
	    return [take(n, xs), drop(n, xs)];
	}
	exports.splitAt = splitAt;
	function takeWhile(f, xs) {
	    for (var i = 0; i < xs.length; i++) {
	        if (!f(xs[i])) {
	            return xs.slice(0, i);
	        }
	    }
	    return xs.slice();
	}
	exports.takeWhile = takeWhile;
	function dropWhile(f, xs) {
	    for (var i = 0; i < xs.length; i++) {
	        if (!f(xs[i])) {
	            return xs.slice(i);
	        }
	    }
	    return [];
	}
	exports.dropWhile = dropWhile;
	function group(xs) {
	    if (xs.length == 0) {
	        return [];
	    }
	    var result = [];
	    var last = [xs[0]];
	    for (var i = 1; i < xs.length; i++) {
	        if (last[0] === xs[i]) {
	            last.push(xs[i]);
	        }
	        else {
	            result.push(last);
	            last = [xs[i]];
	        }
	    }
	    result.push(last);
	    return result;
	}
	exports.group = group;
	function filter(f, xs) {
	    var result = [];
	    for (var i = 0; i < xs.length; i++) {
	        if (f(xs[i]))
	            result.push(xs[i]);
	    }
	    return result;
	}
	exports.filter = filter;
	function zip(xs, ys) {
	    var n = Prelude_1.min(xs.length, ys.length);
	    var result = new Array(n);
	    for (var i = 0; i < n; i++) {
	        result[i] = [xs[i], ys[i]];
	    }
	    return result;
	}
	exports.zip = zip;
	function unzip(xs) {
	    var r1 = new Array(xs.length);
	    var r2 = new Array(xs.length);
	    for (var i = 0; i < xs.length; i++) {
	        r1[i] = xs[i][0];
	        r2[i] = xs[i][1];
	    }
	    return [r1, r2];
	}
	exports.unzip = unzip;
	function range(from, to) {
	    var result = Array(to - from + 1);
	    for (var i = from; i <= to; i++) {
	        result[i - from] = i;
	    }
	    return result;
	}
	exports.range = range;
	function copy(xs) {
	    return xs.slice(0);
	}
	exports.copy = copy;
	function apply_permutation(p, xs) {
	    var n = xs.length;
	    var result = new Array(n);
	    for (var i = 0; i < n; i++) {
	        result[i] = xs[p[i]];
	    }
	    return result;
	}
	exports.apply_permutation = apply_permutation;
	function next_permutation(p) {
	    var n = p.length;
	    if (n < 2)
	        return null;
	    var r = copy(p);
	    var k = n - 2;
	    for (; k >= 0 && r[k] >= r[k + 1]; k--)
	        ;
	    if (k < 0)
	        return null;
	    for (var i = k + 1, j = n - 1; i < j; i++, j--) {
	        var t_1 = r[i];
	        r[i] = r[j];
	        r[j] = t_1;
	    }
	    var next = k + 1;
	    for (; r[next] <= r[k]; next++)
	        ;
	    var t = r[k];
	    r[k] = r[next];
	    r[next] = t;
	    return r;
	}
	exports.next_permutation = next_permutation;

/***/ },
/* 3 */
/***/ function(module, exports, __webpack_require__) {

	var List = __webpack_require__(2);
	var Graph = (function () {
	    function Graph(size) {
	        this.size = size;
	        this.adjacency = List.map(function (_) { return []; }, new Array(size));
	    }
	    Graph.prototype.fromEdges = function (edges) {
	        for (var _i = 0; _i < edges.length; _i++) {
	            var e = edges[_i];
	            this.addEdge(e);
	        }
	    };
	    Graph.prototype.addEdge = function (edge) {
	        this.adjacency[edge.source].push(edge);
	    };
	    Graph.prototype.adjacent = function (source) {
	        return this.adjacency[source];
	    };
	    Graph.prototype.map = function (source, f) {
	        var edges = this.adjacent(source);
	        for (var i = 0; i < edges.length; i++) {
	            edges[i] = f(edges[i]);
	        }
	    };
	    Graph.prototype.forEach = function (source, f) {
	        var edges = this.adjacent(source);
	        for (var i = 0; i < edges.length; i++) {
	            f(edges[i]);
	        }
	    };
	    Graph.prototype.dfs = function (source) {
	        var mark = List.map(function (_) { return 0; }, new Array(this.size));
	        var time = 1;
	        function go(node) {
	            if (mark[node] !== 0)
	                return;
	            mark[node] = time++;
	            this.forEach(node, function (edge) { return go(edge.target); });
	        }
	        go(source);
	        return mark;
	    };
	    return Graph;
	})();
	exports.Graph = Graph;

/***/ }
/******/ ]);


You are given an integer $$$n$$$ ($$$n > 1$$$).Your task is to find a sequence of integers $$$a_1, a_2, \ldots, a_k$$$ such that:  each $$$a_i$$$ is strictly greater than $$$1$$$;  $$$a_1 \cdot a_2 \cdot \ldots \cdot a_k = n$$$ (i. e. the product of this sequence is $$$n$$$);  $$$a_{i + 1}$$$ is divisible by $$$a_i$$$ for each $$$i$$$ from $$$1$$$ to $$$k-1$$$;  $$$k$$$ is the maximum possible (i. e. the length of this sequence is the maximum possible). If there are several such sequences, any of them is acceptable. It can be proven that at least one valid sequence always exists for any integer $$$n > 1$$$.You have to answer $$$t$$$ independent test cases.

The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 5000$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains one integer $$$n$$$ ($$$2 \le n \le 10^{10}$$$). It is guaranteed that the sum of $$$n$$$ does not exceed $$$10^{10}$$$ ($$$\sum n \le 10^{10}$$$).

For each test case, print the answer: in the first line, print one positive integer $$$k$$$ — the maximum possible length of $$$a$$$. In the second line, print $$$k$$$ integers $$$a_1, a_2, \ldots, a_k$$$ — the sequence of length $$$k$$$ satisfying the conditions from the problem statement. If there are several answers, you can print any. It can be proven that at least one valid sequence always exists for any integer $$$n > 1$$$.

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

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

function main() {
  let t = +readLine();
  while (t--) {
    let n = +readLine();
    let [count, pivot] = [0, null];
    let [maxCount, maxArr] = [-Infinity, []];

    for (let i = 2; i <= Math.sqrt(n); i++) {
      if (n % i === 0) {
        let [number, store] = [n, []];
        while (Number.isInteger(number / i) && (number / i) % i === 0) {
          store.push(i);
          number = number / i;
        }
        store.push(number);
        if (store.length > maxArr.length) {
          maxArr = store;
        }
      }
    }
    if (!maxArr.length) {
      console.log(1);
      console.log(n);
    } else {
      console.log(maxArr.length);
      console.log(maxArr.join(" "));
    }
  }
}

//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){
	var tmp = input.split(' ');
	for(var i = 0; i < tmp.length; i++){
		inLine.push(tmp[i]);
	}
});
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 nextArray(size, code){
	var ret = new Array(size);
	for(var i = 0; i < size; i++){
		if(code == 'int'){
			ret[i] = nextInt();
		}else{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);}
function 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();
	for(var i = 0; i < t; i++){
		var N = nextInt();
		var map = getPrimeFactorization(N);
		var key = Object.keys(map);
		key.sort(function(a,b){
			return map[b] - map[a];
		});
		var list = [];
		for(var j = 0; j < map[key[0]] - 1; j++){
			list.push(key[0]);
		}
		N /= Math.pow(key[0], map[key[0]] - 1);
		list.push(N);
		output.push(list.length);
		output.push(myconv(list, 8));
	}
	myout(myconv(output, 9));
}
function getPrimeFactorization(val){
  var primeMap = {};
  var div = 2;
  if(isPrime(val)){
    primeMap[val] = 1;
    return primeMap;
  }
  while(val != 1){
    if(val % div == 0){
      var count = 2;
      while(val % Math.pow(div, count) == 0){
         count++;
      }
      (primeMap[div] == null)  ? primeMap[div] = (count - 1) : primeMap[div] += (count - 1);
      val /= Math.pow(div, count - 1);
      if(isPrime(val)){
        (primeMap[val] == null)  ? primeMap[val] = 1 : primeMap[val]++;
        break;
      }
    }
    div = (div == 2) ? div + 1 : div + 2;
  }
  return primeMap;
}
function isPrime(val){
  if(val == null || val <= 1 || (val != 2 && val % 2 == 0)){
    return false;
  }else if(val == 2){
    return true;
  }
  var root = Math.floor(Math.sqrt(val));
  for(var i = 3; i <= root; i += 2){
    if(val % i == 0){
      return false;
    }
  }
  return true;
}

"use strict";

(() => {

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

    let curLine = 0, allLines = [];

    let nextLine = () => {
        if(curLine == allLines.length) throw new ReferenceError("No more input in the buffer");
        return allLines[curLine++]
    };

    readline.on("line", line => { allLines.push(line); });
    readline.on("close", () => { main(nextLine) });

})();

function main(nextLine) {
    let t = Number(nextLine());

    while(t--) {
        let n = Number(nextLine());

        let ans = new Array(40).fill(1);

        for(let i = 2; i*i <= n; i++) {
            if(n%i == 0) {
                for(let j = 0; n%i == 0; j++) ans[j] *= i, n /= i;
            }
        }
        if(n > 1) ans[0] *= n;

        while(ans[ans.length-1] === 1) ans.pop();
        ans.reverse();

        console.log(ans.length);
        console.log(ans.join(" "));
    }
}

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

let lines = [];

rl.on('line', (data) => {
    lines.push(data);
    if(lines.length > 0 && parseInt(lines[0]) === lines.length - 1) {
	rl.close();
	main();
    }
});

async function main() {
    let t = parseInt(lines[0]);
    for(let i = 1; i <= t; i++) {
	let n = parseInt(lines[i]);

	let factpow = {};
	for(let j = 2; j*j <= n; j++) {
	    if(n % j === 0) {
		factpow[j] = 0;
		while(n % j === 0) {
		    n /= j;
		    factpow[j]++;
		}
	    }
	}
	if(n != 1) {
	    factpow[n] = 1;
	}

	let lenmx = 0;
	for(const v in factpow) {
	    lenmx = Math.max(lenmx, factpow[v]);
	}

	let arr = [];
	for(let j = 0; j < lenmx; j++) {
	    arr.push(1);
	}

	for(const v in factpow) {
	    let power = factpow[v];
	    for(let j = lenmx - 1; j >= lenmx - power; j--) {
		arr[j] *= v;
	    }
	}

	console.log(lenmx);
	console.log(arr.join(' '));
    }
}

function main() {
    var t = int(readline());

    while(t--) {
        var n = int(readline());
        primeFactors(n);
    }

}

// default parsers for JS.
function int(x) {
    return parseInt(x);
}

function float(x) {
    return parseFloat(x);
}

function primeFactors(n) {
    var fr = {};
    var mx = 0;

    while (n % 2 === 0) {
        if(fr[2] === undefined) fr[2] = 0;
        fr[2]++;

        n /= 2;
    }

    if(fr[2])
        mx = Math.max(fr[2], mx);

    for (var i = 3; i <= int(Math.sqrt(n)); i = i + 2) {
        var flag = n % i === 0;

        while (n % i === 0)
        {
            if(fr[i] === undefined) fr[i] = 0;
            fr[i]++;
            n /= i;
        }

        if(flag)
            mx = Math.max(mx, fr[i]);
    }

    if (n > 2)
        fr[n] = 1;

    if(fr[n])
        mx = Math.max(mx, fr[n]);

    var ans = new Array(mx).fill(1);
    Object.keys(fr).forEach(v => {
        var gt = mx - 1;
            var freq = fr[v];
            while(gt >= 0 && freq--) {
                ans[gt--] *= v;
            }
    })

    print(mx);
    var finalAns = "";
    ans.forEach(v => {
        finalAns += v + " ";

    });

    print(finalAns);
    /*for(auto val: ans) {
        printf("%lld ", val);
    }*/
}

main();

function main() {
    var t = int(readline());

    while(t--) {
        var n = int(readline());
        primeFactors(n);
    }

}

// default parsers for JS.
function int(x) {
    return parseInt(x);
}

function float(x) {
    return parseFloat(x);
}

function primeFactors(n) {
    var fr = {};
    var mx = 0;

    while (n % 2 === 0) {
        if(fr[2] === undefined) fr[2] = 0;
        fr[2]++;

        n >>= 1;
    }

    if(fr[2])
        mx = Math.max(fr[2], mx);

    for (var i = 3; i <= Math.sqrt(n); i = i + 2) {
        var flag = n % i === 0;

        while (n % i === 0)
        {
            if(fr[i] === undefined) fr[i] = 0;
            fr[i]++;
            n /= i;
        }

        if(flag)
            mx = Math.max(mx, fr[i]);
    }

    if (n > 2)
        fr[n] = 1;

    if(fr[n])
        mx = Math.max(mx, fr[n]);

    var ans = new Array(mx).fill(1);
    Object.keys(fr).forEach(v => {
        var gt = mx - 1;
            var freq = fr[v];
            while(gt >= 0 && freq--) {
                ans[gt--] *= v;
            }
    })

    print(mx);
    var finalAns = "";
    ans.forEach(v => {
        finalAns += v + " ";

    });

    print(finalAns);
    /*for(auto val: ans) {
        printf("%lld ", val);
    }*/
}

main();


You are given an array $$$a$$$ of $$$n$$$ integers. Count the number of pairs of indices $$$(i, j)$$$ such that $$$i < j$$$ and $$$a_j - a_i = j - i$$$.

The first line contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$). Then $$$t$$$ test cases follow. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$). The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le n$$$) — array $$$a$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.

For each test case output the number of pairs of indices $$$(i, j)$$$ such that $$$i < j$$$ and $$$a_j - a_i = j - i$$$.

var testsCounter = parseInt(readline());

for (var i = 0; i < testsCounter; i++) {
    var arrayLength = parseInt(readline());
    var array = readline().split(' ');
    var residueHash = new Map();
    var countPairs = 0;

    for (var j = 0; j < arrayLength; j++) {
        var currentResidue = array[j] - j;
        if (residueHash.has(currentResidue)) {
            var currentValue = residueHash.get(currentResidue);
            var counter = currentValue + 1;
            residueHash.set(currentResidue, counter);
            var newResidue = parseInt(residueHash.get(currentResidue));
        } else {
            residueHash.set(currentResidue, 0);
        }
    }

    var iterator = residueHash.values();

    for (var j = 0; j < residueHash.size; j++) {
        var counter = iterator.next().value;
        countPairs += (counter * (counter + 1)) / 2
    }

    print(countPairs);
}

var t = readline();
t = Number(t);
while (t--) {
  var count = {},
    last = 0;
  var n = Number(readline());
  var array = readline().split(" ");
  for (var i = 1; i <= n; i++) {
    var test = "test" + ( array[i - 1] - i );
    count[test] = count[test] ? count[test] + 1 : 1;
  }
  for (var key in count) {
    last += count[key] > 1 ? (count[key] * (count[key] - 1)) / 2 : 0;
  }
  print(last);
}

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

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

    var distances = {};

    var pairsCount = 0;
    for (var i = 0; i < array.length; ++i) {
        var distance = array[i] - i;
        if (!distances[distance]) {
            distances[distance] = 0;
        }

        pairsCount += distances[distance];
        ++distances[distance];
    }

    print(pairsCount);
}

const t=parseInt(readline());

for(var k=0;k<t;k++)
{
    var n=parseInt(readline());
    var map = new Map();
    var arr = readline().split(' ').forEach((v, i) => {
        var dif = parseInt(v) - i;
        if (map.has(dif))
            map.set(dif, map.get(dif) + 1);
        else
            map.set(dif, 1);
    });
    var counter = 0;
    map.forEach((v) => counter += v * (v - 1) / 2);
    print(counter);

}

var tests = parseInt(readline());
for (var test = 0; test < tests; test++) {
    var size = parseInt(readline());
    var map = new Map();
    var arr = readline().split(' ').forEach((v, i) => {
        var dif = parseInt(v) - i;
        if (map.has(dif))
            map.set(dif, map.get(dif) + 1);
        else
            map.set(dif, 1);
    });
    var counter = 0;
    map.forEach((v) => counter += v * (v - 1) / 2);
    print(counter);
}

var input = new Array(parseInt(readline()) * 2);
    for (var i = 0; i < input.length; i++) {
        input[i] = readline();
    }
    var output = calc(input);
    output.forEach(function (value) { print(value); });
    function calc(inputArray) {
        var result = new Array();
        for (var i = 0; i < inputArray.length; i += 2) {
            var caseLength = parseInt(inputArray[i]);
            var caseArray = inputArray[i + 1].split(" ");
            var resultArray = new Array(caseLength);
            for (var j = 0; j < caseLength; j++) {
                resultArray[j] = parseInt(caseArray[j]) - j;
            }
            resultArray.sort(function (a, b) { return a - b; });
            var currentTerm = resultArray[0];
            var seqLength = 1;
            var total = 0;
            for (var k = 1; k < caseLength; k++) {
                if (resultArray[k] === currentTerm) {
                    seqLength++;
                }
                else {
                    total += calcSeq(seqLength);
                    currentTerm = resultArray[k];
                    seqLength = 1;
                }
            }
            total += calcSeq(seqLength);
            result.push(total);
        }
        return result;
    }
    function calcSeq(seq) {
        var result = 0;
        for (var i = 1; i < seq; i++) {
            result += i;
        }
        return result;
    }

var T = parseInt(readline());
function nC2(n) { return n*(n-1)/2; }
while (T--) {
    var N = parseInt(readline());
    var M = N-1;
    var P = 2*N+1;
    var a = readline().split(" ");
    var count = new Array(P);
    for (var i = 0; i < P; ++i)
        count[i] = 0;
	for (var i = 0; i < N; ++i)
	    ++count[N+parseInt(a[i])-i];
	var ans = 0;
	for (var i = 0; i < P; ++i)
	    if (count[i] > 1)
	        ans += nC2(count[i]);
	print(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", () => {
  inputString = inputString
    .trim()
    .split("\n")
    .map((string) => string.trim());

  main();
});

const readline = () => inputString[currentLine++];

// main logic

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

    // console.log(arrayNum);

    const map = new Map();
    let result = 0;
    for (let i = 0; i < arrayNum.length; i++) {
      const key = arrayNum[i] - i - 1;
      const current = map.get(key) || 0;
      result += current;
      map.set(key, current + 1);
    }
    console.log(result);
  });
};

"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 = parseInt(readline());
    let arr = readline()
      .trim()
      .split(" ")
      .map((cur) => parseInt(cur));
    for (let i = 0; i < n; i++) {
      arr[i] = arr[i] - (i + 1);
    }
    let obj = {},
      cnt = 1,
      flag = false;
    for (let i = 0; i < n; i++) {
      if (obj[arr[i]]) {
        flag = true;
        obj[arr[i]]++;
      } else obj[arr[i]] = 1;
    }
    if (flag) {
      let cnt = 0;
      for (let i of Object.keys(obj)) {
        let k = obj[i];
        if (k <= 1) continue;
        k--;
        cnt += (k * (k + 1)) / 2;
      }
      console.log(cnt);
    } else {
      console.log(0);
    }
  }
};
solve();

const solve = (arr) => {
    try {
        const set = {};

        for (let i = 0; i < arr.length; i += 1) {
            set[arr[i] - i] = (set[arr[i] - i] || 0) + 1;
        }

        let ans = 0;
        const keys = Object.values(set).filter((x) => x > 1);

        for (let i = 0; i < keys.length; i += 1) {
            ans += (keys[i] * (keys[i] - 1)) / 2;
        }

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

let input = '';
process.stdin.on('data', str => input += str)
process.stdin.on('end', () => {
    const [n, ...lines] = input.trim().split('\n')
        .map(l => l.trim());

    for (let i=0; i<n; i++) {
        console.log(solve(lines[i*2+1].split(' ')))
    }
})

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

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

function main() {
	let t = +readLine();
	while (t--) {
		const len = +readLine();
		const arr = readLine().split(' ').map(Number);
		const obj = {};
		let ans = 0;
		for (let i = 0; i < len; i++) {
			arr[i] = arr[i] - i;
			const n = arr[i];
			obj[n] = (obj[n] || 0) + 1;
		}
		const values = Object.values(obj);
		for (let val of values) {
			if (val > 1) {
				ans += Math.floor((val * (val - 1)) / 2);
			}
		}
		console.log(ans);
	}
}

const solve = (arr) => {

	const set = {};
	for (let i=0; i<arr.length; i++) {
		set[arr[i] - i] = (set[arr[i] - i] || 0) + 1;
	}

	const keys = Object.values(set).filter(v => v > 1);

	let sum2 = 0;
	for (let i=0; i<keys.length; i++) {
		for (let j=1; j<keys[i]; j++) {
			sum2 += j;
		}
	}

	return sum2;
}

let input = '';
process.stdin.on('data', str => input += str)
process.stdin.on('end', () => {
	const [n, ...lines] = input.trim().split('\n')
		.map(l => l.trim());

	for (let i=0; i<n; i++) {
		console.log(solve(lines[i*2+1].split(' ')))
	}
})

var dataitr;
var stdin_input = "";
process.stdin.resume();
process.stdin.setEncoding("ascii");
process.stdin.on("data", function (input) { stdin_input += input; });
process.stdin.on("end", function () { dataitr = stdin_input.split('\n').values(); main(); });

const rl = () => dataitr.next().value.trim();
const rn = () => Number(rl());
const ra = () => rl().split(' ');
const rna = () => ra().map(x => Number(x));

function main () {
	let t = rn();
	while (t--) {
		let n = rn();
		let a = rna();

		let mp = new Map();
		let ans = 0;
		for (let i = 0; i < n; i++) {
			const key = a[i] - i;
			const vl = mp.has(key) ? mp.get(key) : 0;
			mp.set(key, vl + 1);
			ans += vl;
		}

		console.log(ans);
	}
}

const readline = require("readline");
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
let input = [];
rl.on('line', line => {
    input.push(line);
})
rl.on('close', line => {
    var t = Number(input[0]);
    var b = 1;
    for (var a = 0; a < t; a++) {
        var n = Number(input[b]);
        b++;
        var arr = input[b].split(" ").map((i) => {
            return Number(i);
        });
        b++;
        var map = new Map();
        var count = 0;
        for (var i = 0; i < arr.length; i++) {
            var diff = arr[i] - i;
            if (map.has(diff)) {
                count += map.get(diff);
                map.set(diff, map.get(diff) + 1);
            } else {
                map.set(diff, 1);
            }
        }
        console.log(count);
    }
})

//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();
	for(var i = 0; i < t; i++){
		var N = nextInt();
		var list = nextIntArray(N);
		var map = {};
		for(var j = 0; j < N; j++){
			var V = list[j] - j;
			if(map[V] == null){
				map[V] = 0;
			}
			map[V]++;
		}
		var key = Object.keys(map);
		var output = 0;
		for(var j = 0; j < key.length; j++){
			var add = map[key[j]];
			output += add * (add - 1) / 2;
		}
		myout(output);
	}
}

var testsCounter = parseInt(readline());

for (var i = 0; i < testsCounter; i++) {
    var arrayLength = parseInt(readline());
    var array = readline().split(' ');
    var residueHash = new Map();
    var countPairs = 0;

    for (var j = 0; j < arrayLength; j++) {
        var currentResidue = array[j] - j;
        if (residueHash.has(currentResidue)) {
            var currentValue = residueHash.get(currentResidue);
            var counter = currentValue + 1;
            residueHash.set(currentResidue, counter);
            var newResidue = parseInt(residueHash.get(currentResidue));
        } else {
            residueHash.set(currentResidue, 0);
        }
    }

    for (var j = 0; j < residueHash.size; j++) {
        var counter = residueHash.values().next();
        countPairs += (counter * (counter + 1)) / 2
    }

    print(countPairs);
}

var testsCounter = parseInt(readline());

for (var i = 0; i < testsCounter; i++) {
    var arrayLength = parseInt(readline());
    var array = readline().split(' ');
    var residueHash = new Map();
    var countPairs = 0;

    for (var j = 0; j < arrayLength; j++) {
        var currentResidue = array[j] - j;
        if (residueHash.has(currentResidue)) {
            var currentValue = residueHash.get(currentResidue);
            var counter = currentValue + 1;
            residueHash.set(currentResidue, counter);
            var newResidue = parseInt(residueHash.get(currentResidue));
        } else {
            residueHash.set(currentResidue, 0);
        }
    }

    print(residueHash.values())

    // for (var [residue, counter] of residueHash) {
    //     countPairs += (counter * (counter + 1)) / 2
    // }

    print(countPairs);
}

var testsCounter = parseInt(readline());

for (var i = 0; i < testsCounter; i++) {
    var arrayLength = parseInt(readline());
    var array = readline().split(' ');
    var residueHash = new Map();
    var countPairs = 0;

    for (var j = 0; j < arrayLength; j++) {
        var currentResidue = array[j] - j;
        if (residueHash.has(currentResidue)) {
            var currentValue = residueHash.get(currentResidue);
            var counter = currentValue + 1;
            residueHash.set(currentResidue, counter);
            var newResidue = parseInt(residueHash.get(currentResidue));
        } else {
            residueHash.set(currentResidue, 0);
        }
    }

    // for (var [residue, counter] of residueHash) {
    //     countPairs += (counter * (counter + 1)) / 2
    // }

    print(countPairs);
}

var testsCounter = parseInt(readline());

for(var i = 0; i < testsCounter; i++) {
    var arrayLength = parseInt(readline());
    var array = readline().split(' ');
    var residueHash = new Map();
    for(var j = 0; j < arrayLength; j++) {
        var currentValue = residueHash.get(parseInt(array[j]));
        if(currentValue) {
            residueHash.set(parseInt(array[j]), 0);
        } else {
            residueHash.set(parseInt(array[j]), parseInt(currentValue) + 1);
        }
    }

    var countPairs = 0;

    for(var j = 0; j < arrayLength; j++) {
        var currentValue = residueHash.get(array[j]);
        countPairs =+ (parseInt(currentValue) * (parseInt(currentValue) + 1)) / 2
    }

    print(countPairs);
}

var testsCounter = parseInt(readline());

for(var i = 0; i < testsCounter; i++) {
    var arrayLength = parseInt(readline());
    var array = readline().split(' ');
    var residueHash = new Map();
    for(var j = 0; j < arrayLength; j++) {
        var currentValue = residueHash.get(array[j]);
        if(currentValue) {
            residueHash.set(array[j], 0);
        } else {
            residueHash.set(array[j], parseInt(currentValue) + 1);
        }
    }

    var countPairs = 0;

    for(var j = 0; j < arrayLength; j++) {
        var currentValue = residueHash.get(array[j]);
        countPairs =+ (parseInt(currentValue) * (parseInt(currentValue) + 1)) / 2
    }

    print(countPairs);
}

var testsCounter = parseInt(readline());

for(var i = 0; i < testsCounter; i++) {
    var arrayLength = parseInt(readline());
    var array = readline().split(' ');
    var residueHash = new Map();
    for(var j = 0; j < arrayLength; j++) {
        var currentValue = residueHash.get(array[j]);
        if(currentValue) {
            residueHash.set(array[j], 0);
        } else {
            residueHash.set(array[j], currentValue + 1);
        }
    }

    var countPairs = 0;

    for(var j = 0; j < arrayLength; j++) {
        var currentValue = residueHash.get(array[j]);
        countPairs =+ (currentValue * (currentValue + 1)) / 2
    }

    print(countPairs);
}

var testsCounter = parseInt(readline());

for(var i = 0; i < testsCounter; i++) {
    var arrayLength = parseInt(readline());
    var array = readline().split(' ');
    var residueHash = new Map();
    for(var j = 0; i < arrayLength; i++) {
        var currentValue = residueHash.get(array[j]);
        if(currentValue) {
            residueHash.set(array[j], 0);
        } else {
            residueHash.set(array[j], currentValue + 1);
        }
    }

    var countPairs = 0;

    for(var j = 0; i < arrayLength; i++) {
        var currentValue = residueHash.get(array[j]);
        countPairs =+ (currentValue * (currentValue + 1)) / 2
    }

    print(countPairs);
}

var t = readline()
t = Number(t)
while (t--) {
   var count = [], last = 0;
   var n = Number(readline())
   var array = readline().split(" ")
   for(var i = 1; i <= n; i++){
      if(array[i - 1] - i >= 0)
      count[array[i - 1] - i] = count[array[i - 1] - i]? count[array[i - 1] - i] + 1: 1
   }
   for(var i = 0; i < count.length; i++){
      if(count[i] > 1){
         last += ( count[i] * ( count[i] - 1 ) ) / 2
      }
   }
   print(last)
}

"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) => string.trim());

  main();
});

const readline = () => inputString[currentLine++];

// main logic

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

    console.log(arrayNum);

    const results = Array.from({ length: arrayLength }, () => 0);
    for (let i = 0; i < arrayNum.length; i++) {
      for (let j = i + 1; j < arrayNum.length; j++) {
        // console.log(
        //   "i",
        //   i,
        //   "j",
        //   j,
        //   "a_j",
        //   arrayNum[j],
        //   j - i + arrayNum[i] === arrayNum[j]
        // );
        if (j - i + arrayNum[i] === arrayNum[j]) {
          // console.log(".");
          results[j] += 1;
        }
      }
    }
    // console.log("results", results);
    console.log(results.reduce((i, j) => i + j, 0));
  });
};

"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 = parseInt(readline());
    let arr = readline()
      .trim()
      .split(" ")
      .map((cur) => parseInt(cur));
    for (let i = 0; i < n; i++) {
      arr[i] = Math.abs(arr[i] - i + 1);
    }
    let obj = {},
      cnt = 1,
      flag = false;
    for (let i = 0; i < n; i++) {
      if (obj[arr[i]]) {
        flag = true;
        obj[arr[i]]++;
      } else obj[arr[i]] = 1;
    }
    if (flag) {
      let cnt = 0;
      for (let i of Object.keys(obj)) {
        let k = obj[i];
        if (k <= 1) continue;
        k--;
        cnt += (k * (k + 1)) / 2;
      }
      console.log(cnt);
    } else {
      console.log(0);
    }
  }
};
solve();

"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 = parseInt(readline());
    let arr = readline()
      .trim()
      .split(" ")
      .map((cur) => parseInt(cur));
    for (let i = 0; i < n; i++) {
      arr[i] = Math.abs(arr[i] - i + 1);
    }
    console.log(arr);
    let obj = {},
      cnt = 1,
      flag = false;
    for (let i = 0; i < n; i++) {
      if (obj[arr[i]]) {
        flag = true;
        obj[arr[i]]++;
      } else obj[arr[i]] = 1;
    }
    if (flag) {
      let cnt = 0;
      for (let i of Object.keys(obj)) {
        let k = obj[i];
        if (k <= 1) continue;
        k--;
        cnt += (k * (k + 1)) / 2;
      }
      console.log(cnt);
    } else {
      console.log(0);
    }
  }
};
solve();

"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 = parseInt(readline());
    let arr = readline()
      .trim()
      .split(" ")
      .map((cur) => parseInt(cur));
    for (let i = 0; i < n; i++) {
      arr[i] = Math.abs(arr[i] - i + 1);
    }
    let obj = {},
      cnt = 1,
      flag = false;
    for (let i = 0; i < n; i++) {
      if (obj[arr[i]]) {
        flag = true;
        obj[arr[i]]++;
      } else obj[arr[i]] = 1;
    }
    if (flag) {
      for (let i of Object.keys(obj)) {
        let k = obj[i];
        if (k <= 1) continue;
        k--;
        console.log((k * (k + 1)) / 2);
      }
    } else {
      console.log(0);
    }
  }
};
solve();

const solve = (arr) => {
    try {
        const set = {};

        for (let i = 0; i < arr.length; i += 1) {
            set[arr[i] - i] = (set[arr[i] - i] || 0) + 1;
        }

        const keys = Object.values(set).filter((x) => x > 1).reduce((acc, curr) => acc + curr, 0);
        if (keys > 1) {
            return (keys * (keys - 1)) / 2;
        } else {
            return keys;
        }
    } catch (ex) {
        console.log('ex:', ex);
    }
};

let input = '';
process.stdin.on('data', str => input += str)
process.stdin.on('end', () => {
    const [n, ...lines] = input.trim().split('\n')
        .map(l => l.trim());

    for (let i=0; i<n; i++) {
        console.log(solve(lines[i*2+1].split(' ')))
    }
})

const solve = (arr) => {
    try {
        const set = {};

        for (let i = 0; i < arr.length; i += 1) {
            set[arr[i] - i] = (set[arr[i] - i] || 0) + 1;
            arr[i] = arr[i] - i;
        }
        const keys = Object.values(set).filter((x) => x > 1).reduce((acc, curr) => acc + curr, 0);
        return (keys * (keys - 1)) / 2;
    } catch (ex) {
        console.log('ex:', ex);
    }
};

let input = '';
process.stdin.on('data', str => input += str)
process.stdin.on('end', () => {
    const [n, ...lines] = input.trim().split('\n')
        .map(l => l.trim());

    for (let i=0; i<n; i++) {
        console.log(solve(lines[i*2+1].split(' ')))
    }
})

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

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

function main() {
	let t = +readLine();
	while (t--) {
		const len = +readLine();
		const arr = readLine().split(' ').map(Number);
		const obj = {};
		let max = -Infinity;
		for (let i = 0; i < len; i++) {
			arr[i] = arr[i] - i;
			const n = arr[i];
			obj[n] = (obj[n] || 0) + 1;
			max = Math.max(max, obj[n]);
		}
		const ans = Math.floor((max * (max - 1)) / 2);
		console.log(ans);
	}
}

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

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

function main() {
	let t = +readLine();
	while (t--) {
		const len = +readLine();
		const arr = readLine().split(' ').map(Number);
		const obj = {};
		let max = -Infinity;
		for (let i = 0; i < len; i++) {
			arr[i] = arr[i] - i;
			const n = arr[i];
			obj[n] = (obj[n] || 0) + 1;
			max = Math.max(max, obj[n]);
		}
		const ans = Math.floor(max * (max - 1)) / 2;
		console.log(ans);
	}
}