When Valera has got some free time, he goes to the library to read some books. Today he's got t free minutes to read. That's why Valera took n books in the library and for each book he estimated the time he is going to need to read it. Let's number the books by integers from 1 to n. Valera needs ai minutes to read the i-th book.Valera decided to choose an arbitrary book with number i and read the books one by one, starting from this book. In other words, he will first read book number i, then book number i + 1, then book number i + 2 and so on. He continues the process until he either runs out of the free time or finishes reading the n-th book. Valera reads each book up to the end, that is, he doesn't start reading the book if he doesn't have enough free time to finish reading it. Print the maximum number of books Valera can read.

The first line contains two integers n and t (1 ≤ n ≤ 105; 1 ≤ t ≤ 109) — the number of books and the number of free minutes Valera's got. The second line contains a sequence of n integers a1, a2, ..., an (1 ≤ ai ≤ 104), where number ai shows the number of minutes that the boy needs to read the i-th book.

Print a single integer — the maximum number of books Valera can read.

print(function(n, t) {
	var a = rn(),
		l = 0,
		r = 0,
		sum = 0,
		ans = 0;
	while (r < n) {
		sum += a[r++];
		while (sum > t)
			sum -= a[l++];
		if (r - l > ans)
			ans = r - l;
	}
	return ans;
}.apply(0, rn()));

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

print(function(n, t) {
	var a = rn(),
		l = 0,
		r = 0,
		sum = 0,
		ans = 0;
	while (r < n) {
		sum += a[r++];
		while (sum > t)
			sum -= a[l++];
		ans = Math.max(r - l, ans);
	}
	return ans;
}.apply(0, rn()));

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

print(function(n, t) {
	var s = 0;
	var a = readline().split(' ').map(Number);
	var b = new Int32Array(n + 1);
	var ans = 0;
	for (var i = 0; i < n; i++)
		b[i + 1] = b[i] + a[i];

	for (var i = 1; i <= n; i++) {
		var x = findCeil(b, b[i] - t, 0, n);
		if (x > -1) {
			ans = Math.max(ans, i - x);
		}
	}

	return ans;

}.apply(0, readline().split(' ').map(Number)));

function findCeil(a, v, l, h) {
	var m;
	if (v <= a[l]) return l;
	if (v > a[h]) return -1;
	while (l <= h) {
		m = l + h >> 1;
		if (v <= a[m]) {
			if (v > a[m - 1]) return m;
			else h = m - 1;
		} else {
			if (v <= a[m + 1]) return m + 1;
			else l = m + 1;
		}
	}
	return -1;
}

function rda(){ return readline().split(" ").map(Number); }
function rdn(){ return Number(readline()); }

var a = rda(), n = a[0], t = a[1];
a = rda();

for(var i = 0, s = 0; i < n; i++){
    s += a[i];
    a[i] = s;
}

var ans = 0;

for(var i = 0, j = 0; j < n; ){
    var x = (i == 0) ? (a[j]) : (a[j]-a[i-1]);
    if(x <= t){
        j++;
        ans++;
    }else{
        i++;
        j++;
    }
}

write(ans);

(function main() {
    var toInt = function(x) {
        return parseInt(x);
    }
    var firstline = readline().split(" ").map(toInt);
    var n = firstline[0],
        t = firstline[1];

    var ar = readline().split(" ").map(toInt);
    // NOT ar.sort(function(a, b){return a-b});

    ar.reduce(function(sum, next, id, array) {
        var tmp = sum + next;
        array[id] = tmp;
        return tmp;
    });

    ar.splice(0,0,0);

    print((function() {
        function binarysearch(end) {
            var left = 0,
            right = end;
            var mid;
            while (left <= right) {
                mid = Math.floor((left + right) /2);
                var sub = ar[end] - ar[mid];

                if (sub == t) {
                    return end - mid;
                } else if (sub > t) {
                    left = mid + 1;
                } else {
                    right = mid;
                    if (left == right) {
                        return end - mid;
                    }
                }
            }
        }
        var count = -1;
        for(var i = 1; i < ar.length; ++i) {
            var tmp = binarysearch(i);
            if (count < tmp)
                count = tmp;
        }
        if (count > -1)
            return count;
        return 0;
    })());
})();

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

var n = parseInt(line[0]);
var t = parseInt(line[1]);

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

var max = 0;
books[-1] = 0;
var j = -1;
var total = 0;
for(var i = 0; i < n; i++ ) {
    if(j == n){
        break;
    }
    if(i == j) {
        i++;
    }
    if(parseInt(books[i]) + total <= t){
        if(i - j  > max){
            max = i - j ;
        }
        total +=parseInt(books[i]);
    } else {
        if(total != 0){
            total -= parseInt(books[j+1]);
        }
        j++;
        i--;
    }
}

print(max);

;(function () {

	print(function(n, t) {
		var a = readline().split(' ').map(Number), ret = 0;

		for (var i = 0, j = 0, s = 0; i < n; i++) {
			s += a[i];
			while (s > t) s -= a[j++];
			ret = Math.max(ret, i - j + 1);
		}

		return ret;
	}.apply(null, readline().split(' ').map(Number)));

}).call(this);

function main() {
    var line = readline().split(' ').map(Number);
    var n = line[0];
    var t = line[1];
    var time = t;
    var data = readline().split(' ').map(Number);
    var start = 0;
    var i=0;
    var max = 0;
    var res = 0;
    while(i < n){
        while(t - data[i] < 0 && data[i] <= time){
            t += data[start];
            res--;
            start++;
        }
        if(data[i] <= time){
        t-=data[i];
        res++;
        }
        if(res>max){
            max = res;
        }
        i++
    }
    print(max)
}

main()

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

  main();
});

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

// Make a Snippet for the code above this and then write your logic in main()
function main() {
  const input = readline().split(' ').map(Number)
  const [numOfBooks, freeMinutes] = input
  const books = readline().split(' ').map(Number)
  helper(numOfBooks, freeMinutes, books)
}

function helper(numOfBooks, freeMinutes, books) {
  let left = 0
  let right = 0
  let sum = 0
  let max = 0
  while (right < numOfBooks) {
    if (sum + books[right] <= freeMinutes) {
      sum += books[right]
      right++
    } else {
      max = Math.max(right - left, max)
      sum -= books[left]
      left++
    }
  }

  console.log(Math.max(right - left, max))
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function printResult(x) {
    process.stdout.write(x);
}

function main() {
    const nm = readLine().split(' ').map(Number);
    const arr = readLine().split(' ').map(Number);

    const n = nm[0];
    const m = nm[1];

    // console.log(nm, requirements, complexities)
    const result = books(n, m, arr);
    printResult(result.toString());
}

const books = (n, m, a) => {
    let left = 0;
    let right = 0;
    let count = 0;
    let sum = 0;
    for (let i = 0; i < n; i++) {
        left = i;
        sum += a[left];

        if (left === right) {
            if (a[left] > m) {
                if (right === n - 1) break;
                right++;
                sum = 0;
                continue;
            } else if (a[left] === m) {
                count = Math.max(count, 1);
                if (right === n - 1) break;
                right++;
                sum = 0;
                continue;
            } else {
                if (right === n - 1) {
                    count = Math.max(count, 1);
                    break;
                }
                right++;
            }
        }
        while (right < n) {
            if (a[right] === m) {
                count = right - left > 1 ? Math.max(count, right - left) : 1;
                i = right;
                right++;
                sum = 0;
                break;
            } else if (a[right] > m) {
                count = right > left ? Math.max(count, right - left) : 0;
                i = right;
                right++;
                sum = 0;
                break;
            }
            sum += a[right];
            if (sum < m) {
                if (right === n - 1) return Math.max(count, right - left + 1);
                right++;
            } else if (sum === m) {
                count = right > left ? Math.max(count, right - left + 1) : 1;
                if (count === m || right === n - 1) return count;
                if (count > 1) {
                    sum = sum - (a[left] + a[left + 1]);
                } else if (count === 1) {
                    sum = 0;
                } else {
                    sum = 0;
                }

                right++;
                break;
            } else {
                count = right > left ? Math.max(count, right - left) : 0;
                if (count === m || right === n - 1) return count;
                if (count > 1) {
                    sum = sum - (a[left] + a[left + 1]);
                } else if (count === 1) {
                    sum = 0;
                } else {
                    sum = 0;
                }
                right++
                break;
            }
        }
    }

    return count;
};

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function printResult(x) {
    process.stdout.write(x);
}

function main() {
    const nm = readLine().split(' ').map(Number);
    const arr = readLine().split(' ').map(Number);

    const n = nm[0];
    const m = nm[1];

    const result = books(n, m, arr);
    printResult(result.toString());
}

const books = (n, m, a) => {
    let left = 0;
    let right = 0;
    let count = 0;
    let sum = 0;
    for (let i = 0; i < n; i++) {
        left = i;
        sum += a[left];

        if (left === right) {
            if (a[left] >= m) {
                if (a[left] === m) count = Math.max(count, 1);
                if (right === n - 1) break;
                sum = 0;
                right++;
                continue;
            } else {
                if (right === n - 1) {
                    count = Math.max(count, 1);
                    break;
                }
                right++;
            }
        }
        while (right < n) {
            if (a[right] >= m) {
                if (a[right] === m) count = right - left > 1 ? Math.max(count, right - left) : 1;
                else count = right > left ? Math.max(count, right - left) : 0;

                i = right;
                right++;
                sum = 0;
                break;
            }

            sum += a[right];
            if (sum < m) {
                if (right === n - 1) return Math.max(count, right - left + 1);
                right++;
            } else {
                if (sum === m) count = right > left ? Math.max(count, right - left + 1) : 1;
                else count = right > left ? Math.max(count, right - left) : 0;

                if (count === m || right === n - 1) return count;

                sum = count > 1 ? sum - (a[left] + a[left + 1]) : 0;
                right++;
                break;
            }
        }
    }

    return count;
};

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function printResult(x) {
    process.stdout.write(x);
}

function main() {
    const nm = readLine().split(' ').map(Number);
    const arr = readLine().split(' ').map(Number);

    const n = nm[0];
    const m = nm[1];

    const result = books(n, m, arr);
    printResult(result.toString());
}

const books = (n, m, a) => {
    let left = 0;
    let right = 0;
    let count = 0;
    let sum = 0;
    for (let i = 0; i < n; i++) {
        left = i;
        sum += a[left];

        if (left === right) {
            if (a[left] >= m) {
                if (a[left] === m) count = Math.max(count, 1);
                if (right === n - 1) break;
                sum = 0;
                right++;
                continue;
            } else {
                if (right === n - 1) {
                    count = Math.max(count, 1);
                    break;
                }
                right++;
            }
        }
        while (right < n) {
            if (a[right] >= m) {
                if (a[right] === m) {
                    count = right - left > 1 ? Math.max(count, right - left) : 1;
                } else {
                    count = right > left ? Math.max(count, right - left) : 0;
                }

                i = right;
                right++;
                sum = 0;
                break;
            }

            sum += a[right];
            if (sum < m) {
                if (right === n - 1) return Math.max(count, right - left + 1);
                right++;
            } else {
                if (sum === m) {
                    count = right > left ? Math.max(count, right - left + 1) : 1;
                } else {
                    count = right > left ? Math.max(count, right - left) : 0;
                }

                if (count === m || right === n - 1) return count;

                sum = count > 1 ? sum - (a[left] + a[left + 1]) : 0;
                right++;
                break;
            }
        }
    }

    return count;
};

var l=readline().split(' ');
var n=+l[0];
var t=+l[1];
var a=readline().split(' ')
	.map(function(v){return+v;})
	.sort(function(a,b){return a-b});
var ans=0;
var sum=0;
for(var i=0;i<n;i++){
	sum+=a[i];
	if(sum>t){
		break;
	}else{
		ans++;
	}
}
print(ans);

print(function(n, t) {
	var s = 0;
	var a = readline().split(' ').map(Number);
	var b = new Int32Array(n + 1);
	var ans = 0;
	for (var i = 0; i < n; i++)
		b[i + 1] = b[i] + a[i];

	for (var i = 1; i <= n; i++) {
		var x = find(b[i] - t);
		if (x > -1) {
			ans = Math.max(ans, i - x);
		}
	}

	return ans;

	function find(v) {
		var mid, low = 0,
			high = n;
		if (v <= b[low]) return low;
		if (v > b[high]) return -1;
		if (v == b[high]) return n;
		while (low < high) {
			mid = ~~ ((low + high) / 2);
			if (v >= b[mid]) {
				if (v < b[mid + 1]) return mid + 1;
				low = mid;
			} else {
				if (v >= b[mid - 1]) return mid;
				high = mid;
			}
		}
	}

}.apply(0, readline().split(' ').map(Number)));

print(function(n, t) {
	var s = 0;
	var a = readline().split(' ').map(Number);
	var b = new Int32Array(n + 1);
	var ans = 0;
	for (var i = 0; i < n; i++)
		b[i + 1] = b[i] + a[i];

	for (var i = 1; i <= n; i++) {
		var x = find(b[i] - t);
		if (x > -1) {
			ans = Math.max(ans, i - x);
		}
	}

	return ans;

	function find(v) {
		var mid, low = 0,
			high = n;
		if (v < b[low]) return -1;
		if (v > b[high]) return -1;
		if (v == b[high]) return n;
		while (low < high) {
			mid = ~~ ((low + high) / 2);
			if (v >= b[mid]) {
				if (v < b[mid + 1]) return mid + 1;
				low = mid;
			} else {
				if (v >= b[mid - 1]) return mid;
				high = mid;
			}
		}
	}

}.apply(0, readline().split(' ').map(Number)));

function rda(){ return readline().split(" ").map(Number); }
function rdn(){ return Number(readline()); }

var a = rda(), n = a[0], t = a[1];
a = rda();

for(var i = 0, s = 0; i < n; i++){
    s += a[i];
    a[i] = s;
}

var ans = 0;
if(t >= a[0]) ans++;

for(var i = 0, j = 1; j < n; ){
    var x = (i == 0) ? (a[j]) : (a[j]-a[i-1]);
    if(x <= t){
        j++;
        ans++;
    }else{
        i++;
        j++;
    }
}

write(ans);

function rda(){ return readline().split(" ").map(Number); }
function rdn(){ return Number(readline()); }

var a = rda(), n = a[0], t = a[1];
a = rda().sort(function(x, y){ return x-y; });

for(var i = 0, s = 0; i < n; i++){
    s += a[i];
    a[i] = s;
}

var ans = 0;
if(t >= a[0]) ans++;

for(var i = 0, j = 1; j < n; ){
    if(a[j] <= t){
        j++;
        ans++;
    }else{
        i++;
        j++;
    }
}

write(ans);

function rda(){ return readline().split(" ").map(Number); }
function rdn(){ return Number(readline()); }

var a = rda(), n = a[0], t = a[1];
a = rda();

for(var i = 0, s = 0; i < n; i++){
    s += a[i];
    a[i] = s;
}

var ans = 0;
if(t >= a[0]) ans++;

for(var i = 0, j = 1; j < n; ){
    var x = (i == 0) ? (a[j]) : (a[j]-a[i-1]);
    if(x <= t){
        j++;
        ans++;
    }else{
        i++;
        j++;
    }
    print(i, j, ans);
}

write(ans);

var input = readline().split(" ").map(Number), n = input[0], t = input[1], a = readline().split(" ").map(Number);
var counter = 0, ans;

a = a.filter(function(number){
	return !(number > t);
});
n = a.length;

a.sort(function(x,y){return x-y});

if(n == 0){
	ans = n;
}
else{
	for(var i = 0; i < n; i++){
		counter += a[i];
		if(counter > t){
			ans = i;
			break;
		}
	}

	if(counter <= t){
		ans = n;
	}

}

write(ans);

(function main() {
    var toInt = function(x) {
        return parseInt(x);
    }
    // ar = [2, 10];
    // t = 10;
    var firstline = readline().split(" ").map(toInt);
    var n = firstline[0],
        t = firstline[1];

    var ar = readline().split(" ").map(toInt);
    ar.sort(function(a, b){return a-b});

    ar.reduce(function(sum, next, id, array) {
        var tmp = sum + next;
        array[id] = tmp;
        return tmp;
    });

    print((function() {
        var left = 0,
            right = ar.length-1;
        var mid, old_mid= -1;
        while (left <= right) {
            mid = Math.floor((left + right) / 2);
            if (ar[mid] < t) {
                if (old_mid == mid) {
                    if (ar[old_mid + 1] < t)
                        return old_mid + 1;
                    return mid;
                }
                left = mid;
            } else if (ar[mid] == t) {
                return mid;
            } else {
                right = mid - 1;
            }
            old_mid = mid;
        }
        return -1;
    })()+1);
})();

(function main() {
    var toInt = function(x) {
        return parseInt(x);
    }
    var firstline = readline().split(" ").map(toInt);
    var n = firstline[0],
        t = firstline[1];

    var ar = readline().split(" ").map(toInt);
    ar.sort();

    ar.reduce(function(sum, next, id, array) {
        var tmp = sum + next;
        array[id] = tmp;
        return tmp;
    });

    print((function() {
        var left = 0,
            right = ar.length-1;
        var mid, old_mid= -1;
        while (left <= right) {
            mid = Math.floor((left + right) / 2);
            if (ar[mid] < t) {
                if (old_mid == mid) {
                    if (ar[old_mid + 1] < t)
                        return old_mid + 1;
                    return mid;
                }
                left = mid;
            } else if (ar[mid] == t) {
                return mid;
            } else {
                right = mid - 1;
            }
            old_mid = mid;
        }
        return -1;
    })()+1);
})();

(function main() {
    var toInt = function(x) {
        return parseInt(x);
    }
    var firstline = readline().split(" ").map(toInt);
    var n = firstline[0],
        t = firstline[1];

    var ar = readline().split(" ").map(toInt);

    ar.sort();

    ar.reduce(function(sum, next, id, array) {
        var tmp = sum + next;
        array[id] = tmp;
        return tmp;
    });

    print((function() {
        var left = 0,
            right = ar.length-1;
        var mid, old_mid= -1;
        while (left <= right) {
            mid = (left + right) / 2;
            if (ar[mid] < t) {
                if (old_mid == mid) {
                    if (ar[old_mid + 1] < t)
                        return old_mid + 1;
                    return mid;
                }
                left = mid;
            } else if (ar[mid] == t) {
                return mid;
            } else {
                right = mid - 1;
            }
            old_mid = mid;
        }
    })());
})();

(function main() {
    var toInt = function(x) {
        return parseInt(x);
    }
    var firstline = readline().split(" ").map(toInt);
    var n = firstline[0],
        t = firstline[1];

    var ar = readline().split(" ").map(toInt);

    ar.sort();

    ar.reduce(function(sum, next, id, array) {
        var tmp = sum + next;
        array[id] = tmp;
        return tmp;
    });

    print((function() {
        var left = 0,
            right = ar.length;
        var mid = (left + right) / 2,
            old_mid;
        while (left <= right) {
            if (ar[mid] < t) {
                if (old_mid == mid) {
                    if (ar[old_mid + 1] < t)
                        return ar[old_mid + 1];
                    return ar[mid];
                }
                left = mid;
            } else if (ar[mid] == t) {
                return ar[mid];
            } else {
                right = mid - 1;
            }
            old_mid = mid;
        }
    })());
})();

(function main() {
    var toInt = function(x) {
        return parseInt(x);
    }
    var firstline = readline().split(" ").map(toInt);
    var n = firstline[0],
        t = firstline[1];

    var ar = readline().split(" ").map(toInt);
    ar.sort();

    ar.reduce(function(sum, next, id, array) {
        var tmp = sum + next;
        array[id] = tmp;
        return tmp;
    });

    print((function() {
        var left = 0,
            right = ar.length-1;
        var mid, old_mid= -1;
        while (left <= right) {
            mid = Math.floor((left + right) / 2);
            if (ar[mid] < t) {
                if (old_mid == mid) {
                    if (ar[old_mid + 1] < t)
                        return old_mid + 1;
                    return mid;
                }
                left = mid;
            } else if (ar[mid] == t) {
                return mid;
            } else {
                right = mid - 1;
            }
            old_mid = mid;
        }
        return left;
    })()+1);
})();

(function main() {
    var toInt = function(x) {
        return parseInt(x);
    }
    // ar = [6, 4];
    // t = 10;
    var firstline = readline().split(" ").map(toInt);
    var n = firstline[0],
        t = firstline[1];

    var ar = readline().split(" ").map(toInt);
    ar.sort(function(a, b){return a-b});

    ar.reduce(function(sum, next, id, array) {
        var tmp = sum + next;
        array[id] = tmp;
        return tmp;
    });

    print((function() {
        var left = 0,
            right = ar.length-1;
        var mid, old_mid= -1;
        while (left <= right) {
            mid = Math.floor((left + right) / 2);
            if (ar[mid] < t) {
                if (old_mid == mid) {
                    if (ar[old_mid + 1] <= t)
                        return old_mid + 1;
                    return mid;
                }
                left = mid;
            } else if (ar[mid] == t) {
                return mid;
            } else {
                right = mid - 1;
            }
            old_mid = mid;
        }
        return -1;
    })()+1);
})();

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

var n = parseInt(line[0]);
var t = parseInt(line[1]);

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

var max = 0;
books[-1] = 0;
var j = -1;
var total = 0;
for(var i = 0; i < n; i++ ) {
    if(j == n){
        break;
    }
    if(i == j) {
        i++;
    }
    if(parseInt(books[i]) + total <= t){
        if(i - j  > max){
            max = i - j ;
        }
        total +=parseInt(books[i]);
    } else {
        if(total != 0){
            total -= parseInt(books[j-1]);
        }
        j++;
        i--;
    }
}

print(max);

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

var n = parseInt(line[0]);
var t = parseInt(line[1]);

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

var max = 0;
books[-1] = 0;
var j = -1;
var total = 0;
for(var i = 0; i < n; i++ ) {
    if(j == n){
        break;
    }
    if(i == j) {
        i++;
    }
    if(parseInt(books[i]) + total <= t){
        if(i - j  > max){
            max = i - j ;
        }
        total +=parseInt(books[i]);
    } else {
        total -= parseInt(books[j]);
        j++;
        i--;
    }
}

print(max);

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

var n = parseInt(line[0]);
var t = parseInt(line[1]);

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

var times = {};

times[0] = 0;

for(var i = 0; i < n; i++ ){
    times[i+1] = times[i] + parseInt(books[i]);
}

var max = 0;
for(var i = 0; i < n; i++) {
    for(var j=n-1; j > 0; j--){
        if(times[j]  - times[i] <= t && j - i + 1 > max){
            max = j - i + 1;
        }
    }
}

print(max);

function main() {
    var line = readline().split(' ').map(Number);
    var n = line[0];
    var t = line[1];
    var time = t;
    var data = readline().split(' ').map(Number);
    var start = 0;
    var i=0;
    var max = 0;
    var res = 0;
    while(i < n){
        while(t - data[i] < 0 && data[i] <= time){
            t += data[start];
            res--;
            start++;
        }
        t-=data[i];
        res++;
        if(res>max){
            max = res;
        }
        i++
    }
    print(max)
}

main()

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

  main();
});

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

// Make a Snippet for the code above this and then write your logic in main()
function main() {
  const input = readline().split(' ').map(Number)
  const [numOfBooks, freeMinutes] = input
  const books = readline().split(' ').map(Number)
  helper(numOfBooks, freeMinutes, books)
}

function helper(numOfBooks, freeMinutes, books) {
  let left = 0
  let right = 0
  let sum = 0
  let max = 0
  while (right < numOfBooks) {
    if (sum + books[right] < freeMinutes) {
      sum += books[right]
      right++
    } else {
      max = Math.max(right - left, max)
      sum -= books[left]
      left++
    }
  }

  console.log(Math.max(right - left, max))
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function printResult(x) {
    process.stdout.write(x);
}

function main() {
    const nm = readLine().split(' ').map(Number);
    const arr = readLine().split(' ').map(Number);

    const n = nm[0];
    const m = nm[1];

    // console.log(nm, requirements, complexities)
    const result = books(n, m, arr);
    printResult(result.toString());
}

const books = (n, m, a) => {
    let left = 0;
    let right = 0;
    let count = 0;
    let sum = 0;
    for (let i = 0; i < n; i++) {
        left = i;
        sum += a[left];

        if (left === right) {
            if (a[left] > m) {
                if (right === n - 1) break;
                right++;
                sum = 0;
                continue;
            } else if (a[left] === m) {
                count = Math.max(count, 1);
                if (right === n - 1) break;
                right++;
                sum = 0;
                continue;
            } else {
                if (right === n - 1) break;
                right++;
            }
        }
        while (right < n) {
            if (a[right] === m) {
                count = right - left > 1 ? Math.max(count, right - left) : 1;
                i = right;
                right++;
                sum = 0;
                break;
            } else if (a[right] > m) {
                count = right > left ? Math.max(count, right - left) : 0;
                i = right;
                right++;
                sum = 0;
                break;
            }
            sum += a[right];
            if (sum < m) {
                if (right === n - 1) return Math.max(count, right - left + 1);
                right++;
            } else if (sum === m) {
                count = right > left ? Math.max(count, right - left + 1) : 1;
                if (count === m || right === n - 1) return count;
                if (count > 1) {
                    sum = sum - (a[left] + a[left + 1]);
                } else if (count === 1) {
                    sum = 0;
                } else {
                    sum = 0;
                }

                right++;
                break;
            } else {
                count = right > left ? Math.max(count, right - left) : 0;
                if (count === m || right === n - 1) return count;
                if (count > 1) {
                    sum = sum - (a[left] + a[left + 1]);
                } else if (count === 1) {
                    sum = 0;
                } else {
                    sum = 0;
                }
                right++
                break;
            }
        }
    }

    return count;
};

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function printResult(x) {
    process.stdout.write(x);
}

function main() {
    const nm = readLine().split(' ').map(Number);
    const arr = readLine().split(' ').map(Number);

    const n = nm[0];
    const m = nm[1];

    const result = books(n, m, arr);
    printResult(result.toString());
}

const books = (n, m, a) => {
    let left = 0;
    let right = 0;
    let count = 0;
    let sum = 0;
    for (let i = 0; i < n; i++) {
        left = i;
        sum += a[left];

        if (left === right) {
            if (a[left] >= m) {
                if (a[left] === m) count = Math.max(count, 1);
                if (right === n - 1) break;
                sum = 0;
                continue;
            } else {
                if (right === n - 1) {
                    count = Math.max(count, 1);
                    break;
                }
                right++;
            }
        }
        while (right < n) {
            if (a[right] >= m) {
                if (a[right] === m) {
                    count = right - left > 1 ? Math.max(count, right - left) : 1;
                } else {
                    count = right > left ? Math.max(count, right - left) : 0;
                }

                i = right;
                right++;
                sum = 0;
                break;
            }

            sum += a[right];
            if (sum < m) {
                if (right === n - 1) return Math.max(count, right - left + 1);
                right++;
            } else if (sum >= m) {
                if (sum === m) {
                    count = right > left ? Math.max(count, right - left + 1) : 1;
                } else {
                    count = right > left ? Math.max(count, right - left) : 0;
                }

                if (count === m || right === n - 1) return count;

                sum = count > 1 ? sum - (a[left] + a[left + 1]) : 0;
                right++;
                break;
            }
        }
    }

    return count;
};

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function printResult(x) {
    process.stdout.write(x);
}

function main() {
    const nm = readLine().split(' ').map(Number);
    const arr = readLine().split(' ').map(Number);

    const n = nm[0];
    const m = nm[1];

    const result = books(n, m, arr);
    printResult(result.toString());
}

const books = (n, m, a) => {
    let left = 0;
    let right = 0;
    let count = 0;
    let sum = 0;
    for (let i = 0; i < n; i++) {
        left = i;
        sum += a[left];

        if (left === right) {
            if (a[left] >= m) {
                if (a[left] === m) count = Math.max(count, 1);
                if (right === n - 1) break;
                sum = 0;
                continue;
            } else {
                if (right === n - 1) {
                    count = Math.max(count, 1);
                    break;
                }
                right++;
            }
        }
        while (right < n) {
            if (a[right] >= m) {
                if (a[right] === m) count = right - left > 1 ? Math.max(count, right - left) : 1;
                else count = right > left ? Math.max(count, right - left) : 0;

                i = right;
                right++;
                sum = 0;
                break;
            }

            sum += a[right];
            if (sum < m) {
                if (right === n - 1) return Math.max(count, right - left + 1);
                right++;
            } else if (sum >= m) {
                if (sum === m) count = right > left ? Math.max(count, right - left + 1) : 1;
                else count = right > left ? Math.max(count, right - left) : 0;

                if (count === m || right === n - 1) return count;

                sum = count > 1 ? sum - (a[left] + a[left + 1]) : 0;
                right++;
                break;
            }
        }
    }

    return count;
};

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function printResult(x) {
    process.stdout.write(x);
}

function main() {
    const nm = readLine().split(' ').map(Number);
    const arr = readLine().split(' ').map(Number);

    const n = nm[0];
    const m = nm[1];

    const result = books(n, m, arr);
    printResult(result.toString());
}

const books = (n, m, a) => {
    let left = 0;
    let right = 0;
    let count = 0;
    let sum = 0;
    for (let i = 0; i < n; i++) {
        left = i;
        sum += a[left];

        if (left === right) {
            if (a[left] >= m) {
                if (a[left] === m) count = Math.max(count, 1);
                if (right === n - 1) break;
                sum = 0;
                continue;
            } else {
                if (right === n - 1) {
                    count = Math.max(count, 1);
                    break;
                }
                right++;
            }
        }
        while (right < n) {
            if (a[right] >= m) {
                if (a[right] === m) right - left > 1 ? Math.max(count, right - left) : 1;
                else count = right > left ? Math.max(count, right - left) : 0;

                i = right;
                right++;
                sum = 0;
                break;
            }

            sum += a[right];
            if (sum < m) {
                if (right === n - 1) return Math.max(count, right - left + 1);
                right++;
            } else if (sum >= m) {
                if (sum === m) count = right > left ? Math.max(count, right - left + 1) : 1;
                else count = right > left ? Math.max(count, right - left) : 0;

                if (count === m || right === n - 1) return count;

                sum = count > 1 ? sum - (a[left] + a[left + 1]) : 0;
                right++;
                break;
            }
        }
    }

    return count;
};

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function printResult(x) {
    process.stdout.write(x);
}

function main() {
    const nm = readLine().split(' ').map(Number);
    const arr = readLine().split(' ').map(Number);

    const n = nm[0];
    const m = nm[1];

    const result = books(n, m, arr);
    printResult(result.toString());
}

const books = (n, m, a) => {
    let left = 0;
    let right = 0;
    let count = 0;
    let sum = 0;
    for (let i = 0; i < n; i++) {
        left = i;
        sum += a[left];
        if (left === right) {
            if (a[left] >= m) {
                if (a[left] === m) count = Math.max(count, 1);
                if (right === n - 1) break;
                sum = 0;
                continue;
            } else if (right === n - 1) {
                count = Math.max(count, 1);
                break;
            }
            right++;
        }
        while (right < n) {
            if (a[right] >= m) {
                if (a[right] === m) right - left > 1 ? Math.max(count, right - left) : 1;
                else count = right > left ? Math.max(count, right - left) : 0;

                i = right;
                right++;
                sum = 0;
                break;
            }

            sum += a[right];
            if (sum < m) {
                if (right === n - 1) return Math.max(count, right - left + 1);
                right++;
            } else if (sum >= m) {
                if (sum === m) count = right > left ? Math.max(count, right - left + 1) : 1;
                else count = right > left ? Math.max(count, right - left) : 0;

                if (count === m || right === n - 1) return count;

                sum = count > 1 ? sum - (a[left] + a[left + 1]) : 0;
                right++;
                break;
            }
        }
    }

    return count;
};


You are given a non-empty string $$$s=s_1s_2\dots s_n$$$, which consists only of lowercase Latin letters. Polycarp does not like a string if it contains at least one string "one" or at least one string "two" (or both at the same time) as a substring. In other words, Polycarp does not like the string $$$s$$$ if there is an integer $$$j$$$ ($$$1 \le j \le n-2$$$), that $$$s_{j}s_{j+1}s_{j+2}=$$$"one" or $$$s_{j}s_{j+1}s_{j+2}=$$$"two".For example:  Polycarp does not like strings "oneee", "ontwow", "twone" and "oneonetwo" (they all have at least one substring "one" or "two"),  Polycarp likes strings "oonnee", "twwwo" and "twnoe" (they have no substrings "one" and "two"). Polycarp wants to select a certain set of indices (positions) and remove all letters on these positions. All removals are made at the same time.For example, if the string looks like $$$s=$$$"onetwone", then if Polycarp selects two indices $$$3$$$ and $$$6$$$, then "onetwone" will be selected and the result is "ontwne".What is the minimum number of indices (positions) that Polycarp needs to select to make the string liked? What should these positions be?

The first line of the input contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the input. Next, the test cases are given. Each test case consists of one non-empty string $$$s$$$. Its length does not exceed $$$1.5\cdot10^5$$$. The string $$$s$$$ consists only of lowercase Latin letters. It is guaranteed that the sum of lengths of all lines for all input data in the test does not exceed $$$1.5\cdot10^6$$$.

Print an answer for each test case in the input in order of their appearance. The first line of each answer should contain $$$r$$$ ($$$0 \le r \le |s|$$$) — the required minimum number of positions to be removed, where $$$|s|$$$ is the length of the given line. The second line of each answer should contain $$$r$$$ different integers — the indices themselves for removal in any order. Indices are numbered from left to right from $$$1$$$ to the length of the string. If $$$r=0$$$, then the second line can be skipped (or you can print empty). If there are several answers, print any of them.

10
onetwonetwooneooonetwooo
two
one
twooooo
ttttwo
ttwwoo
ooone
onnne
oneeeee
oneeeeeeetwooooo

NoteIn the first example, answers are:  "onetwone",  "testme" — Polycarp likes it, there is nothing to remove,  "oneoneone",  "twotwo". In the second example, answers are:   "onetwonetwooneooonetwooo",  "two",  "one",  "twooooo",  "ttttwo",  "ttwwoo" — Polycarp likes it, there is nothing to remove,  "ooone",  "onnne" — Polycarp likes it, there is nothing to remove,  "oneeeee",  "oneeeeeeetwooooo".

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

var arr = ''
process.stdin.on('data', (i) => {
  arr += i
})

process.stdin.on('end', () => {
  arr = arr.split('\n').map(a => a.replace(/(\r\n|\n|\r)/gm, ''))

  const t = parseInt(arr.shift())

  for(let j = 0; j < t; j++) {
    const s = arr[j],
          len = s.length,
          len2 = len - 2

    let count = 0
    let str = s.split('')
    let ans = ''

    for(let i = 0; i < len2; i ++) {
      // console.log(str[i], i)
      if(str[i] == 'o' && str[i + 1] == 'n' && str[i + 2] == 'e') {
        count ++
        if(ans == '') ans += (i + 1 + 1).toString()
        else ans += ` ${(i + 1 + 1)}`
        str[i + 1] = '1'
        i += 2
      }
      else if(str[i] == 't' && str[i + 1] == 'w' && str[i + 2] == 'o') {
        if(str[i + 3] == 'n' && str[i + 4] == 'e'){
          count ++
          if(ans == '') ans += (i + 2 + 1).toString()
          else ans += ` ${(i + 2 + 1)}`
          str[i + 2] = '1'
          i += 4
        }
        else {
          count ++
          if(ans == '') ans += (i + 1 + 1).toString()
          else ans += ` ${(i + 1 + 1)}`
          str[i + 1] = '1'
          i += 2
        }
      }
    }

    console.log(count)
    console.log(ans)
  }
})

function myout(t){print(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}

function Main() {
  var t = myconv(readline(),1);
  var output = new Array(t);
  for(var i = 0; i < t; i++){
      var s = myconv(readline(),6);
      var pos = [];
      //myout(s);
      for(var j = 0; j < s.length; j++){
         var twone = s[j-1]+s[j]+s[j+1]+s[j+2]+s[j+3];
         if(twone == "twone"){
             pos.push(j+2);
             j += 3;
             continue;
         }
         var onetwo = s[j-1]+s[j]+s[j+1];
         if(onetwo == "one" || onetwo == "two"){
             pos.push(j+1);
             continue;
         }
      }
      output[i] = pos.length + "\n" + pos.join(" ");
  }
  myout(output.join("\n"));
}

Main();


There are some tasks which have the following structure: you are given a model, and you can do some operations, you should use these operations to achive the goal. One way to create a new task is to use the same model and same operations, but change the goal.Let's have a try. I have created the following task for Topcoder SRM 557 Div1-Hard: you are given n integers x1, x2, ..., xn. You are allowed to perform the assignments (as many as you want) of the following form xi ^= xj (in the original task i and j must be different, but in this task we allow i to equal j). The goal is to maximize the sum of all xi.Now we just change the goal. You are also given n integers y1, y2, ..., yn. You should make x1, x2, ..., xn exactly equal to y1, y2, ..., yn. In other words, for each i number xi should be equal to yi.

The first line contains an integer n (1 ≤ n ≤ 10000). The second line contains n integers: x1 to xn (0 ≤ xi ≤ 109). The third line contains n integers: y1 to yn (0 ≤ yi ≤ 109).

If there is no solution, output -1. If there is a solution, then in the first line output an integer m (0 ≤ m ≤ 1000000) – the number of assignments you need to perform. Then print m lines, each line should contain two integers i and j (1 ≤ i, j ≤ n), which denote assignment xi ^= xj. If there are multiple solutions you can print any of them. We can prove that under these constraints if there exists a solution then there always exists a solution with no more than 106 operations.

NoteAssignment a ^= b denotes assignment a = a ^ b, where operation "^" is bitwise XOR of two integers.

var xAction = new Array();
var yAction = new Array();
var xBit = 0;
var yBit = 0;

var n = parseInt(readline());
var x = readline().split(' ');
for(var i=0;i<n;i++)
{
    x[i] = parseInt(x[i]);
}
var y = readline().split(' ');
for(var i=0;i<n;i++)
{
    y[i] = parseInt(y[i]);
}

var res = new Array();
var ans = 1;

parseArray(x,xAction,'x');
parseArray(y,yAction,'y');

if(xBit<yBit)
{
    ans = 0;
}
else
{
    ans = updateBaseBit();
//	debugA();
	if(ans==1)
	{
	    for(var i=xBit;i<n;i++)
		{
		    ans = updateNum(i,0,xBit,y[i])
			if(ans==0)
			{
			    break;
			}
		}
	}
}

if(ans==0)
{
    print(-1);
}
else
{
    var step = (xAction.length + yAction.length)/2;
	print(step);
	for(var i=0;i<xAction.length;i+=2)
	{
	    xAction[i]++;
		xAction[i+1]++;
	    print(xAction[i]+' '+xAction[i+1]);
	}
	for(var i=yAction.length-1;i>0;i-=2)
	{
	    yAction[i]++;
		yAction[i-1]++;
	    print(yAction[i-1]+' '+yAction[i]);
	}
}

// functions

// move highest bit to the head of the array
function parseArray(aNumber, aAction, strType)
{
    var nBit = 0;
	for(var k=30; k>=0; k--)
	{
    	for(var i=nBit;i<aNumber.length;i++)
	    {
	        if(isKBit(aNumber[i],k))
			{
			    for(var j=i+1;j<aNumber.length;j++)
				{
				    if(isKBit(aNumber[j],k))
					{
					    xor(j,i,aNumber,aAction);
					}
				}
			    swap(nBit,i,aNumber,aAction);
				nBit++;
			    break;
			}
	    }
	}
	if(strType=='x')
	{
	    xBit = nBit;
	}
	else
	{
	    yBit = nBit;
	}
}

// make the base bit of x and y equivalent
function updateBaseBit()
{
    var pos = 0;
    while(pos<=xBit||pos<=yBit)
	{
	    if(pos==yBit)
		{
		    xBit = yBit;
		    return 1;
		}
		if(pos==xBit)
		{
		    return 0;
		}

		var t = getHighestBit(x[pos])-getHighestBit([y[pos]]);
		if(t<0)
		{
		    return 0;
		}
		if(t>0)
		{
		    xor(pos,pos,x,xAction);
		}
		var tt=updateNum(pos,pos+1,xBit,y[pos]);

		if(tt==0)
		{
		    return 0;
		}
		pos++;
	}
}

// convert x[k] into val with x[s, s+1,...,e-1]
function updateNum(k,s,e,val)
{
    if(val==0)
	{
	    xor(k,k,x,xAction);
		return 1;
	}
	for(var i=s;i<e;i++)
	{
	    var t = getHighestBit(x[k]^val)-getHighestBit(x[i]);
	    if(t==0)
		{
		    xor(k,i,x,xAction);
		}
		else if(t>0)
		{
		    return 0;
		}
	}
	if(x[k]==val)
	{
	    return 1;
	}
	else
	{
	    return 0;
	}
}

function swap(i,j,aNumber,aAction)
{
    if(i != j)
	{
        var t = aNumber[i];
	    aNumber[i] = aNumber[j];
	    aNumber[j] = t;
	    aAction.push(i,j,j,i,i,j);
	}
}

function isKBit(x, k)
{
    if(((x>>k)&1)!=0)
	{
	    return 1;
	}
	else
	{
	    return 0;
	}
}

function getHighestBit(val)
{
    var x =0;
	while(val>0)
	{
	    val =(val>>1);
		x++;
	}
	return x-1;
}

function xor(i,j,aNumber,aAction)
{
    aNumber[i]^=aNumber[j];
	aAction.push(i,j);
}

function debugA()
{
	print('ans: '+ans);
	for(var i=0;i<n;i++)
	{
		print('x['+i+']: '+x[i]);
	}
	for(var i=0;i<n;i++)
	{
		print('y['+i+']: '+y[i]);
	}
	print('xBit: '+xBit+'  yBit: '+yBit);
	print('xAction length: '+ xAction.length);
	print('yAction length: '+yAction.length);
}

var xAction = new Array();
var yAction = new Array();
var xBit = 0;
var yBit = 0;

var n = parseInt(readline());
var x = readline().split(' ');
for(var i=0;i<n;i++)
{
    x[i] = parseInt(x[i]);
}
var y = readline().split(' ');
for(var i=0;i<n;i++)
{
    y[i] = parseInt(y[i]);
}

var res = new Array();
var ans = 1;

parseArray(x,xAction,'x');
parseArray(y,yAction,'y');

if(xBit<yBit)
{
    ans = 0;
}
else
{
    ans = updateBaseBit();
//	debugA();
	if(ans==1)
	{
	    for(var i=xBit;i<n;i++)
		{
		    ans = updateNum(i,0,xBit,y[i])
			if(ans==0)
			{
			    break;
			}
		}
	}
}

if(ans==0)
{
    print(-1);
}
else
{
    var step = (xAction.length + yAction.length)/2;
	print(step);
	for(var i=0;i<xAction.length;i+=2)
	{
	    xAction[i]++;
		xAction[i+1]++;
	    print(xAction[i]+' '+xAction[i+1]);
	}
	for(var i=yAction.length-1;i>0;i-=2)
	{
	    yAction[i]++;
		yAction[i-1]++;
	    print(yAction[i]+' '+yAction[i-1]);
	}
}

// functions

// move highest bit to the head of the array
function parseArray(aNumber, aAction, strType)
{
    var nBit = 0;
	for(var k=30; k>=0; k--)
	{
    	for(var i=nBit;i<aNumber.length;i++)
	    {
	        if(isKBit(aNumber[i],k))
			{
			    for(var j=i+1;j<aNumber.length;j++)
				{
				    if(isKBit(aNumber[j],k))
					{
					    xor(j,i,aNumber,aAction);
					}
				}
			    swap(nBit,i,aNumber,aAction);
				nBit++;
			    break;
			}
	    }
	}
	if(strType=='x')
	{
	    xBit = nBit;
	}
	else
	{
	    yBit = nBit;
	}
}

// make the base bit of x and y equivalent
function updateBaseBit()
{
    var pos = 0;
    while(pos<=xBit||pos<=yBit)
	{
	    if(pos==yBit)
		{
		    xBit = yBit;
		    return 1;
		}
		if(pos==xBit)
		{
		    return 0;
		}

		var t = getHighestBit(x[pos])-getHighestBit([y[pos]]);
		if(t<0)
		{
		    return 0;
		}
		if(t>0)
		{
		    xor(pos,pos,x,xAction);
		}
		var tt=updateNum(pos,pos+1,xBit,y[pos]);

		if(tt==0)
		{
		    return 0;
		}
		pos++;
	}
}

// convert x[k] into val with x[s, s+1,...,e-1]
function updateNum(k,s,e,val)
{
    if(val==0)
	{
	    xor(k,k,x,xAction);
		return 1;
	}
	for(var i=s;i<e;i++)
	{
	    var t = getHighestBit(x[k]^val)-getHighestBit(x[i]);
	    if(t==0)
		{
		    xor(k,i,x,xAction);
		}
		else if(t>0)
		{
		    return 0;
		}
	}
	if(x[k]==val)
	{
	    return 1;
	}
	else
	{
	    return 0;
	}
}

function swap(i,j,aNumber,aAction)
{
    if(i != j)
	{
        var t = aNumber[i];
	    aNumber[i] = aNumber[j];
	    aNumber[j] = t;
	    aAction.push(i,j,j,i,i,j);
	}
}

function isKBit(x, k)
{
    if(((x>>k)&1)!=0)
	{
	    return 1;
	}
	else
	{
	    return 0;
	}
}

function getHighestBit(val)
{
    var x =0;
	while(val>0)
	{
	    val =(val>>1);
		x++;
	}
	return x-1;
}

function xor(i,j,aNumber,aAction)
{
    aNumber[i]^=aNumber[j];
	aAction.push(i,j);
}

function debugA()
{
	print('ans: '+ans);
	for(var i=0;i<n;i++)
	{
		print('x['+i+']: '+x[i]);
	}
	for(var i=0;i<n;i++)
	{
		print('y['+i+']: '+y[i]);
	}
	print('xBit: '+xBit+'  yBit: '+yBit);
	print('xAction length: '+ xAction.length);
	print('yAction length: '+yAction.length);
}

var n = parseInt(readline());
var x = readline().split(' ');
for(var i=0;i<n;i++)
{
    x[i] = parseInt(x[i]);
}
var y = readline().split(' ');
for(var i=0;i<n;i++)
{
    y[i] = parseInt(y[i]);
}

var res = new Array();
var ans = 1;
var bit = new Array();

// move the highest bit to the first s elements
var s = 0;
for(var b=30;b>=0;b--)
{
    for(var i=s;i<n;i++)
	{
	    if(isKBit(x[i],b))
		{
		    // debug
//			print("s: "+s+" b:"+b+" i:"+i);
		    swap(s,i);
			for(var j=s+1;j<n;j++)
			{
			    if(isKBit(x[j],b))
				{
				    xor(j,s);
				}
			}
			s++;
			break;
		}
	}
}
//debug
//print("isKBit: "+isKBit(5,2));
/*print("s: "+s);
for(var i=0;i<n;i++)
{
    print(x[i]);
}*/

if(s==0)
{
    for(var i=0;i<n;i++)
	{
	    if(y[i]!=0)
		{
		    ans = 0;
			break;
		}
	}
}
else
{
    for(var i=s;i<n&&ans==1;i++)
	{
	    ans=produceY(i,s);
		if(ans==0)
		{
		    break;
		}
	}
	// sort y[0 -- s-1];
	var sorty = new Array();
	for(var i=0;i<s-1;i++)
	{
	    var m = i;
		for(var j=i+1;j<s;j++)
		{
		    if(y[j]>y[m])
			{
			    m=j;
			}
		}
		var t = y[i];
		y[i] = y[m];
		y[m] = t;
		sorty.push(i,m);
	}
//	print('sorty length: '+sorty.length);
	// process the first s element
	for(var i=0;i<s;i++)
	{
	    //debug
//		print("produceYY: "+y[i]+' '+i+' '+s+' '+x[i]);
	    ans=produceYY(y[i],i,s);
		if(ans==0)
		{
		    break;
		}
	}

	for(var i=sorty.length-1;i>=0;i-=2)
	{
	    swap(sorty[i],sorty[i-1]);
	}
}

if(ans==1)
{
    print(res.length / 2);
	for(var i=0;i<res.length;i+=2)
	{
	    print(res[i]+' '+res[i+1]);
	}
}
else
{
    print(-1);
}

// functions

function swap(i,j)
{
    if(i != j)
	{
        var t = x[i];
	    x[i] = x[j];
	    x[j] = t;
	    res.push(i,j,j,i,i,j);
	}
}

function isKBit(x, k)
{
    if(((x>>k)&1)!=0)
	{
	    return 1;
	}
	else
	{
	    return 0;
	}
}

function getHighestBit(val)
{
    var x =0;
	while(val>0)
	{
	    val =(val>>1);
		x++;
	}
	return x-1;
}

function xor(i,j)
{
    x[i]^=x[j];
	res.push(i,j);
}

// convert x[k] into y[k] with x[0,1,...,s-1];
function produceY(k, s)
{
    var r = 0;
    for(var i=30;i>=0;i--)
	{
	    if(isKBit(x[k],i)==isKBit(y[k],i))
		{
		    continue;
		}
		else
		{
		    var isOK = 0;
		    for(var j=r;j<s;j++)
			{
			    if(isKBit(x[k]^x[j],i) == isKBit(y[k],i))
				{
				    isOK = 1;
//					x[k]^=x[j];
					r=j+1;
					xor(k,j);
					break;
				}
			}
			if(isOK==0)
			{
			    return 0;
			}
		}
	}
	return 1;
}

// convert x[s] into val with x[s,s+1,...,e-1]
function produceYY(val,s,e)
{
    var r = s;
    for(var i=30;i>=0;i--)
	{
	    if(isKBit(x[s],i)==isKBit(val,i))
		{
		    continue;
		}
		else
		{
		    var isOK = 0;
			//debug
//			print('dif:'+i);
//			print('x[r]: '+x[r]);
//			print(getHighestBit(x[r]));
			// update r;
			while(getHighestBit(x[r])!=i)
			{
			    r++;
				if(r>=e)
				{
				    break;
				}
			}
			//debug
//			print('r:'+r);
		    for(var j=r;j<e;j++)
			{
			    if(isKBit(x[s]^x[j],i) == isKBit(val,i))
				{
				    isOK = 1;
//					x[s]^=x[j];
					r=j+1;
					xor(s,j);
					break;
				}
			}
			if(isOK==0)
			{
			    return 0;
			}
		}
	}
	return 1;
}

var n = parseInt(readline());
var x = readline().split(' ');
for(var i=0;i<n;i++)
{
    x[i] = parseInt(x[i]);
}
var y = readline().split(' ');
for(var i=0;i<n;i++)
{
    y[i] = parseInt(y[i]);
}

var res = new Array();
var ans = 1;
var bit = new Array();

// move the highest bit to the first s elements
var s = 0;
for(var b=30;b>=0;b--)
{
    for(var i=s;i<n;i++)
	{
	    if(isKBit(x[i],b))
		{
		    // debug
//			print("s: "+s+" b:"+b+" i:"+i);
		    swap(s,i);
			for(var j=s+1;j<n;j++)
			{
			    if(isKBit(x[j],b))
				{
				    xor(j,s);
				}
			}
			s++;
			break;
		}
	}
}
//debug
//print("isKBit: "+isKBit(5,2));
/*print("s: "+s);
for(var i=0;i<n;i++)
{
    print(x[i]);
}*/

if(s==0)
{
    for(var i=0;i<n;i++)
	{
	    if(y[i]!=0)
		{
		    ans = 0;
			break;
		}
	}
}
else
{
    for(var i=s;i<n&&ans==1;i++)
	{
	    ans=produceY(i,s);
		if(ans==0)
		{
		    break;
		}
	}
	// sort y[0 -- s-1];
	var sorty = new Array();
	for(var i=0;i<s-1;i++)
	{
	    var m = i;
		for(var j=i+1;j<s;j++)
		{
		    if(y[j]>y[m])
			{
			    m=j;
			}
		}
		var t = y[i];
		y[i] = y[m];
		y[m] = t;
		sorty.push(i,m);
	}
//	print('sorty length: '+sorty.length);
	// process the first s element
	for(var i=0;i<s;i++)
	{
	    //debug
//		print("produceYY: "+y[i]+' '+i+' '+s+' '+x[i]);
	    ans=produceYY(y[i],i,s);
		if(ans==0)
		{
		    break;
		}
	}

	for(var i=sorty.length-1;i>=0;i-=2)
	{
	    swap(sorty[i],sorty[i-1]);
	}
}

if(ans==1)
{
    print(res.length / 2);
	for(var i=0;i<res.length;i++)
	{
	    res[i]=parseInt(res[i])+1;
	}
	for(var i=0;i<res.length;i+=2)
	{
	    print(res[i]+' '+res[i+1]);
	}
}
else
{
    print(-1);
}

// functions

function swap(i,j)
{
    if(i != j)
	{
        var t = x[i];
	    x[i] = x[j];
	    x[j] = t;
	    res.push(i,j,j,i,i,j);
	}
}

function isKBit(x, k)
{
    if(((x>>k)&1)!=0)
	{
	    return 1;
	}
	else
	{
	    return 0;
	}
}

function getHighestBit(val)
{
    var x =0;
	while(val>0)
	{
	    val =(val>>1);
		x++;
	}
	return x-1;
}

function xor(i,j)
{
    x[i]^=x[j];
	res.push(i,j);
}

// convert x[k] into y[k] with x[0,1,...,s-1];
function produceY(k, s)
{
    var r = 0;
    for(var i=30;i>=0;i--)
	{
	    if(isKBit(x[k],i)==isKBit(y[k],i))
		{
		    continue;
		}
		else
		{
		    var isOK = 0;
		    for(var j=r;j<s;j++)
			{
			    if(isKBit(x[k]^x[j],i) == isKBit(y[k],i))
				{
				    isOK = 1;
//					x[k]^=x[j];
					r=j+1;
					xor(k,j);
					break;
				}
			}
			if(isOK==0)
			{
			    return 0;
			}
		}
	}
	return 1;
}

// convert x[s] into val with x[s,s+1,...,e-1]
function produceYY(val,s,e)
{
    var r = s;
    for(var i=30;i>=0;i--)
	{
	    if(isKBit(x[s],i)==isKBit(val,i))
		{
		    continue;
		}
		else
		{
		    var isOK = 0;
			//debug
//			print('dif:'+i);
//			print('x[r]: '+x[r]);
//			print(getHighestBit(x[r]));
			// update r;
			while(getHighestBit(x[r])!=i)
			{
			    r++;
				if(r>=e)
				{
				    break;
				}
			}
			//debug
//			print('r:'+r);
		    for(var j=r;j<e;j++)
			{
			    if(isKBit(x[s]^x[j],i) == isKBit(val,i))
				{
				    isOK = 1;
//					x[s]^=x[j];
					r=j+1;
					xor(s,j);
					break;
				}
			}
			if(isOK==0)
			{
			    return 0;
			}
		}
	}
	return 1;
}

var xAction = new Array();
var yAction = new Array();
var xBit = 0;
var yBit = 0;

var n = parseInt(readline());
var x = readline().split(' ');
for(var i=0;i<n;i++)
{
    x[i] = parseInt(x[i]);
}
var y = readline().split(' ');
for(var i=0;i<n;i++)
{
    y[i] = parseInt(y[i]);
}

var res = new Array();
var ans = 1;

parseArray(x,xAction,'x');
parseArray(y,yAction,'y');

if(xBit<yBit)
{
    ans = 0;
}
else
{
    ans = updateBaseBit();
//	debugA();
	if(ans==1)
	{
	    for(var i=xBit;i<n;i++)
		{
		    ans = updateNum(i,0,xBit,y[i])
			if(ans==0)
			{
			    break;
			}
		}
	}
}

if(ans==0)
{
    print(-1);
}
else
{
    var step = (xAction.length + yAction.length)/2;
	print(step);
	for(var i=0;i<xAction.length;i+=2)
	{
	    print(xAction[i]+' '+xAction[i+1]);
	}
	for(var i=yAction.length-1;i>0;i-=2)
	{
	    print(yAction[i]+' '+yAction[i-1]);
	}
}

// functions

// move highest bit to the head of the array
function parseArray(aNumber, aAction, strType)
{
    var nBit = 0;
	for(var k=30; k>=0; k--)
	{
    	for(var i=nBit;i<aNumber.length;i++)
	    {
	        if(isKBit(aNumber[i],k))
			{
			    for(var j=i+1;j<aNumber.length;j++)
				{
				    if(isKBit(aNumber[j],k))
					{
					    xor(j,i,aNumber,aAction);
					}
				}
			    swap(nBit,i,aNumber,aAction);
				nBit++;
			    break;
			}
	    }
	}
	if(strType=='x')
	{
	    xBit = nBit;
	}
	else
	{
	    yBit = nBit;
	}
}

// make the base bit of x and y equivalent
function updateBaseBit()
{
    var pos = 0;
    while(pos<=xBit||pos<=yBit)
	{
	    if(pos==yBit)
		{
		    xBit = yBit;
		    return 1;
		}
		if(pos==xBit)
		{
		    return 0;
		}

		var t = getHighestBit(x[pos])-getHighestBit([y[pos]]);
		if(t<0)
		{
		    return 0;
		}
		if(t>0)
		{
		    xor(pos,pos,x,xAction);
		}
		var tt=updateNum(pos,pos+1,xBit,y[pos]);

		if(tt==0)
		{
		    return 0;
		}
		pos++;
	}
}

// convert x[k] into val with x[s, s+1,...,e-1]
function updateNum(k,s,e,val)
{
    if(val==0)
	{
	    xor(k,k,x,xAction);
		return 1;
	}
	for(var i=s;i<e;i++)
	{
	    var t = getHighestBit(x[k]^val)-getHighestBit(x[i]);
	    if(t==0)
		{
		    xor(k,i,x,xAction);
		}
		else if(t>0)
		{
		    return 0;
		}
	}
	if(x[k]==val)
	{
	    return 1;
	}
	else
	{
	    return 0;
	}
}

function swap(i,j,aNumber,aAction)
{
    if(i != j)
	{
        var t = aNumber[i];
	    aNumber[i] = aNumber[j];
	    aNumber[j] = t;
	    aAction.push(i,j,j,i,i,j);
	}
}

function isKBit(x, k)
{
    if(((x>>k)&1)!=0)
	{
	    return 1;
	}
	else
	{
	    return 0;
	}
}

function getHighestBit(val)
{
    var x =0;
	while(val>0)
	{
	    val =(val>>1);
		x++;
	}
	return x-1;
}

function xor(i,j,aNumber,aAction)
{
    aNumber[i]^=aNumber[j];
	aAction.push(i,j);
}

function debugA()
{
	print('ans: '+ans);
	for(var i=0;i<n;i++)
	{
		print('x['+i+']: '+x[i]);
	}
	for(var i=0;i<n;i++)
	{
		print('y['+i+']: '+y[i]);
	}
	print('xBit: '+xBit+'  yBit: '+yBit);
	print('xAction length: '+ xAction.length);
	print('yAction length: '+yAction.length);
}


The brave Knight came to the King and asked permission to marry the princess. The King knew that the Knight was brave, but he also wanted to know if he was smart enough. So he asked him to solve the following task.There is a permutation $$$p_i$$$ of numbers from 1 to $$$2n$$$. You can make two types of operations.   Swap $$$p_1$$$ and $$$p_2$$$, $$$p_3$$$ and $$$p_4$$$, ..., $$$p_{2n-1}$$$ and $$$p_{2n}$$$.  Swap $$$p_1$$$ and $$$p_{n+1}$$$, $$$p_2$$$ and $$$p_{n+2}$$$, ..., $$$p_{n}$$$ and $$$p_{2n}$$$. The task is to find the minimal number of operations required to sort the given permutation.The Knight was not that smart actually, but quite charming, so the princess asks you to help him to solve the King's task.

The first line contains the integer $$$n$$$ ($$$1\le n\le 1000$$$). The second line contains $$$2n$$$ integers $$$p_i$$$ — the permutation of numbers from 1 to $$$2n$$$.

Print one integer — the minimal number of operations required to sort the permutation. If it is impossible to sort the permutation using these operations, print $$$-1$$$.

NoteIn the first example, you can sort the permutation in three operations:   Make operation 1: $$$3, 6, 5, 2, 1, 4$$$.  Make operation 2: $$$2, 1, 4, 3, 6, 5$$$.  Make operation 1: $$$1, 2, 3, 4, 5, 6$$$.

const increase = a => {
  for (let i = 0; i < a.length; i++) {
    if (a[i] !== i + 1) return false;
  }
  return true;
};

const permutation = (n, a, tag) => {
  const b = [...a];
  if (tag === 0) {
    for (let j = 0; j < n; j++) {
      let w = b[2 * j];
      b[2 * j] = b[2 * j + 1];
      b[2 * j + 1] = w;
    }
  } else if (tag === 1) {
    for (let j = 0; j < n; j++) {
      let w = b[j];
      b[j] = b[n + j];
      b[n + j] = w;
    }
  }
  return b;
};

const solve = (n, a) => {
  if (increase(a)) return 0;

  let p1 = [...a];
  let t1 = 0;
  let p2 = [...a];
  let t2 = 1;

  for (let i = 1; i <= n; i++) {
    p1 = permutation(n, p1, t1);
    p2 = permutation(n, p2, t2);
    if (increase(p1) || increase(p2)) return i;
    t1 = 1 - t1;
    t2 = 1 - t2;
  }

  return -1;
};

const main = () => {
  const n = readInt();
  const a = readListInt();

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

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

const readInt = () => {
  return parseInt(inputString[currentLine++]);
};

const readListInt = () => {
  return inputString[currentLine++].split(" ").map(s => parseInt(s));
};

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 n = Number(input[0]);
    var arr = input[1].split(" ").map((i) => {
        return Number(i);
    })
    function op1(arr) {
        var temp = [];
        for (var i = 0; i < n; i++) {
            temp[2 * i + 1] = arr[2 * i];
            temp[2 * i] = arr[2 * i + 1];
        }
        return temp;
    }
    function op2(arr) {
        var temp = [];
        for (var i = 0; i < n; i++) {
            temp[i] = arr[i + n];
            temp[i + n] = arr[i];
        }
        return temp;
    }
    var sorted = arr.slice();
    sorted.sort((a, b) => {
        return a - b;
    })
    var set = new Set();
    var queue = [];
    queue.push(arr);
    set.add(arr.toString());
    var found = false;
    var step = 0;
    while (queue.length !== 0) {
        var l = queue.length;
        for (var m = 0; m < l; m++) {
            var curt = queue.shift();
            if (curt.toString() === sorted.toString()) {
                console.log(step);
                found = true;
                break;
            }
            var next1 = op1(curt);
            var next2 = op2(curt);
            if (!set.has(next1.toString())) {
                queue.push(next1);
                set.add(next1.toString());
            }
            if (!set.has(next2.toString())) {
                queue.push(next2);
                set.add(next2.toString());
            }
        }
        step++;
    }
    if (!found) {
        console.log(-1);
    }
})

"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++];
}
function iInpArr() {
  return readline()
    .trim()
    .split(" ")
    .map((cur) => parseInt(cur));
}
function BInpArr() {
  return readline()
    .trim()
    .split(" ")
    .map((cur) => BigInt(cur));
}
function string() {
  return readline().trim();
}
function stringArr() {
  return readline().trim().split("");
}
function getValue() {
  return parseInt(readline());
}
let mod = BigInt(1e9 + 7);
const solve = () => {
  let t = 1;
  while (t--) {
    let n = getValue();
    let arr = iInpArr();
    let arr1 = [...arr];
    const check = (arr) => {
      for (let i = 0; i < arr.length - 1; i++) {
        if (arr[i] > arr[i + 1]) return false;
      }
      return true;
    };
    const swap = (arr) => {
      for (let i = 0; i < arr.length; i += 2) {
        [arr[i], arr[i + 1]] = [arr[i + 1], arr[i]];
      }
    };
    const rev = (arr) => {
      for (let i = 0; i < n; i++) {
        [arr[i], arr[n + i]] = [arr[n + i], arr[i]];
      }
    };
    if (n % 2 === 0) {
      if (check(arr)) {
        console.log(0);
        continue;
      }
      swap(arr);
      rev(arr1);
      if (check(arr) || check(arr1)) {
        console.log(1);
        continue;
      }
      rev(arr);
      swap(arr1);
      if (check(arr) || check(arr1)) {
        console.log(2);
        continue;
      }
      console.log(-1);
    } else {
      let ans = false;
      for (let i = 0; i <= n * 2; i++) {
        if (check(arr) || check(arr1)) {
          console.log(i);
          ans = true;
          break;
        }
        if (i % 2 === 0) {
          swap(arr);
          rev(arr1);
        } else {
          rev(arr);
          swap(arr1);
        }
      }
      if (ans === false) console.log(-1);
    }
  }
};
solve();

const increase = a => {
  for (let i = 0; i < a.length; i++) {
    if (a[i] !== i + 1) return false;
  }
  return true;
};

const permutation = (n, a, tag) => {
  const b = [...a];
  if (tag === 0) {
    for (let j = 0; j < n; j++) {
      let w = b[2 * j];
      b[2 * j] = b[2 * j + 1];
      b[2 * j + 1] = w;
    }
  } else if (tag === 1) {
    for (let j = 0; j < n; j++) {
      let w = b[j];
      b[j] = b[n + j];
      b[n + j] = w;
    }
  }
  return b;
};

const solve = (n, a) => {
  if (increase(a)) return 0;

  let p1 = [...a];
  let t1 = 0;
  let p2 = [...a];
  let t2 = 1;
  for (let i = 1; i <= 4; i++) {
    p1 = permutation(n, p1, t1);
    p2 = permutation(n, p2, t2);
    if (increase(p1) || increase(p2)) return i;
    t1 = 1 - t1;
    t2 = 1 - t2;
  }

  return -1;
};

const main = () => {
  const n = readInt();
  const a = readListInt();

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

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

const readInt = () => {
  return parseInt(inputString[currentLine++]);
};

const readListInt = () => {
  return inputString[currentLine++].split(" ").map(s => parseInt(s));
};

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 n = Number(input[0]);
    var arr = input[1].split(" ").map((i) => {
        return Number(i);
    })
    function op1(arr) {
        var temp = [];
        for (var i = 0; i < n; i++) {
            temp[2 * i + 1] = arr[2 * i];
            temp[2 * i] = arr[2 * i + 1];
        }
        return temp;
    }
    function op2(arr) {
        var temp = [];
        for (var i = 0; i < n; i++) {
            temp[i] = arr[i + n];
            temp[i + n] = arr[i];
        }
        return temp;
    }
    var sorted = arr.slice();
    sorted.sort((a, b) => {
        return a - b;
    })
    var set = new Set();
    set.add(arr.toString());
    function helper(arr, set, step) {
        if (arr.toString() === sorted.toString()) {
            return step;
        }
        var min = Infinity;
        var next = op1(arr);
        if (!set.has(next.toString())) {
            set.add(next.toString());
            min = Math.min(helper(next, set, step + 1), min);
        }
        next = op2(arr);
        if (!set.has(next.toString())) {
            set.add(next.toString());
            min = Math.min(helper(next, set, step + 1), min);
        }
        return min;
    }
    var result = helper(arr, set, 0);
    if (result === Infinity) {
        console.log(-1);
    } else {
        console.log(result);
    }
})


n people came to a party. Then those, who had no friends among people at the party, left. Then those, who had exactly 1 friend among those who stayed, left as well. Then those, who had exactly 2, 3, ..., n - 1 friends among those who stayed by the moment of their leaving, did the same.What is the maximum amount of people that could stay at the party in the end?

The first input line contains one number t — amount of tests (1 ≤ t ≤ 105). Each of the following t lines contains one integer number n (1 ≤ n ≤ 105).

For each test output in a separate line one number — the maximum amount of people that could stay in the end.

'use strict'

const T = +readline()

let lll

while (lll = +readline()) {
  print(Math.max(lll - 2, 0))
}


This is an interactive problem.Initially, there is an array $$$a = [1, 2, \ldots, n]$$$, where $$$n$$$ is an odd positive integer. The jury has selected $$$\frac{n-1}{2}$$$ disjoint pairs of elements, and then the elements in those pairs are swapped. For example, if $$$a=[1,2,3,4,5]$$$, and the pairs $$$1 \leftrightarrow 4$$$ and $$$3 \leftrightarrow 5$$$ are swapped, then the resulting array is $$$[4, 2, 5, 1, 3]$$$. As a result of these swaps, exactly one element will not change position. You need to find this element.To do this, you can ask several queries. In each query, you can pick two integers $$$l$$$ and $$$r$$$ ($$$1 \leq l \leq r \leq n$$$). In return, you will be given the elements of the subarray $$$[a_l, a_{l + 1}, \dots, a_r]$$$ sorted in increasing order. Find the element which did not change position. You can make at most $$$\mathbf{15}$$$ queries.The array $$$a$$$ is fixed before the interaction and does not change after your queries.Recall that an array $$$b$$$ is a subarray of the array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end.

Each test contains multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 500$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$3 \leq n < 10^4$$$; $$$n$$$ is odd) — the length of the array $$$a$$$. After reading the first line of each test case, you should begin the interaction. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^4$$$.

NoteIn the first test, the interaction proceeds as follows. SolutionJuryExplanation$$$\texttt{2}$$$There are 2 test cases.$$$\texttt{5}$$$In the first test case, the hidden array is $$$[4,2,5,1,3]$$$, with length $$$5$$$.$$$\texttt{? 1 4}$$$$$$\texttt{1 2 4 5}$$$The solution requests the subarray $$$[4,2,5,1]$$$ in increasing order, and the jury responds with $$$[1,2,4,5]$$$.$$$\texttt{? 3 5}$$$$$$\texttt{1 3 5}$$$The solution requests the subarray $$$[5,1,3]$$$ in increasing order, and the jury responds with $$$[1,3,5]$$$.$$$\texttt{! 2}$$$The solution has somehow determined that $$$a_2=2$$$, and outputs it. Since the output is correct, the jury continues to the next test case.$$$\texttt{3}$$$In the second test case, the hidden array is $$$[1,3,2]$$$, with length $$$3$$$.$$$\texttt{? 1 1}$$$$$$\texttt{1}$$$The solution requests the number $$$[1]$$$ only, and the jury responds with $$$[1]$$$.$$$\texttt{! 1}$$$The solution has determined that $$$a_1=1$$$, and outputs it. Since the output is correct and there are no more test cases, the jury and the solution exit. Note that the line breaks in the example input and output are for the sake of clarity, and do not occur in the real interaction.

function countIn(f, q) {
    var last = f + q.length;
    var count = 0;
    q.forEach(x => {
        if (x > f && x <= last) {
            count++;
        }
    });
    return count;
}

function check(s, e) {
    if (s == e) {
        return s + 1;
    }
    var mid = Math.floor((e + s) / 2);
    print(`? ${s+1} ${mid+1}`);
    var jury = readline().split(' ').map(x => parseInt(x));
    if (jury[0] == -1) {
        return -1;
    }
    var numIn = countIn(s, jury);
    // if odd
    if (numIn & 1) {
        return check(s, mid);
    } else {
        return check(mid+1, e);
    }
}

var tests = parseInt(readline());
for (var t=0; t < tests; t++) {
    var n = parseInt(readline());
    var answer = check(0, n-1);
    if (answer == -1) {
        break;
    }
    print(`! ${answer}`);
}

function countIn(f, q) {
    var last = s + q.length;
    var count = 0;
    q.forEach(x => {
        if (x > f && x <= last) {
            count++;
        }
    });
    return count;
}

function check(s, e) {
    if (s == e) {
        return s + 1;
    }
    var mid = Math.floor((e + s) / 2);
    print(`? ${s+1} ${mid+1}`);
    var jury = readline().split(' ').map(x => parseInt(x));
    if (jury[0] == -1) {
        return -1;
    }
    var numIn = countIn(s, jury);
    // if odd
    if (numIn & 1) {
        return check(s, mid);
    } else {
        return check(mid+1, e);
    }
}

var tests = parseInt(readline());
for (var t=0; t < tests; t++) {
    var n = parseInt(readline());
    var answer = check(0, n-1);
    if (answer == -1) {
        break;
    }
    print(`! ${answer}`);
}

function countIn(f, q) {
    var last = s + q.length;
    var count = 0;
    q.forEach(x => {
        if (x > f && x <= last) {
            count++;
        }
    });
    return count;
}

function check(s, e) {
    if (s == e) {
        return s + 1;
    }
    var mid = Math.floor((e + s) / 2);
    print(`? ${s+1} ${mid+1}`);
    var jury = readline().split(' ').map(x => parseInt(x));
    if (jury[0] == -1) {
        return -1;
    }
    var numIn = countIn(s, jury);
    // if odd
    if (numIn & 1) {
        return check(s, mid);
    } else {
        return check(mid+1, e);
    }
}

// paste code in main in CF
// always use var over let and const
// replace console.log with print
// don't parse arrays
// don't return
function main() {
    var tests = parseInt(readline());
    for (var t=0; t < tests; t++) {
        var n = parseInt(readline());
        var answer = check(0, n-1);
        if (answer == -1) {
            break;
        }
        print(`! ${answer}`);
    }
}


Alice and Borys are playing tennis.A tennis match consists of games. In each game, one of the players is serving and the other one is receiving.Players serve in turns: after a game where Alice is serving follows a game where Borys is serving, and vice versa.Each game ends with a victory of one of the players. If a game is won by the serving player, it's said that this player holds serve. If a game is won by the receiving player, it's said that this player breaks serve.It is known that Alice won $$$a$$$ games and Borys won $$$b$$$ games during the match. It is unknown who served first and who won which games.Find all values of $$$k$$$ such that exactly $$$k$$$ breaks could happen during the match between Alice and Borys in total.

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. Each of the next $$$t$$$ lines describes one test case and contains two integers $$$a$$$ and $$$b$$$ ($$$0 \le a, b \le 10^5$$$; $$$a + b > 0$$$) — the number of games won by Alice and Borys, respectively. It is guaranteed that the sum of $$$a + b$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.

For each test case print two lines. In the first line, print a single integer $$$m$$$ ($$$1 \le m \le a + b + 1$$$) — the number of values of $$$k$$$ such that exactly $$$k$$$ breaks could happen during the match. In the second line, print $$$m$$$ distinct integers $$$k_1, k_2, \ldots, k_m$$$ ($$$0 \le k_1 < k_2 < \ldots < k_m \le a + b$$$) — the sought values of $$$k$$$ in increasing order.

NoteIn the first test case, any number of breaks between $$$0$$$ and $$$3$$$ could happen during the match:   Alice holds serve, Borys holds serve, Alice holds serve: $$$0$$$ breaks;  Borys holds serve, Alice holds serve, Alice breaks serve: $$$1$$$ break;  Borys breaks serve, Alice breaks serve, Alice holds serve: $$$2$$$ breaks;  Alice breaks serve, Borys breaks serve, Alice breaks serve: $$$3$$$ breaks. In the second test case, the players could either both hold serves ($$$0$$$ breaks) or both break serves ($$$2$$$ breaks).In the third test case, either $$$2$$$ or $$$3$$$ breaks could happen:   Borys holds serve, Borys breaks serve, Borys holds serve, Borys breaks serve, Borys holds serve: $$$2$$$ breaks;  Borys breaks serve, Borys holds serve, Borys breaks serve, Borys holds serve, Borys breaks serve: $$$3$$$ breaks.

"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++];
}
function iInpArr() {
  return readline()
    .trim()
    .split(" ")
    .map((cur) => parseInt(cur));
}
function BInpArr() {
  return readline()
    .trim()
    .split(" ")
    .map((cur) => BigInt(cur));
}
function string() {
  return readline().trim();
}
function stringArr() {
  return readline().trim().split("");
}

function stringArr1() {
  return readline().trim().split(" ");
}
function getValue() {
  return parseInt(readline());
}
function iInpArr1() {
  return readline()
    .trim()
    .split("")
    .map((cur) => parseInt(cur));
}
let mod = 1e9 + 7;
mod = BigInt(mod);
const pow = (num, exp, mod) => {
  if (exp === BigInt(0)) return BigInt(1);
  let x = pow(num, exp / BigInt(2), mod);
  if (exp % BigInt(2)) return (((x * x) % mod) * num) % mod;
  else return (x * x) % mod;
};
const inverse = (num, exp) => {
  return pow(BigInt(num), BigInt(exp), BigInt(mod));
};
const sqrt = (n) => {
  let low = 1n,
    high = n,
    ans;
  while (low <= high) {
    let mid = (low + high) / 2n;
    if (mid * mid <= n) {
      ans = mid;
      low = mid + 1n;
    } else high = mid - 1n;
  }
  return ans;
};
const solve = () => {
  let t = getValue();
  while (t--) {
    let ans = [],
      obj = {};
    const push = (val) => {
      if (obj[val] === undefined) {
        ans.push(val);
        obj[val] = 1;
      }
    };
    let [a, b] = iInpArr();
    let right = Math.ceil((a + b) / 2);
    let left = Math.floor((a + b) / 2);
    let max = Math.max(a, b);
    let min = Math.min(a, b);
    let st = Math.abs(left - min);
    push(st);
    for (let i = 1; i <= min; i++) {
      push(st + i * 2);
    }
    let st1 = Math.abs(right - min);
    push(st1);
    for (let i = 1; i <= min; i++) {
      push(st1 + i * 2);
    }
    console.log(ans.length);
    console.log(ans.sort((a, b) => a - b).join(" "));
  }
};
solve();

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 [a, b] = rna();

		if (a > b)
			[a, b] = [b, a];

		let mb = Math.floor(Math.abs(a - b)/2);

		let times, inc;
		if ((a + b) % 2 == 0) {
			times = a + 1;
			inc = 2;
		} else {
			times = 2 * (a + 1);
			inc = 1;
		}

		const ans = [];
		for (let i = 0; i < times; i++) {
			ans.push(mb);
			mb += inc;
		}

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

function game(a,b){
  var p, x, q;
  p = Math.ceil((a+b)/2);
  q = a + b - p;
  var ans = new Set();
  for (var x=0; x<=p; x++){
    var y = a - (p-x);
    if(y<=q && y>=0) ans.add(x+y);
  }

  p = Math.floor((a+b)/2);
  q = a + b - p;

  for (var x=0; x<=p; x++){
    var y = a - (p-x);
    if(y<=q && y>=0) ans.add(x+y);
  }
  return Array.from(ans).sort(function(a, b) {
  return a - b;
});
}

var t = parseInt(readline());
var inp;

for (var i=0; i<t; i++){
    inp = readline().split(" ").map(x=>parseInt(x));
    var a = inp[0];
    var b = inp[1];
    var ans = game(a,b);
    print(ans.length);
    var s = "";
    for(item of ans){
        s += item + " ";
    }
    print(s);
}

"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++];
}
function iInpArr() {
  return readline()
    .trim()
    .split(" ")
    .map((cur) => parseInt(cur));
}
function BInpArr() {
  return readline()
    .trim()
    .split(" ")
    .map((cur) => BigInt(cur));
}
function string() {
  return readline().trim();
}
function stringArr() {
  return readline().trim().split("");
}

function stringArr1() {
  return readline().trim().split(" ");
}
function getValue() {
  return parseInt(readline());
}
function iInpArr1() {
  return readline()
    .trim()
    .split("")
    .map((cur) => parseInt(cur));
}
let mod = 1e9 + 7;
mod = BigInt(mod);
const pow = (num, exp, mod) => {
  if (exp === BigInt(0)) return BigInt(1);
  let x = pow(num, exp / BigInt(2), mod);
  if (exp % BigInt(2)) return (((x * x) % mod) * num) % mod;
  else return (x * x) % mod;
};
const inverse = (num, exp) => {
  return pow(BigInt(num), BigInt(exp), BigInt(mod));
};
const sqrt = (n) => {
  let low = 1n,
    high = n,
    ans;
  while (low <= high) {
    let mid = (low + high) / 2n;
    if (mid * mid <= n) {
      ans = mid;
      low = mid + 1n;
    } else high = mid - 1n;
  }
  return ans;
};
const solve = () => {
  let t = getValue();
  while (t--) {
    let ans = [],
      obj = {};
    const push = (val) => {
      if (obj[val] === undefined) {
        ans.push(val);
        obj[val] = 1;
      }
    };
    let [a, b] = iInpArr();
    let right = Math.ceil((a + b) / 2);
    let left = Math.floor((a + b) / 2);
    let max = Math.max(a, b);
    let min = Math.min(a, b);
    let st = Math.abs(right - max);
    push(st);
    for (let i = 1; i <= min; i++) {
      push(i * 2);
    }
    let st1 = Math.abs(right - min);
    push(st1);
    for (let i = 1; i <= min; i++) {
      push(st1 + i * 2);
    }
    console.log(ans.length);
    console.log(ans.sort((a, b) => a - b).join(" "));
  }
};
solve();

function game(a,b){
  var p, x, q;
  p = Math.ceil((a+b)/2);
  q = a + b - p;
  var ans = new Set();
  for (var x=0; x<=p; x++){
    var y = a - (p-x);
    if(y<=q && y>=0) ans.add(x+y);
  }

  p = Math.floor((a+b)/2);
  q = a + b - p;

  for (var x=0; x<=p; x++){
    var y = a - (p-x);
    if(y<=q && y>=0) ans.add(x+y);
  }
  return Array.from(ans).sort();
}

var t = parseInt(readline());
var inp;

for (var i=0; i<t; i++){
    inp = readline().split(" ").map(x=>parseInt(x));
    var a = inp[0];
    var b = inp[1];
    var ans = game(a,b);
    print(ans.length);
    var s = "";
    for(item of ans){
        s += item + " ";
    }
    print(s);
}

function game(a,b){
  var p, x, q;
  p = Math.ceil((a+b)/2);
  q = a + b - p;
  var ans = new Set();
  for (var x=0; x<=p; x++){
    var y = a - (p-x);
    if(y<=q && y>=0) ans.add(x+y);
  }

  p = Math.floor((a+b)/2);
  q = a + b - p;

  for (var x=0; x<=p; x++){
    var y = a - (p-x);
    if(y<=q && y>=0) ans.add(x+y);
  }
  return ans;
}

var t = parseInt(readline());
var inp;

for (var i=0; i<t; i++){
    inp = readline().split(" ").map(x=>parseInt(x));
    var a = inp[0];
    var b = inp[1];
    var ans = game(a,b);
    print(ans.size);
    var s = "";
    for(item of ans){
        s += item + " ";
    }
    print(s);
}

function game(a,b){
  var p, x, q;
  p = Math.ceil((a+b)/2);
  q = a + b - p;
  var ans = new Set();
  for (var x=0; x<=p; x++){
    var y = a - (p-x);
    if(y<=q && y>=0) ans.add(x+y);
  }

  p = Math.floor((a+b)/2);
  q = a + b - p;

  for (var x=0; x<=p; x++){
    var y = a - (p-x);
    if(y<=q && y>=0) ans.add(x+y);
  }
  return ans;
}

var t = parseInt(readline());
var inp;

for (var i=0; i<t; i++){
    inp = readline().split(" ").map(x=>parseInt(x));
    var a = inp[0];
    var b = inp[1];
    var ans = game(a,b);
    for(item of ans){
        print(item);
    }
}


Polycarp is very careful. He even types numeric sequences carefully, unlike his classmates. If he sees a sequence without a space after the comma, with two spaces in a row, or when something else does not look neat, he rushes to correct it. For example, number sequence written like "1,2 ,3,...,   10" will be corrected to "1, 2, 3, ..., 10".In this task you are given a string s, which is composed by a concatination of terms, each of which may be:   a positive integer of an arbitrary length (leading zeroes are not allowed),  a "comma" symbol (","),  a "space" symbol (" "),  "three dots" ("...", that is, exactly three points written one after another, also known as suspension points). Polycarp wants to add and remove spaces in the string s to ensure the following:   each comma is followed by exactly one space (if the comma is the last character in the string, this rule does not apply to it),  each "three dots" term is preceded by exactly one space (if the dots are at the beginning of the string, this rule does not apply to the term),  if two consecutive numbers were separated by spaces only (one or more), then exactly one of them should be left,  there should not be other spaces. Automate Polycarp's work and write a program that will process the given string s.

The input data contains a single string s. Its length is from 1 to 255 characters. The string s does not begin and end with a space. Its content matches the description given above.

Print the string s after it is processed. Your program's output should be exactly the same as the expected answer. It is permissible to end output line with a line-break character, and without it.

'use strict';

/*let input = `......,,,,,......  1234 1234  1234 , 1234 ...   ,   1234 ...   1234   ... ,   1234`.split('\n');
function print(output) {
	console.log(output);
}
function readline() {
	return input.shift();
}*/

//code

var inpStr = readline();
var inpArr = inpStr.trim().split('').reduce(function (acc, val, i, arr) {
	if (val !== " " || !(isNaN(parseInt(acc[acc.length - 1])) || isNaN(parseInt(arr[i + 1])))) {
		acc.push(val);
	}
	return acc;
}, []);

for (var i = 0; i < inpArr.length; i++) {
	if (inpArr[i] === ",") {
		inpArr.splice(i + 1, 0, " ");
		i++;
	} else if (inpArr[i] === "." && inpArr[i + 1] === "." && inpArr[i + 2] === ".") {
		if (inpArr[i - 1] !== " ") {
			inpArr.splice(i, 0, " ");
			i += 3;
		} else {
			i += 2;
		}
	}
}

print(inpArr.join('').trim());

'use strict'

const {EOL} = require('os')

let ipt = ''
process.stdin.on('data', s => ipt += s)
process.stdin.on('end', () => {
  let s = ipt.split(EOL)[0]
  console.log(s
    .replace(/(\d)\s+(?=\d)/g, '$1*')
    .replace(/\s/g, '')
    .replace(/,/g, ', ')
    .replace(/\s?\.\.\./g, ' ...')
    .replace(/\*/g, ' ')
    .trim())
})

str = readline();
str = str.replace(/(\d+) +(\d+)/g, '$1_$2');
str = str.replace(/(\d+) +(\d+)/g, '$1_$2');
str = str.replace(/ /g, '');
str = str.replace(/_/g, ' ');
str = str.replace(/,/g, ', ');
str = str.replace(/\.\.\./g, ' ...');
str = str.replace(/  +/g, ' ');
str = str.replace(/ $/g, '');
str = str.replace(/^ /g, '');
write(str);

'use strict';

/*let input = `1  2     3 6 4 545 45 12`.split('\n');
function print(output) {
	console.log(output);
}
function readline() {
	return input.shift();
}*/

//code

var inpStr = readline();
var inpArr = inpStr.trim().split('').reduce(function (acc, val, i, arr) {
	if (val !== " " || !(isNaN(parseInt(acc[acc.length - 1])) || isNaN(parseInt(arr[i + 1])))) {
		acc.push(val);
	}
	return acc;
}, []);

for (var i = 0; i < inpArr.length; i++) {
	if (inpArr[i] === ",") {
		inpArr.splice(i + 1, 0, " ");
	} else if (inpArr[i] === "." && inpArr[i + 1] === "." && inpArr[i + 2] === "." && inpArr[i - 1] !== " ") {
		inpArr.splice(i, 0, " ");
		i += 3;
	}
}

print(inpArr.join('').trim());

'use strict';

/*let input = `...,1,2,3,...`.split('\n');
function print(output) {
	console.log(output);
}
function readline() {
	return input.shift();
}*/

//code

var inpStr = readline();
var inpArr = inpStr.split('').filter(function (el) {
	return el != " ";
});
for (var i = 0; i < inpArr.length; i++) {
	if (inpArr[i] === ",") {
		inpArr.splice(i + 1, 0, " ");
	} else if (inpArr[i] === "." && inpArr[i + 1] === "." && inpArr[i + 2] === "." && inpArr[i - 1] !== " ") {
		inpArr.splice(i, 0, " ");
		i += 3;
	}
}
print(inpArr.join('').trim());

str = readline();
str = str.replace(/ /g, '');
str = str.replace(/,/g, ', ');
str = str.replace(/\.\.\./g, ' ...');
str = str.replace(/  +/g, ' ');
str = str.replace(/ $/g, '');
str = str.replace(/^ /g, '');
write(str);

str = readline();
str = str.replace(/,/g, ', ');
str = str.replace(/(\d+?) +?,/g, '$1,');
str = str.replace(/\.\.\./g, ' ...');
str = str.replace(/  +/g, ' ');
str = str.replace(/ $/g, '');
str = str.replace(/^ /g, '');
write(str);

str = readline();
str = str.replace(/(\d+?) +?(\d+?)/g, '$1')
str = str.replace(/,/g, ', ');
str = str.replace(/(\d+?) +/g, '$1');
str = str.replace(/\.\.\./g, ' ...');
str = str.replace(/  +/g, ' ');
str = str.replace(/ $/g, '');
str = str.replace(/^ /g, '');
write(str);

'use strict'

const {EOL} = require('os')

let ipt = ''
process.stdin.on('data', s => ipt += s)
process.stdin.on('end', () => {
  let s = ipt.split(EOL)[0]
  console.log(s
    .replace(/(\d)\s+(\d)/, '$1*$2')
    .replace(/\s/g, '')
    .replace(/,/g, ', ')
    .replace(/\s?\.\.\./g, ' ...')
    .replace(/\*/g, ' ')
    .trim())
})


An array $$$a_1, a_2, \ldots, a_n$$$ is good if and only if for every subsegment $$$1 \leq l \leq r \leq n$$$, the following holds: $$$a_l + a_{l + 1} + \ldots + a_r = \frac{1}{2}(a_l + a_r) \cdot (r - l + 1)$$$. You are given an array of integers $$$a_1, a_2, \ldots, a_n$$$. In one operation, you can replace any one element of this array with any real number. Find the minimum number of operations you need to make this array good.

The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$): the number of test cases. Each of the next $$$t$$$ lines contains the description of a test case. In the first line you are given one integer $$$n$$$ ($$$1 \leq n \leq 70$$$): the number of integers in the array. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$-100 \leq a_i \leq 100$$$): the initial array.

For each test case, print one integer: the minimum number of elements that you need to replace to make the given array good.

NoteIn the first test case, the array is good already.In the second test case, one of the possible good arrays is $$$[1, 1, \underline{1}, \underline{1}]$$$ (replaced elements are underlined).In the third test case, the array is good already.In the fourth test case, one of the possible good arrays is $$$[\underline{-2.5}, -2, \underline{-1.5}, -1, \underline{-0.5}, 0]$$$.

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 isEqual (a, b) {
	const prec = 1e-3;
	return Math.abs(a - b) < prec;
}

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

		let mxm = 1;
		for (let i = 0; i < n; i++) {
			for (let j = i + 1; j < n; j++) {
				const d = (a[j] - a[i]) / (j-i);
				const A = a[j] - a[i];
				const B = j - i;
				let matches = 0;
				for (let k = 0; k < n; k++) {
					matches += B*a[k] ==  B*a[i] + A*(k-i);
				}
				mxm = Math.max(mxm, matches);
			}
		}

		console.log(n-mxm);
	}
}

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

const INF = 1000;

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

		let mxm = 1;
		for (let i = 0; i < n; i++) {
			for (let j = i + 1; j < n; j++) {
				const d = (a[j] - a[i]) / (j-i);
				let matches = 0;
				for (let k = 0; i+k < n; k++) {
					matches += Math.abs(a[i+k] - (a[i] + d*k)) < 1e-3;
				}
				mxm = Math.max(mxm, matches);
			}
		}

		console.log(n-mxm);
	}
}

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

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

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

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

// SOLUTION:
IS_MULTITEST = 1;

const calc = ()=>{
  // READING:
  let [n] = ra();
  let A = ra();
  LT({n, A});

  // PROCESSING:
  let min = n-1;
  for (let i=0; i<n; i++){
    for (let j=i+1; j<n; j++){
      let step = (A[j]-A[i])/(j-i);
      let cnt = 0;
      for (let k=0; k<n; k++){
        if (Math.abs(A[i]-step*(i-k) - A[k])>0.000001)
          cnt++;
      }
      min = Math.min(cnt, min)
    }
  }
  return min;
};

let _inputLines;
let _lineNumber = 0;
let inputReader = _inputReader();

function _main() {
  _inputLines = _inputData
    .trim()
    .split("\n")
    .map((string) => {
      return string.trim();
    });

  let t = inputReader.readNumber();

  function solve() {
    let n = inputReader.readNumber();
    let a = inputReader.readNumberArray();
    let ans = Infinity;
    for (let i = 0; i < n; i++) {
      for (let j = i + 1; j < n; j++) {
        let cur = 0;
        for (let k = 0; k < n; k++) {
          if ((a[j] - a[i]) * (k - i) != (a[k] - a[i]) * (j - i)) cur++;
        }
        ans = Math.min(ans, cur);
      }
    }
    console.log(ans == Infinity ? 0 : ans);
  }

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

var _inputData = "";
function cacheInput(data) {
  _inputData += data;
}

process.stdin.resume();
process.stdin.setEncoding("utf8");
process.stdin.on("data", cacheInput).on("end", _main);

function _inputReader() {
  function readNumber() {
    return Number(_inputLines[_lineNumber++]);
  }

  function readNumberArray() {
    return _inputLines[_lineNumber++].split(" ").map((val) => Number(val));
  }

  return {
    readNumber,
    readNumberArray,
  };
}

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

const INF = 1000;

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

		let mxm = 1;
		for (let i = 0; i < n; i++) {
			for (let j = i + 1; j < n; j++) {
				const d = (a[j] - a[i])/ (j-i);
				let matches = 0;
				for (let k = 0; i+k < n; k++) {
					matches += a[i+k] == a[i] + d*k;
				}
				mxm = Math.max(mxm, matches);
			}
		}

		console.log(n-mxm);
	}
}