package cf3

import kotlin.math.absoluteValue

fun main() {
    val testcases = readLine()!!.toInt()
    repeat(testcases) {
        readLine()!!.toInt()
        val programmers = readLine()!!.split(" ").map { it.toInt() }
        println(solve(programmers).joinToString(" "))
    }
}

private fun solve(programmers: List<Int>): List<Int> {
    val contributors = programmers.filter { it > 0 }
    val smallestContributor = contributors.min().takeIf { contributors.size > 1 }
    val smallestDistraction = programmers.filter { it < 0 }.max()

    val includeDistraction = smallestContributor == null || (smallestDistraction != null && smallestDistraction.absoluteValue < smallestContributor)

    var cut = false
    return programmers.map {
        when {
            includeDistraction && it == smallestDistraction && !cut  -> 1.also { cut = true }
            it <= 0                                                  -> 0
            !includeDistraction && it == smallestContributor && !cut -> 0.also { cut = true }
            else                                                     -> 1
        }

    }
}


#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);

  return 0;
}


import java.lang.Integer.max
import java.lang.Integer.min
import java.util.*

fun main() {
  val t = readInt()
    repeat(t){
        val n = readInt()
        val a = readInts()
        val sor = a.withIndex().sortedByDescending { it.value }
        val res = Array<Int>(n){0}
        var sum = 0
        var mineg = -1
        var mimax = 0
        for(i in 0 until n){
            if(sor[i].value > 0 && ((i == n-1) || ( sor[i+1].value <= 0))) mimax = i
            if(sor[i].value < 0) {
                mineg = i
                break
            }
        }
        for(i in 0 until n){
            if(sor[i].value > 0) {
                res[sor[i].index] = 1
                sum += sor[i].value
            }
        }
        if(mineg >= 0 && (sor[mineg].value*-1 < sor[mimax].value)){
            res[mineg] = 1
            sum += sor[mineg].value
        } else {
            res[mimax] = 0
            sum -= sor[mimax].value
        }
        println(sum)
        for(i in 0 until n) if(res[i] > 0) print("1") else print("0")
        println()
    }
}


fun solve(inputReader: () -> String?, output: (String) -> Unit) {
    val testCaseCount = inputReader()!!.toInt()
    for(i in 0 until testCaseCount) {
        val developerCount = inputReader()!!.toInt()
        val developers = inputReader()!!.split(' ').map { it.toInt() }
        val maxSum = developers.filter { it > 0 }.sum()
        val greatestNegativeDeveloper = developers.filter { it < 0 }.max() ?: -Int.MAX_VALUE
        val weakestPositiveDeveloper = developers.filter { it > 0 }.min() ?: Int.MAX_VALUE
        if (Math.abs(greatestNegativeDeveloper) < weakestPositiveDeveloper) {
            var found = false;
            val answer = developers.joinToString(separator = "") {
                if (it > 0) {
                    "1"
                } else {
                    if (!found && greatestNegativeDeveloper == it) {
                        found = true
                        "1"
                    } else {
                        "0"
                    }
                }
            }
            output((maxSum+greatestNegativeDeveloper).toString())
            output(answer)
        } else {
            var found = false;
            val answer = developers.joinToString(separator = "") {
                if (it > 0) {
                    if (!found && weakestPositiveDeveloper == it) {
                        found = true
                        "0"
                    } else {
                        "1"
                    }
                } else {
                    "0"
                }
            }
            output((maxSum-weakestPositiveDeveloper).toString())
            output(answer)
        }
    }
}

fun main() {
    solved.solve(::readLine, ::println)
}


package Real

fun main() {
    val count = readLine()!!.toLong()

    for (i in 0 until count) {
        val nums = readLine()!!.toLong()

        val dvs = readLine()!!.split(" ").map { it.toLong() }
        val positiveList = dvs.withIndex().filter { it.value> 0 }.toMutableList()
        val max = positiveList.fold(0L) {acc,it-> acc+it.value }

        val minusMax = dvs.withIndex().filter { it.value < 0 }.maxBy {
            it.value
        }
        val positiveMin = positiveList.minBy { it.value }

        var result =max
        if(minusMax?.value ?: -9999999 < positiveMin?.value?.unaryMinus()?: -9999999){
            positiveMin?.index?.let{ positiveList.removeAt(it)}
            result += positiveMin?.value?.unaryMinus()?: -9999999
        }else{
            minusMax?.let{ positiveList.add(it)}
            result += minusMax?.value ?: -9999999
        }

        println(result)
        dvs.withIndex().forEach {
          if( positiveList.contains(it)) print("1")
            else print("0")
        }
        println()
    }
}


import Advance.add
import java.util.*
import java.util.Collections.max
import kotlin.collections.ArrayList
import kotlin.collections.HashMap
import kotlin.math.max
import kotlin.math.min
import kotlin.math.round

fun rs() = readLine()!!
fun ri() = rs().toInt()
fun rsl() = rs().split(" ")
fun ril() = rsl().map{it.toInt()}

fun main(args: Array<String>)
{
    var t = ri();
    while(t-->0)
    {
        val n=ri()
        val arr = ril()
        var maxneg = Int.MIN_VALUE
        var minpos = Int.MAX_VALUE
        var mpi = -1
        var mni = -1
        var sum = 0
        val brr = Array<Int>(n){0}
        for( i in 0..(n-1)){

            if(arr[i]<0){
                if(maxneg<arr[i]) {
                    maxneg = arr[i];
                    mni = i
                }

            }
            else{
                brr[i] = 1
                if(arr[i]!=0 && arr[i]<minpos) {
                        minpos = arr[i]
                        mpi = i
                }
                sum+=arr[i]
            }

        }
        if(maxneg!= Int.MIN_VALUE && -maxneg<minpos){
            sum+=maxneg
            brr[mni]=1;
        }
        else{
            sum-=minpos
            brr[mpi]=0;
        }
        println(sum)
        brr.forEach { print(it) }
        println()

    }

}


package cf3

import kotlin.math.absoluteValue

fun main() {
    val testcases = readLine()!!.toInt()
    repeat(testcases) {
        val bench = readLine()!!.toInt()
        val programmers = readLine()!!.split(" ").map { it.toInt() }
        println(solve(programmers).joinToString(" "))
    }
}

private fun solve(programmers: List<Int>): List<Int> {
    val contributors = programmers.filter { it > 0 }
    val smallestContributor = contributors.min().takeIf { contributors.size > 1 }
    val smallestDistraction = programmers.filter { it < 0 }.max()

    val includeDistraction = smallestContributor == null || (smallestDistraction != null && smallestDistraction.absoluteValue < smallestContributor)

    var cut = false
    return programmers.map {
        when {
            includeDistraction && it == smallestDistraction && !cut  -> 1.also { cut = true }
            it <= 0                                                  -> 0
            !includeDistraction && it == smallestContributor && !cut -> 0.also { cut = true }
            else                                                     -> 1
        }

    }
}


fun main() {
    val t = readLn().toInt()
    for (i in 0 until t) {
        val n = readLn().toInt()
        val ar = readIntList()
        go(ar, n)
    }
}

fun go(ar: List<Int>, n: Int) {
    var (greater, less) = ar.withIndex().partition { (i, v) -> v > 0 }
    less = less.filter { (i, v) -> v != 0 }
    var sum = greater.sumBy { (i, v) -> v }
    val maxNeg = less.maxBy { (i, v) -> v }
    val minPositive = greater.minBy { (i, v) -> v }!!

    val value = maxNeg?.value ?: 0
    val removeNeg = sum + value
    val removePosit = sum - minPositive.value

    val result = greater.toMutableList()
    if (maxNeg != null && removeNeg > removePosit) {
        result.add(maxNeg)
        println(removeNeg)
    } else {
        println(removePosit)
        result.remove(minPositive)
    }

    val toSet = result.map { (i, v) -> i }.toSet()
    for (i in 0 until n) {
        if (toSet.contains(i)) {
            print(1)
        } else {
            print(0)
        }
    }
    println()
}

var debugEnabled = false

fun readLn() = readLine()!!

fun readIntList() = solved.readLn().split(' ').map { it.toInt() }
fun readIntArray() = solved.readLn().split(' ').map { it.toInt() }.toIntArray()
fun debLn(str: String) {
    if (solved.debugEnabled) {
        println(str)
    }
}

fun deb(str: String) {
    if (solved.debugEnabled) {
        print(str)
    }
}


import kotlin.test.assertTrue

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints

private fun solve() {
    val n = readInt()
    val aa = readInts()
    val aap = aa.filter { it > 0 }
    val perfect = aap.sum()
    val pmin = aap.min()!!
    val nmax = aa.filter { it < 0 }.max()
    if (nmax == null || pmin <= -nmax) {
        println(perfect - pmin)
        var removed = false
        for (a in aa) {
            if ((a > 0) && (removed || a != pmin)) {
                print(1)
            } else {
                print(0)
            }
            if (a == pmin) {
                removed = true
            }
        }
    }
    else {
        println(perfect+nmax)
        var added = false
        for (a in aa) {
            if (a > 0 || (!added && a == nmax)) {
                print(1)
            }
            else {
                print(0)
            }
            if (a == nmax) {
                added = true
            }
        }
    }
    println()
}

fun main() {
    val t = readInt()
    repeat(t) {
        solve()
    }
}


import solved.readLn

fun main() {
    val t = readLn().toInt()
    for (i in 0 until t) {
        val n = readLn().toInt()
        val ar = readIntList()
        go(ar, n)
    }
}

fun go(ar: List<Int>, n: Int) {
    var (greater, less) = ar.withIndex().partition { (i, v) -> v > 0 }
    less = less.filter { (i, v) -> v != 0 }
    var sum = greater.sumBy { (i, v) -> v }
    val maxNeg = less.maxBy { (i, v) -> v }
    val minPositive = greater.minBy { (i, v) -> v }!!

    val value = maxNeg?.value ?: 0
    val removeNeg = sum + value
    val removePosit = sum - minPositive.value

    val result = greater.toMutableList()
    if (maxNeg != null && removeNeg > removePosit) {
        result.add(maxNeg)
        println(removeNeg)
    } else {
        println(removePosit)
        result.remove(minPositive)
    }

    val toSet = result.map { (i, v) -> i }.toSet()
    for (i in 0 until n) {
        if (toSet.contains(i)) {
            print(1)
        } else {
            print(0)
        }
    }
    println()
}

var debugEnabled = false

fun readLn() = readLine()!!

fun readIntList() = solved.readLn().split(' ').map { it.toInt() }
fun readIntArray() = solved.readLn().split(' ').map { it.toInt() }.toIntArray()
fun debLn(str: String) {
    if (solved.debugEnabled) {
        println(str)
    }
}

fun deb(str: String) {
    if (solved.debugEnabled) {
        print(str)
    }
}


import java.util.*
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextInts() = next().split(" ").map { it.toInt() }
fun nextLongs() = next().split(" ").map { it.toLong() }
val OUT = mutableListOf<String>()

fun solve() {
  var n = nextInt()
  var a = nextInts()
  var b = mutableListOf<Int>()
  var lo = 10000
  for (i in 0..n-1) {
    if (a[i] != 0) {
      lo = Math.min(lo, Math.max(a[i], -a[i]))
    }
  }
  var ans = "0".repeat(n)
  var tmp = StringBuilder(n)
  var fl = 0
  var sm = 0
  for (i in 0..n-1) {
    if (fl == 0 && (a[i] == lo || a[i] == -lo)) {
      if (a[i] != lo) {
        tmp[i] = "1"
        ans[i] = "1"
        sm += a[i]
      }
      fl = 1
    } else if (a[i] >= 0) {
      ans[i] = "1"
      sm += a[i]
    } else {
    }
  }
  OUT += "$sm\n$ans"
}

fun main() {
  var T = nextInt()
  for (i in 1..T) {
    solve()
  }
  println(OUT.joinToString("\n"))
}


import kotlin.streams.asStream

fun main() {
    val input = generateSequence(::readLine)
    input.asStream().skip(1).forEach { line ->
        println()
        val total = line.toInt()
        if (total % 2 != 0) print((total - 1) / 2) else print((total - 2) / 2)
    }
}


fun main() {
    var t = readLine()!!.toInt() // read integer from the input
    while(t --) {
        var n = readLine()!!.toInt()
        var ans = max(0, n / 2 - 1)
        if(n > 0)
            ans += n % 2
        println(ans);
    }
}


import java.util.Scanner
fun main(){
    val reader= Scanner(System.`in`)
    var t:Int
    var a:Int
    t=reader.nextInt()
    for (i in 0..t-1){
        a=reader.nextInt()
        println("${max(floor((a-1)/2), 0)}")
    }
}


private fun readLn() = readLine()!!
private fun readInt() = readLn().toInt()
private fun readStrings() = readLn().split(" ")
private fun readInts() = readStrings().map { it.toInt() }

fun main() {
    val lines = readInt()
    for (line in 1..lines) {
        val number = readInts()
        println((number-1)//2)
    }
}


fun readInts() = readLine()!!.split(' ').map { it.toInt() }

fun main() {
  val tests_cnt = readInts()
  for (i in 1..tests_cnt[0]) {
    val a = readInts()
    if(a > 2) println (a/2).toInt()
    else println 0
  }
}


package practice.five

import kotlin.math.roundToInt

fun main() {
    val numTests = readLine()!!.toInt()
    repeat(numTests) {
        val numCandies = readLine()!!.toInt()
        println(distributeCandy(numCandies))
    }
    // listOf(7, 1, 2, 3, 2000000000, 763243547).forEach {
    //     println(distributeCandy(it))
    // }
}

fun distributeCandy(count: Int): Int {
    val aliceMin = ((count.toDouble() / 2) + 0.5).roundToInt()
    return count - aliceMin
}


import java.util.*
val scan = Scanner(System.`in`)
fun main() {
	val b = scan.nextInt()
	for (i 1..b){
	    val a = scan.nextInt()
    	print((a-1)/2)
    }
}


import java.util.Scanner

fun main(args: Array<String>) {

    val reader = Scanner(System.`in`)
    var t:Int = reader.nextInt()

    for(index in 1..t){

        var n:Int = reader.nextInt()
        var ans:Int
        if((n+1)/2>n/2){
            ans=n-(n+1)/2
        }else{
            ans=n-n/2-1
        }
        println("$sum")
    }


package kotlinBasics

fun main() {
    val n = readLine()!!.toInt()
    val a = IntArray(n)
    for (i in 0..a.lastIndex) {
        a[i] = readLine()!!.toInt()

    }
    for (i in 0..a.lastIndex) {
        var o = a[i] /2
        if (a[i] % 2 == 0) {
            println(o - 1)
        } else {
            println(o)
        }
    }
}


import java.lang.AssertionError

private fun readLn() = readLine()!!
private fun readInt() = readLn().toInt()
private fun readLong() = readLn().toLong()
private fun readDouble() = readLn().toDouble()
private fun readStrings() = readLn().split(" ")
private fun readInts() = readStrings().map { it.toInt() }
private fun readLongs() = readStrings().map { it.toLong() }
private fun readDoubles() = readStrings().map { it.toDouble() }

private fun myAssert(x: Boolean) {
    if (!x) {
        throw AssertionError()
    }
}

fun main(args: Array<String>) {
    var tt = readInt()
    for (qq in 0 until tt) {

        var (n) = readInt()
        var ans = 0
        if(n<=2) var=0
        else var=(n-1)/2

        println(var)

    }
}


fun main(args: Array<String>) {
	val tests: Int = readLine()!!.toInt()
	if (tests in 1..10000) {
		val candies: Int = readLine()!!.toInt()
		var noOFPossibilities: Int = 0
		if (candies >= 3 && candies <= (2 * (10.0f).pow(9))) {
			var a: Int = candies - 1
			var b: Int = 1
			while (a + b == candies) {
				noOFPossibilities += 1
				a -= 1
				b +=1
			}
			println(noOFPossibilities)
		} else {
			println(noOFPossibilities)
		}
	}
}


import java.util.*
import java.io.*
import java.math.*

fun main(args : Array<String>) {
    val input = Scanner(System.`in`)
    val N = input.nextInt()
    for (i in 1..N) {
        val BB = input.nextInt()
        val A = BB-1
        val B = 1
        val count = 0
        while (A > B) {
            count += 1
        }
        println(count)
    }
}


fun readInts() = readLine()!!.split(' ')

fun main() {
  val tests_cnt = readInts().map { it.toInt() }
  for (i in 1..tests_cnt[0]) {
    val a = readInts().map { it.toBigInteger() }
    if(a > 2) println((a/2).toBigInteger())
    else println(0)
  }
}


package dsa

import java.util.*
import kotlin.math.*
@JvmField val INPUT = System.`in`
@JvmField val OUTPUT = System.out
@JvmField val _reader = INPUT.bufferedReader()
fun readLine(): String? = _reader.readLine()
fun readLn() = _reader.readLine()!!
@JvmField var _tokenizer: StringTokenizer = StringTokenizer("")
fun read(): String {
    while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return "", " ")
    return _tokenizer.nextToken()
}
fun readInt() = read().toInt()
fun readDouble() = read().toDouble()
fun readLong() = read().toLong()
fun readStrings(n: Int) = List(n) { read() }
fun readLines(n: Int) = List(n) { readLn() }
fun readInts(n: Int) = List(n) { read().toInt() }
fun readIntArray(n: Int) = IntArray(n) { read().toInt() }
fun readDoubles(n: Int) = List(n) { read().toDouble() }
fun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }
fun readLongs(n: Int) = List(n) { read().toLong() }
fun readLongArray(n: Int) = LongArray(n) { read().toLong() }
fun gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b)
fun gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b)
fun Boolean.toInt() = if (this) 1 else 0
val INF = 0x3f3f3f3f
val MOD = (1e9 + 7).toLong()
/***********************************************************************************************/

fun main() {
    var t = readInt()
    for (i in 1..t) {
        var a: Int = readInt()
        var poss: Int = 0
        if (a % 2 == 0) {
            println(a / 2 - 1)
        } else {
            println(a / 2)
        }
    }
}


fun main() {
    repeat(readLine()!!.toInt()) {
        val n = readLine()!!.toInt()
        var ans = 0
        if (n and 1)
            ans = n / 2
        else
            ans = n / 2 - 1
        if (ans < 0) ans = 0
        println(ans)
    }
}


import java.util.Scanner

fun main(args: Array<String>) {
    // Your code here!
    val reader = Scanner(System.`in`)
    var n:Int = reader.nextInt()

    while (n-- != 0) {
        var x:Int = reader.nextInt()
        if ((x.toDouble() / 2) != (x / 2)) {
            println(x / 2)
        } else {
            if (x / 2 == 0) {
                println(0)
            } else {
                println(x/2 - 1)
            }
        }
    }
}


import java.util.*

private fun min(a : Long , b : Long ) : Long
{
	if(a < b)
		return a;
	else
		return b;
}

fun main(args: Array<String>) {
    var q = readLine()!!.toLong();
    while(q --> 0)
    {
    	n = readLine().toLong()
    	println((n-1)/2)

    }

}


import java.util.Scanner
fun main(args: Array<String>) {
    var t = read.nextInt()
    for (i in t) {
       var n = read.nextInt()
       println((n-1)/2)
    }
}


fun main() {
    var t = readLine()!!.toInt() // read integer from the input
    for(i in 0 until t) {
        var n = readLine()!!.toInt()
        var ans = max(0, n / 2 - 1)
        if(n > 0)
            ans += n % 2
        println(ans)
    }
}


fun main() {
    var n = getInteger()
    for (i in 0 until n) {
       	var candies = getInteger()
        println(candies / 2 - (candies % 2) == 0 ? 1 : 0)
    }
}

fun getIntegers(): List<Int> {
    var input = (readLine()!!).split(' ')
    return input.map{it.toInt()}
}

fun getInteger(): Int {
    return (readLine()!!).toInt()
}


import java.math.BigInteger

/**
 *   @author Ulire
 *   @date 2020/11/12 13:28
 **/

suspend fun main() {
    val t =readLine()!!.toInt();
    IntRange(1,t).forEach { _ ->
        run {
            println(readLine()!!.toBigInteger().minus(BigInteger.ONE).divide(BigInteger.TWO))
        }
    }
}


private fun readLn() = readLine()!!
private fun readInt() = readLn().toInt()
private fun readStrings() = readLn().split(" ")
private fun readInts() = readStrings().map { it.toInt() }

fun main() {
    val lines = readInt()
    for (line in 1..lines) {
        val number = readInts()
        println((number-1)/2)
    }
}


fun main() {
    val scanner = Scanner(System.`in`)
    val numberOfTestCases = scanner.nextInt()
    for (i in 0 until numberOfTestCases) {
        val numberOfCandies = scanner.nextInt()
        println(ceil(numberOfCandies / 2.0).toInt() - 1)
    }
}


import java.util.*
fun main(){
   val input=Scanner(System.`in`)
   var t:Int=input.nextInt()
   while(t>0){
    var b:Double =input.nextDouble()
    var a:Int=(b/2).toInt()
    if(a*2==b){
       a--
      println("$a")
    }
    else{
        println("$a")
    }
    t--
   }
}


import java.lang.AssertionError

private fun readLn() = readLine()!!
private fun readInt() = readLn().toInt()
private fun readLong() = readLn().toLong()
private fun readDouble() = readLn().toDouble()
private fun readStrings() = readLn().split(" ")
private fun readInts() = readStrings().map { it.toInt() }
private fun readLongs() = readStrings().map { it.toLong() }
private fun readDoubles() = readStrings().map { it.toDouble() }

private fun myAssert(x: Boolean) {
    if (!x) {
        throw AssertionError()
    }
}

fun main(args: Array<String>) {
    var tt = readInt()
    for (qq in 0 until tt) {

        var (n) = readInt()
        var ans = 0
        if(n<=2) ans=0
        else ans=(n-1)/2

        println(ans)

    }
}


import java.util.Scanner

fun main(args: Array<String>) {

    val reader = Scanner(System.`in`)
    var t:Int = reader.nextInt()

    for(index in 1..t){

        var n:Int = reader.nextInt()
        var ans:Int
        if((n+1)/2>n/2){
            ans=n-(n+1)/2
        }else{
            ans=n-n/2-1
        }
        println("$ans")
    }


    fun readInts() = readLine()!!.split(' ')

    fun main() {
        val tests_cnt = readInts().map { it.toInt() }
        for (i in 1..tests_cnt[0]) {
            val a  = readInts().map { it.toBigInteger() }
            if(a[0] > 2.toBigInteger()) {
                if(a[0].mod(2) == 0) {
                  println(a[0]/2.toBigInteger() - 1)
                } else {
                  println(a[0]/2.toBigInteger())
                }
            } else {
                println(0)
            }
        }
    }


package dsa

import java.util.*
import kotlin.math.*
@JvmField val INPUT = System.`in`
@JvmField val OUTPUT = System.out
@JvmField val _reader = INPUT.bufferedReader()
fun readLine(): String? = _reader.readLine()
fun readLn() = _reader.readLine()!!
@JvmField var _tokenizer: StringTokenizer = StringTokenizer("")
fun read(): String {
    while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return "", " ")
    return _tokenizer.nextToken()
}
fun readInt() = read().toInt()
fun readDouble() = read().toDouble()
fun readLong() = read().toLong()
fun readStrings(n: Int) = List(n) { read() }
fun readLines(n: Int) = List(n) { readLn() }
fun readInts(n: Int) = List(n) { read().toInt() }
fun readIntArray(n: Int) = IntArray(n) { read().toInt() }
fun readDoubles(n: Int) = List(n) { read().toDouble() }
fun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }
fun readLongs(n: Int) = List(n) { read().toLong() }
fun readLongArray(n: Int) = LongArray(n) { read().toLong() }
fun gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b)
fun gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b)
fun Boolean.toInt() = if (this) 1 else 0
val INF = 0x3f3f3f3f
val MOD = (1e9 + 7).toLong()
/***********************************************************************************************/

fun main() {
    var t = readInt()
    for (i in 1..t) {
        var a: Int = readInt()
        if (a % 2 == 0) {
            println(a / 2 - 1)
        } else {
            println(a / 2)
        }
    }
}


import java.lang.Integer.*

private fun readLn() = readLine()!!
private fun readInt() = readLn().toInt()
private fun readStrings() = readLn().split(" ")
private fun readInts() = readStrings().map { it.toInt() }
private fun readLongs() = readStrings().map { it.toLong() }

fun solve(n: Int) {
    if (n%2 == 0) {
        println(max(n / 2 - 1, 0))
    } else {
        println(n/2)
    }
}

fun main() {
    val t = readInt()
    for(i in 0 until t) {
        val n = readInt()
        solve()
    }
}


fun readInts() = readLine()!!.split(' ').map { it.toInt() }

fun main() {
  val tests_cnt = readInts()
  for (i in 1..tests_cnt[0]) {
    val a = readInts()
    if(a > 2) println((a/2).toInt())
    else println(0)
  }
}


import java.util.*

object B {
    fun main(args: Array<String>) {
        val sc = Scanner(System.`in`)
        val t = sc.nextLine().toInt()
        for (i in 0 until t) {
            val x = sc.nextLine().toInt()
            if (x % 2 == 1) println(x / 2) else println(x / 2 - 1)
        }
    }
}


private fun readLn() = readLine()!!
private fun readInt() = readLn().toInt()
private fun readStrings() = readLn().split(" ")
private fun readInts() = readStrings().map { it.toInt() }

fun main() {
    val lines = readInt()
    for (line in 1..lines) {
        val number = readInts()
        println((number-1)/=2)
    }
}


fun main() {
    val scanner = Scanner(System.`in`)
    var t: Int = readLine()!!.toInt()
    while (t-- > 0) {
        val num: Int = scanner.nextInt()
        if (num % 2 == 0) {
            println("${(num / 2) - 1}")
        } else {
            println("${(num - 1) / 2}")
        }
    }
}


package b

import java.io.*
import java.util.*

class MyScanner(inputStream: InputStream) {
    private val br = BufferedReader(InputStreamReader(inputStream));
    private var st: StringTokenizer = StringTokenizer(br.readLine());

    fun next(): String {
        while (!st.hasMoreElements()) {
            st = StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

    fun nextInt(): Int {
        return Integer.parseInt(next());
    }

    fun nextLong(): Long {
        return next().toLong();
    }

    fun nextDouble(): Double {
        return next().toDouble();
    }

    fun nextLine(): String {
        return br.readLine();
    }
}

val In = MyScanner(System.`in`);
val Out = PrintWriter(BufferedOutputStream(System.out))

fun solve() {
    var t = In.nextInt();
    while (t-- > 0) {
        Out.println("${(In.nextInt() - 1) / 2}")
    }
}

fun main() {
    solve()
    Out.close()
}


import java.util.Scanner

func main()
{
    val sc = Scanner(System.`in`)
    val t = sc.nextInt()
    for(x in 0 until t)
    {
        val a = sc.nextInt()
        println((a-1)/2)
    }
}


    fun readInts() = readLine()!!.split(' ').map { it.toInt() }

    fun main() {
        val tests_cnt = readInts()
        for (i in 1..tests_cnt[0]) {
            val a  = readInts()
            if(a[0] > 2) {
                if(a[0].mod(2) == 0) {
                  println(a[0]/2 - 1)
                } else {
                  println(a[0]/2)
                }
            } else {
                println(0)
            }
        }
    }


fun readInts() = readLine()!!.split(' ').map { it.toBigDecimal() }

fun main() {
  val tests_cnt = readInts()
  for (i in 1..tests_cnt[0]) {
    val a = readInts()
    if(a > 2) println((a/2).toInt())
    else println(0)
  }
}


fun readInts() = readLine()!!.split(' ')

fun main() {
  val tests_cnt = readInts().map { it.toInt() }
  for (i in 1..tests_cnt[0]) {
    val a = readInts().map { it.toBigDecimal() }
    if(a > 2) println((a/2).toInt())
    else println(0)
  }
}


import java.util.Scanner
fun main(args: Array<String>) {
    val read = Scanner(System.`in`)
    var t = read.nextInt()
    for (i in t) {
       var n = read.nextInt()
       println((n-1)/2)
    }
}


fun readInts() = readLine()!!.split(' ')

fun main() {
  val tests_cnt = readInts().map { it.toInt() }
  for (i in 1..tests_cnt[0]) {
    val a = readInts().map { it.toBigInteger() }
    if(a > 2) {
      println((a/2).toBigInteger())
    } else {
      println(0)
    }
  }
}


import java.util.*

object main {
    fun main(arg: Array<String>) {
        val `in` = Scanner(System.`in`)
        var t = `in`.nextInt()
        while (t-- > 0) {
            var n: Long
            n = `in`.nextLong()
            if (n % 2 == 0L) {
                println((n - 1) / 2)
            } else println(n / 2)
        }
    }
}


import java.util.*
import java.io.*
import java.math.*

fun main(args : Array<String>) {
    val input = Scanner(System.`in`)
    val N = input.nextInt()
    for (i in 1..N) {
        var BB = input.nextDouble()
        val save = BB
        if (BB % 2 == 0)
            BB += 1
        val A = Math.ceil(BB/2)
        println(save - A)
    }
}


fun main(args: Array<String>) {
    val t = readline()
    for (i in t)
    println("Hello World!") {
       val n = readline()
       println((n-1)/2)
    }
}


    fun readInts() = readLine()!!.split(' ')

    fun main() {
        val tests_cnt = readInts().map { it.toInt() }
        for (i in 1..tests_cnt[0]) {
            val a  = readInts().map { it.toBigInteger() }
            if(a[0] > 2.toBigInteger()) {
                if(a[0] % 2 == 0) {
                  println(a[0]/2.toBigInteger() - 1)
                } else {
                  println(a[0]/2.toBigInteger())
                }
            } else {
                println(0)
            }
        }
    }


import java.util.Scanner

fun main(args: Array<String>) {
    val t = Scanner(System.`in`)
    for (i in t) {
       val n = Scanner(System.`in`)
       println((n-1)/2)
    }
}


fun main() {
    var n = getInteger()
    for (i in 0 until n) {
       	var candies = getInteger()
        println(candies / 2 - !(candies % 2)
    }
}

fun getIntegers() {
    var input = (readLine()!!).split(' ')
 	return input.map{it.toInt()}
}

fun getInteger() {
    return (readLine()!!).toInt()
}


import java.util.*

object B {
    @JvmStatic
    fun main(args: Array<String>) {
        val `in` = Scanner(System.`in`)
        val n = `in`.nextInt()
        for (i in 0 until n) {
            val t = `in`.nextLong()
            if (t <= 2) {
                println(0)
            } else {
                println(if (t % 2 == 0L) t / 2 - 1 else t / 2)
            }
        }
    }
}


fun main() {
    var n = getInteger()
    for (i in 0 until n) {
       	var candies = getInteger()
        println(candies / 2 - !(candies % 2))
    }
}

fun getIntegers() {
    var input = (readLine()!!).split(' ')
 	return input.map{it.toInt()}
}

fun getInteger() {
    return (readLine()!!).toInt()
}


fun main() {
    val testsNum : Int = readLine()?.toIntOrNull() ?: -1
    for(testId in 1..testsNum){
        val testInput = readLine() ?: ""
        val sweetsNum = testInput.toLong()
        val result = ceil(sweetsNum.toDouble()/2).toInt() -1
        println(result)
    }
}


import java.util.*
import java.io.*
import java.math.*

fun main(args : Array<String>) {
    val input = Scanner(System.`in`)
    val N = input.nextInt()
    for (i in 1..N) {
        var BB = input.nextFloat()
        val save = BB
        if (BB % 2 == 0)
            BB += 1
        val A = ceil(BB/2)
        println(save - A)
    }
}


fun main(args: Array<String>) {
    val t = readline()!!
    for (i in t)
    println("Hello World!") {
       val n = readline()!!
       println((n-1)/2)
    }
}


fun main() {
    val n = readLine().toInt()
    for (i in 0 until n) {
        main2(readLine().toInt())
    }
}

fun main2(candies:Int){
    val half = candies/2
    println(half)
    println(Integer.max(0,half + half%2 - 2))
}


fun main() {
    val t = Scanner(System.`in`)
    for (i in t) {
       val n = Scanner(System.`in`)
       println((n-1)/2)
    }
}


package practice.taskB

fun main() {
	val t = readInt()
	for (i in 1..t) {
		val n = readInt()
		val r = (n - 1) / 2
		println(r)
	}
}

fun readInt() = readLine()!!.toInt()


import java.util.Scanner

fun main(){
    val sc = Scanner(System.`in`)

    var t = sc.readInt()

    while(t > 0){
        val a:Int = sc.nextInt()

        print((a+1)/2)

        t = t-1
    }

}


import java.util.*

object Main {
    @JvmStatic
    fun programkt(args: Array<String>) {
        val scanner = Scanner(System.`in`)
        var t = scanner.nextInt()
        while (t-- > 0) {
            val n = Math.max(0, scanner.nextInt() - 2)
            println(n - 2 - (n - 2) / 2)
        }
    }
}


import java.util.*
import java.io.*
import java.math.*

fun main(args : Array<String>) {
    val input = Scanner(System.`in`)
    val N = input.nextInt()
    for (i in 1..N) {
        var BB = input.nextFloat()
        val save = BB
        if (BB % 2 == 0)
            BB += 1
        val A = Math.ceil(BB/2)
        println(save - A)
    }
}


import java.util.Scanner

fun main(){
    val sc = Scanner(System.`in`)

    var t = sc.readInt()

    while(t > 0){
        val a:Int = sc.readInt()

        print((a+1)/2)

        t = t-1
    }

}


private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints

fun one() {
    var n = readInt()

    var ans = n%2==0 ? (n-1 - n/2) : (n- n/2);

    println(max(0,ans))
}

fun main() {
    var t = readInt()

    for (i in 1..t) one()

}


private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints

fun one() {
    var n = readInt()

    var ans = if (n%2==0) { (n-1 - n/2) } else{ (n- n/2) }

    println(max(0,ans))
}

fun main() {
    var t = readInt()

    for (i in 1..t) one()

}


import java.util.Scanner

fun main(args: Array<String>)
{
   val sc = Scanner(System.in)
   var t: Int
   var n: Int
   var x: Int

   while(t-- > 0)
   {
     n=sc.nextInt()
     x=(n-1)/2
     println("$x")
   }
}


readLine()?.toInt()?.let { t ->
        repeat(t){
            readLine()?.toInt()?.let {n ->
                val b = n/2
                val a = n-b
                when {
                    a == b -> {
                        println(b-1)
                    }
                    a > b -> {
                        println(b)
                    }
                    else -> {
                        println(0)
                    }
                }

            }
        }
    }


private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readDouble() = readLn().toDouble() // single double
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints
private fun readLongs() = readStrings().map { it.toLong() } // list of longs
private fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles

fun main(){
    var t = readInt()
    while(t-- > 0){
        var (a) = readInts()
        val x = a/2
        val y = a%2
        val sum = x - y + 1
        println($sum)
    }
}


package com.mmk

fun main() {
   val firstLine= readInt()
    for(i in 0 until firstLine){
        val n= readInt()
        var a=n
        var b=0
        var count=0
        while(a>b){
            a--
            b++
            if (a>0 && b>0 && a>b)
                count++
        }
        println(count)
    }
}

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints


import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter

val reader = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun readLn() = reader.readLine()
fun readInt() = readLn().toInt()
fun readLong() = readLn().toLong()
fun readDouble() = readLn().toDouble()

fun readStrings() = readLn().split(" ")
fun readInts() = readStrings().map { it.toInt() }
fun readLongs() = readStrings().map { it.toLong() }
fun readDoubles() = readStrings().map { it.toDouble() }

fun readIntArrays(vararg arrays: IntArray) {
    for (i in 0 until arrays[0].size) {
        for (j in arrays.indices) {
            arrays[j][i] = readInt()
        }
    }
}

fun main() {
    solve()
    reader.close()
    out.close()
}

main()

fun solve() {
    for (ii in 0 until readInt()){
        var n = readInt()
        var ans = if (n < 3) 0 else (n-1)/2
        out.println(ans)
    }
}


fun main(args: Array<String>) {
    var t = read.nextInt()
    for (i in t) {
       var n = read.nextInt()
       println((n-1)/2)
    }
}


    fun main(args: Array<String>) {
        var T: Int
        val scanner = Scanner(System.`in`)
        T = scanner.nextInt()
        while (T-- > 0) {
            var n = scanner.nextInt()
            if (n < 2) n = 2
            println((n - 1) / 2)
        }
    }


fun main(args: Array<String>) {
    val tests = readLine().toInt()
    for (i in 0 until tests) {
        val nr = readLine().toInt()
        val ats = (nr-1)/2
        println(ats)
    }
}


import kotlin.time.seconds

fun main(){
    val t = readLine()!!.toInt()
    for (i in 1..t){
        var (n,k) = readLine()!!.split(" ").map { it.toLong() }
        val array = readLine()!!.split(" ")
                .mapIndexed { index, s ->
            Pair(index, s.toLong())
        }.sortedBy { it.second }
        var max = array.last().second
        val sum = array.map { it.second }.sum()
        var mbMax = (2*(sum+k)+array.size*array.size-1)/(2*array.size)
        if ((2*(sum+k)+array.size*array.size-1)%(2*array.size)!=0L){
            mbMax++
        }
        max = maxOf(mbMax, max)
        var newArray = Array(n.toInt()){
            max+it-n+1
        }
        var length = newArray.sum()-sum-k
        newArray.mapIndexed { index, i ->
            if (i-array[index].second>length){
                val m = length
                length=0
                i-m
            }
            else{
                length-=i-array[index].second
                array[index].second
            }
        }.apply {
            Array(n.toInt()) { index ->
                val ind = array.indexOfFirst { it.first == index }
                this[ind] - array[ind].second
            }.forEach { print("$it ") }
            println()
        }
    }
}


import java.io.PrintWriter
import java.lang.Math.min
import java.util.*

fun solve() {
    val t = round3.c.ni()
    for(i in 1..t){
        go()
    }
}

fun go() {
    var (n, K) = na()
    var a = na()
    var ai: MutableList<IntArray> = mutableListOf()
    for(i in 0..n-1){
        ai.add(intArrayOf(a[i], i, 0))
    }
    ai.sortBy{ it[0] }
    for(i in n-2 downTo 0){
        ai[i][2] = min(K, ai[n-1][0] - ai[i][0] - (n-1-i))
        K -= ai[i][2]
    }
    if(K > 0){
        val plus = (K+n-1)/n
        for(i in 0..n-1){
            ai[i][2] += K/n
            if(n-i <= K%n){
                ai[i][2] += 1
            }
        }
    }
    ai.sortBy{ it[1] }
    for(i in 0..n-1){
        out.print(ai[i][2])
        out.print(" ")
    }
    out.println()

//    out.println(ai)
}

val out = PrintWriter(System.out)

fun main(args: Array<String>) {
    solve()
    out.flush()
}

fun nline() = readLine()!!
fun ni() = nline().toInt()
fun nl() = nline().toLong()
fun nd() = nline().toDouble()
fun nas() = nline().split(" ")
fun na() = nas().map { it.toInt() }
fun nal() = nas().map { it.toLong() }

fun tr(x: Any) = System.err.println(x)
fun tr(x: IntArray) = System.err.println(Arrays.toString(x))
fun tr(x: Array<Any>) = System.err.println(Arrays.deepToString(x))


import java.io.OutputStream
import java.io.IOException
import java.io.InputStream
import java.util.Arrays
import java.io.UncheckedIOException
import java.io.Closeable
import java.io.Writer
import java.io.OutputStreamWriter

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
object programkt {
    @Throws(Exception::class)
    @JvmStatic
    fun main(args: Array<String>) {
        val thread = Thread(null, TaskAdapter(), "", (1 shl 27).toLong())
        thread.start()
        thread.join()
    }

    internal class TaskAdapter : Runnable {
        override fun run() {
            val inputStream = System.`in`
            val outputStream = System.out
            val `in` = FastInput(inputStream)
            val out = FastOutput(outputStream)
            val solver = DBonusDistribution()
            val testCount = Integer.parseInt(`in`.next())
            for (i in 1..testCount)
                solver.solve(i, `in`, out)
            out.close()
        }
    }

    internal class DBonusDistribution {
        fun solve(testNumber: Int, `in`: FastInput, out: FastOutput) {
            val n = `in`.readInt()
            var k = `in`.readInt()
            val a = IntArray(n)
            val index = arrayOfNulls<Int>(n)
            for (i in 0 until n) {
                a[i] = `in`.readInt()
                index[i] = i
            }
            Arrays.sort(index) { i, j -> -Integer.compare(a[i], a[j]) }
            val dist = IntArray(n)
            for (i in 1 until n) {
                var allow = a[index[i - 1]] - 1 - a[index[i]]
                allow = Math.min(k, allow)
                k -= allow
                a[index[i]] += allow
                dist[index[i]] = allow
            }
            val avg = k / n
            for (i in 0 until n) {
                dist[index[i]] += avg
            }
            val remain = k % n
            for (i in 0 until remain) {
                dist[index[i]]++
            }

            for (d in dist) {
                out.append(d).append(' ')
            }
            out.println()
        }

    }

    internal class FastOutput(private val os: Writer) : AutoCloseable, Closeable, Appendable {
        private val cache = StringBuilder(10 shl 20)

        override fun append(csq: CharSequence): FastOutput {
            cache.append(csq)
            return this
        }

        override fun append(csq: CharSequence, start: Int, end: Int): FastOutput {
            cache.append(csq, start, end)
            return this
        }

        constructor(os: OutputStream) : this(OutputStreamWriter(os)) {}

        override fun append(c: Char): FastOutput {
            cache.append(c)
            return this
        }

        fun append(c: Int): FastOutput {
            cache.append(c)
            return this
        }

        fun println(): FastOutput {
            cache.append(System.lineSeparator())
            return this
        }

        fun flush(): FastOutput {
            try {
                os.append(cache)
                os.flush()
                cache.setLength(0)
            } catch (e: IOException) {
                throw UncheckedIOException(e)
            }

            return this
        }

        override fun close() {
            flush()
            try {
                os.close()
            } catch (e: IOException) {
                throw UncheckedIOException(e)
            }

        }

        override fun toString(): String {
            return cache.toString()
        }

    }

    internal class FastInput(private val `is`: InputStream) {
        private val defaultStringBuf = StringBuilder(1 shl 13)
        private val buf = ByteArray(1 shl 20)
        private var bufLen: Int = 0
        private var bufOffset: Int = 0
        private var next: Int = 0

        private fun read(): Int {
            while (bufLen == bufOffset) {
                bufOffset = 0
                try {
                    bufLen = `is`.read(buf)
                } catch (e: IOException) {
                    bufLen = -1
                }

                if (bufLen == -1) {
                    return -1
                }
            }
            return buf[bufOffset++].toInt()
        }

        fun skipBlank() {
            while (next >= 0 && next <= 32) {
                next = read()
            }
        }

        operator fun next(): String {
            return readString()
        }

        fun readInt(): Int {
            var sign = 1

            skipBlank()
            if (next == '+'.toInt() || next == '-'.toInt()) {
                sign = if (next == '+'.toInt()) 1 else -1
                next = read()
            }

            var `val` = 0
            if (sign == 1) {
                while (next >= '0'.toInt() && next <= '9'.toInt()) {
                    `val` = `val` * 10 + next - '0'.toInt()
                    next = read()
                }
            } else {
                while (next >= '0'.toInt() && next <= '9'.toInt()) {
                    `val` = `val` * 10 - next + '0'.toInt()
                    next = read()
                }
            }

            return `val`
        }

        fun readString(builder: StringBuilder): String {
            skipBlank()

            while (next > 32) {
                builder.append(next.toChar())
                next = read()
            }

            return builder.toString()
        }

        fun readString(): String {
            defaultStringBuf.setLength(0)
            return readString(defaultStringBuf)
        }

    }
}


package com.happypeople.codeforces.c1297

import java.io.ByteArrayInputStream
import java.io.InputStream
import java.util.*

fun main(args: Array<String>) {
    try {
        D1297().run()
    } catch (e: Throwable) {
        println("")
    }
}

class D1297 {
    fun run() {
        val sc = Scanner(systemIn())
        val t=sc.nextInt()
        (1..t).forEach { solve(sc) }
    }

    fun solve(sc : Scanner) {
        val n=sc.nextInt()
        val k=sc.nextInt()
        val a=(1..n).map { Pair(sc.nextInt(), it) }.sortedBy { -it.first }
        /* Pay the second one max possible d, the third one max possible...
        * if still d available, distribute equal among all, starting with higest
        **/

        val ans=IntArray(n)
        var d=0
        (1..n-1).forEach {
            val diff=a[it-1].first - a[it].first
            if(diff>1) {
                if(diff < k-d)
                    ans[it]=diff
                else
                    ans[it]=k-d
            } else
                ans[it]=0

            d+=ans[it]
        }

        val v=(k-d)/n
        if(v>0) {
            (0..n - 1).forEach {
                ans[it] +=v
                d+=v
            }
        }
        (1..(k-d)).forEach {
            ans[it-1]++
        }

        (0..n-1).map {
            Pair(ans[it], a[it].second)
        }.sortedBy { it.second }.forEach {
            print("${it.first} ")
        }
        println()
    }

    companion object {
        var inputStr: String? = null

        fun systemIn(): InputStream {
            if (inputStr != null)
                return ByteArrayInputStream(inputStr!!.toByteArray())
            else
                return System.`in`
        }

        var printLog = false
        fun log(str: String) {
            if (printLog)
                println(str)
        }
    }
}


import java.io.OutputStream
import java.io.IOException
import java.io.InputStream
import java.util.Random
import java.io.UncheckedIOException
import java.io.Closeable
import java.io.Writer
import java.io.OutputStreamWriter

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
object programkt {
    @Throws(Exception::class)
    @JvmStatic
    fun main(args: Array<String>) {
        val thread = Thread(null, TaskAdapter(), "", (1 shl 27).toLong())
        thread.start()
        thread.join()
    }

    internal class TaskAdapter : Runnable {
        override fun run() {
            val inputStream = System.`in`
            val outputStream = System.out
            val `in` = FastInput(inputStream)
            val out = FastOutput(outputStream)
            val solver = DBonusDistribution()
            val testCount = Integer.parseInt(`in`.next())
            for (i in 1..testCount)
                solver.solve(i, `in`, out)
            out.close()
        }
    }

    internal class DBonusDistribution {
        fun solve(testNumber: Int, `in`: FastInput, out: FastOutput) {
            val n = `in`.readInt()
            var k = `in`.readInt()
            val a = IntArray(n)
            val index = IntArray(n)
            for (i in 0 until n) {
                a[i] = `in`.readInt()
                index[i] = i
            }
            CompareUtils.quickSort(index, { i, j -> -Integer.compare(a[i], a[j]) }, 0, n)
            val dist = IntArray(n)
            for (i in 1 until n) {
                var allow = a[index[i - 1]] - 1 - a[index[i]]
                allow = Math.min(k, allow)
                k -= allow
                a[index[i]] += allow
                dist[index[i]] = allow
            }
            val avg = k / n
            for (i in 0 until n) {
                dist[index[i]] += avg
            }
            val remain = k % n
            for (i in 0 until remain) {
                dist[index[i]]++
            }

            for (d in dist) {
                out.append(d).append(' ')
            }
            out.println()
        }

    }

    internal class FastOutput(private val os: Writer) : AutoCloseable, Closeable, Appendable {
        private val cache = StringBuilder(10 shl 20)

        override fun append(csq: CharSequence): FastOutput {
            cache.append(csq)
            return this
        }

        override fun append(csq: CharSequence, start: Int, end: Int): FastOutput {
            cache.append(csq, start, end)
            return this
        }

        constructor(os: OutputStream) : this(OutputStreamWriter(os)) {}

        override fun append(c: Char): FastOutput {
            cache.append(c)
            return this
        }

        fun append(c: Int): FastOutput {
            cache.append(c)
            return this
        }

        fun println(): FastOutput {
            cache.append(System.lineSeparator())
            return this
        }

        fun flush(): FastOutput {
            try {
                os.append(cache)
                os.flush()
                cache.setLength(0)
            } catch (e: IOException) {
                throw UncheckedIOException(e)
            }

            return this
        }

        override fun close() {
            flush()
            try {
                os.close()
            } catch (e: IOException) {
                throw UncheckedIOException(e)
            }

        }

        override fun toString(): String {
            return cache.toString()
        }

    }

    internal object Randomized {
        private val random = Random(0)

        fun nextInt(l: Int, r: Int): Int {
            return random.nextInt(r - l + 1) + l
        }

    }

    internal class FastInput(private val `is`: InputStream) {
        private val defaultStringBuf = StringBuilder(1 shl 13)
        private val buf = ByteArray(1 shl 20)
        private var bufLen: Int = 0
        private var bufOffset: Int = 0
        private var next: Int = 0

        private fun read(): Int {
            while (bufLen == bufOffset) {
                bufOffset = 0
                try {
                    bufLen = `is`.read(buf)
                } catch (e: IOException) {
                    bufLen = -1
                }

                if (bufLen == -1) {
                    return -1
                }
            }
            return buf[bufOffset++].toInt()
        }

        fun skipBlank() {
            while (next >= 0 && next <= 32) {
                next = read()
            }
        }

        operator fun next(): String {
            return readString()
        }

        fun readInt(): Int {
            var sign = 1

            skipBlank()
            if (next == '+'.toInt() || next == '-'.toInt()) {
                sign = if (next == '+'.toInt()) 1 else -1
                next = read()
            }

            var `val` = 0
            if (sign == 1) {
                while (next >= '0'.toInt() && next <= '9'.toInt()) {
                    `val` = `val` * 10 + next - '0'.toInt()
                    next = read()
                }
            } else {
                while (next >= '0'.toInt() && next <= '9'.toInt()) {
                    `val` = `val` * 10 - next + '0'.toInt()
                    next = read()
                }
            }

            return `val`
        }

        fun readString(builder: StringBuilder): String {
            skipBlank()

            while (next > 32) {
                builder.append(next.toChar())
                next = read()
            }

            return builder.toString()
        }

        fun readString(): String {
            defaultStringBuf.setLength(0)
            return readString(defaultStringBuf)
        }

    }

    internal interface IntComparator {
        fun compare(a: Int, b: Int): Int

    }

    internal object SequenceUtils {
        fun swap(data: IntArray, i: Int, j: Int) {
            val tmp = data[i]
            data[i] = data[j]
            data[j] = tmp
        }

    }

    internal object CompareUtils {
        private val THRESHOLD = 4

        fun <T> insertSort(data: IntArray, cmp: IntComparator, l: Int, r: Int) {
            for (i in l + 1..r) {
                var j = i
                val `val` = data[i]
                while (j > l && cmp.compare(data[j - 1], `val`) > 0) {
                    data[j] = data[j - 1]
                    j--
                }
                data[j] = `val`
            }
        }

        fun quickSort(data: IntArray, cmp: IntComparator, f: Int, t: Int) {
            if (t - f <= THRESHOLD) {
                insertSort<Any>(data, cmp, f, t - 1)
                return
            }
            SequenceUtils.swap(data, f, Randomized.nextInt(f, t - 1))
            var l = f
            var r = t
            var m = l + 1
            while (m < r) {
                val c = cmp.compare(data[m], data[l])
                if (c == 0) {
                    m++
                } else if (c < 0) {
                    SequenceUtils.swap(data, l, m)
                    l++
                    m++
                } else {
                    SequenceUtils.swap(data, m, --r)
                }
            }
            quickSort(data, cmp, f, l)
            quickSort(data, cmp, m, t)
        }

    }
}


import java.util.*

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextInts() = next().split(" ").map { it.toInt() }
fun nextLongs() = next().split(" ").map { it.toLong() }

fun main(args: Array<String>) {
    var tc = nextInt()
    while (tc > 0) {
        var (n,k) = nextInts()
        val data = ArrayList(nextLongs())

        var datas = ArrayList< Pair<Long,Int> >()
        var ans = ArrayList<Long>()

        var idx = 0
        for (x in data) {
            datas.add(Pair(x, idx))
            ans.add(0)
            idx += 1
        }

        datas = ArrayList(datas.sortedBy { it.first })

        var l : Long = 0
        var r : Long= 2000000000
        var ret : Long= r+1

        var cnt = 0

        idx = 0
        while(idx < n){
            data[datas[idx].second] -= cnt.toLong()
            cnt+=1
            idx+=1
        }

        while(l <= r){
            var mid : Long= l + (r-l)/2;
            var evalu : Long = 0
            for (x in data){
                if(x > mid){
                    continue
                } else {
                    evalu += mid - x
                }
            }
            if(evalu < k){
                l = mid+1
            } else {
                r = mid-1
                ret = mid
            }
        }

        idx = n-1
        while(idx >= 0){
            if(data[datas[idx].second] >= ret){
                idx-=1
            } else {
                var sisa = k
                if((ret - data[datas[idx].second]) <= sisa) sisa = (ret - data[datas[idx].second]).toInt()
                ans[datas[idx].second] = sisa.toLong()
                k -= sisa
                idx-=1
            }
        }

        var before = -1
        for (x in ans) {
            if (before != -1) print(" ")
            print(x)
            before = x
        }
        println("")

        tc = tc - 1
    }

}


import kotlin.math.min
import kotlin.test.fail

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints

private fun solve() {
    var (n,k) = readInts()
    val aa = readInts().withIndex().sortedBy { (_,a) -> a }
    val dd = IntArray(n)
    dd[n-1] = 0
    for (i in n-2 downTo 0) {
        val (ai, a) = aa[i]
        val (ain, an) = aa[i+1]
        dd[ai] = minOf(k, an + dd[ain] - a -1)
        k -= dd[ai]
        if (k == 0) {
            break
        }
    }
    if (k > 0) {
        val inc = k/n
        val rem = k%n
        for (i in 0 until n-rem) {
            val (ai, _) = aa[i]
            dd[ai] += inc
        }
        for (i in n-rem until n) {
            val (ai, _) = aa[i]
            dd[ai] += inc+1
        }
    }
    println(dd.joinToString(" "))
}

fun main() {
    val t = readInt()
    repeat(t) {
        solve()
    }
}


import kotlin.time.seconds

fun myread() = readLine()!!
fun readint() = myread().toInt()
fun readLong() = myread().toLong()
fun readints() = myread().split(" ").map{it.toInt()}
fun readLongs() = myread().split(" ").map{it.toLong()}

fun main() {
    val t = readint()
    for(i in 1 .. t){
        val (n,k) = readints()
        var a = readints()
        var v = mutableListOf<Pair<Int,Int>>()
        for(j in 0 .. (n-1)){
            v.add(Pair(j,a[j]))
        }
        v.sortBy { it.second }
        v.reverse()
        var l = v[0].second
        var r = v[0].second + k
        while(l!=r){
            var m = l / 2 + r / 2
            if(l%2==1 && r%2==1)m++
            var tk = 0
            for(j in 0 .. (n-1)){
                tk += (m-j) - v[j].second
            }
            if(tk >= k){
                r = m
            } else{
                l = m + 1
            }
        }
        var tk = k
        var ans = IntArray(n)
        for(j in 0 .. (n-1)){
            if(tk > (l-j)-v[j].second) {
                ans[v[j].first] = (l-j)-v[j].second
                tk -= (l-j)-v[j].second
            } else {
                ans[v[j].first] = tk
                tk = 0
            }
        }
        for(j in 0 .. (n-1)){
            if(j > 0)print(" ")
            print(ans[j])
        }
        println("")
    }
}


import java.lang.IllegalArgumentException
import java.lang.StringBuilder
import java.util.*;
import kotlin.Comparator

import kotlin.collections.ArrayList
import kotlin.math.*;
import kotlin.system.exitProcess
import  kotlin.collections.*
import kotlin.time.seconds

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readDouble() = readLn().toDouble() // single double
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints
private fun readLongs() = readStrings().map { it.toLong() } // list of longs
private fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles

class Bit(var n:Int) {
    var a = ArrayList<Long>()
    init {
        a.resize(n+1,0);
    }
    fun clear(m:Int) {
        n = m
        a.resize(n+1,0)
    }
    fun add(x:Int,v:Long) {
        var p = x
        while(p<=n) {
            a[p] += v
            p += p and -p
        }
    }
    fun sum(x:Int) : Long {
        var ans : Long = 0
        var p = x
        while(p>0) {
            ans += a[p]
            p -= p and -p
        }
        return ans
    }
}

fun lower_bound(a:ArrayList<Int>, l:Int, r:Int , x:Int ): Int {
    var L=l-1
    var R=r-1
    while(R-L>1) {
        var mid = (L+R)/2
        if(a[mid]>=x) R=mid
        else L=mid
    }
    return R
}

fun <T> ArrayList<T>.resize(n:Int, v:T) {
    this.clear()
    for(i in 0..n-1) this.add(v)
}

//---------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------

class PI (val first:Long,val second:Int):Comparable<PI> {
    override fun compareTo(other: PI): Int {
        if(first==other.first) return second.compareTo(other.second)
        return first.compareTo(other.first)
    }
}

var n = 0
var k = 0
var a = ArrayList<Long>()

fun ok(m: Long):Boolean {
    var K:Long = k.toLong()
    var pre = m
    K -= m-a[0]
    if(K<=0) return true
    for(i in 1..n-1) {
        var add = min(K,pre-1-a[i])
        K -= add
        pre = a[i]+add
    }
    return K<=0
}

fun main () {
    var T = readInt()
    repeat(T) {
        val (nn,kk) = readInts()
        n = nn
        k = kk
        a.clear()
        var b = readLongs()
        var o = ArrayList<PI>()
        for(i in 0..n-1) {
            a.add(b[i])
            o.add(PI(b[i],i))
        }
        Collections.sort(a)
        Collections.reverse(a)

        Collections.sort(o)
        Collections.reverse(o)

        var L :Long = (a[0]-1).toLong()
        var R : Long = 3000000000
        while(R-L>1) {
            var mid = (L+R)/2
            if(ok(mid)) R=mid
            else L = mid
        }
        var ans = ArrayList<Long>()
        ans.resize(n,0)
        var K = k-(R-a[0])
        ans[o[0].second] = R-a[0]
        var pre = R

        for(i in 1..n-1) {
            val add = min(K,pre-1-a[i])
            K -= add
            ans[o[i].second] = add
            pre = o[i].first + add
        }
        //println(R-a[0])
        for(x in ans) print("$x ")
        println()
    }

}


fun spreadUnequalAmong(remaining: Int, n: Int, bonuses: MutableList<Int>) {
    val delta = remaining / n
    val r = remaining % n
    for (i in 0 until n) bonuses[i] += delta
    for (i in 1..r) bonuses[n - i] += 1
}

fun main() {
    val tasks = readLine()!!.toInt()
    repeat(tasks) {
        val (n, k) = readLine()!!.split(" ").map { it.toInt() }
        val salaries = readLine()!!.split(" ").map { it.toInt() }.withIndex().sortedBy { it.value }
        check(salaries.size == n)

        val sv = salaries.map { it.value }

        var remaining = k
        val bonuses = MutableList(n) { 0 }
        for (i in 0..salaries.lastIndex - 1) {
            val delta = sv[i + 1] - sv[i] - 1
            val deduction = delta * (i + 1)
            when {
                deduction == 0 -> continue
                deduction <= remaining -> {
                    remaining -= deduction
                    for (j in 0..i) bonuses[j] += delta
                }
                else -> {
                    spreadUnequalAmong(remaining, i + 1, bonuses)
                    remaining = 0
                }
            }
            if (remaining == 0) break
        }
        if (remaining > 0) {
            spreadUnequalAmong(remaining, n, bonuses)
        }
        check(bonuses.sum() == k)
        val ibonuses = salaries.zip(bonuses) { (index, s), b ->
//            println("$index:\t$s\t+\t$b =\t${s + b}")
            IndexedValue(index, b)
        }
        println(ibonuses.sortedBy { it.index }.map { it.value }.joinToString(" "))
//        println()
    }
}


package org.ehmeed.competitive.kotlinheroes.third

private fun main() {
    solve(StdInput)
//    solveTestInputs()
}

data class Employee(val index: Int, val salary: Int)

private fun solve(input: Input) {
    val cases = input.nextLine().toInt()
    repeat(cases) {
        val (employeesCount, totalBonus) = input.nextLine().toInts()
        val employees = input.nextLine().toInts().mapIndexed { index, salary -> Employee(index, salary) }.sortedByDescending { it.salary }  //different
        val bonuses = Array(employeesCount) { 0 }

        var bonusLeft = totalBonus
        var currentEmployeeIndex = 1
        while (bonusLeft > 0) {
            if (currentEmployeeIndex == employees.lastIndex + 1) {
                currentEmployeeIndex = 0
                while (bonusLeft > 0) {
                    bonuses[employees[currentEmployeeIndex].index] += 1
                    bonusLeft -= 1
                    currentEmployeeIndex += 1
                    if (currentEmployeeIndex == employees.lastIndex + 1) currentEmployeeIndex = 0
                }
            }
            val prevEmployee = employees[currentEmployeeIndex - 1]
            val previousEsalary = prevEmployee.salary + bonuses[prevEmployee.index]
            val currEsalary = employees[currentEmployeeIndex].salary + bonuses[employees[currentEmployeeIndex].index]
            val diff = (previousEsalary - currEsalary - 1).coerceAtMost(bonusLeft)

            bonuses[employees[currentEmployeeIndex].index] += diff
            bonusLeft -= diff
            currentEmployeeIndex += 1
        }
        println(bonuses.joinToString(" "))
    }
}

// test inputs
private fun solveTestInputs() {
    listOf(
        """
5
4 1
3 1 4 2
2 3
10 2
4 1000000000
987654321 1000000000 999999999 500000000
8 9
5 6 1 8 3 4 2 7
6 1
6 3 1 8 5 9

        """,
        """

        """,
        """

        """
    )
        .filter { it.isNotBlank() }
        .map { it.trimIndent().trimEnd() }
        .map { it.asTestInput() }
        .mapIndexed(::solveTestInput)

}

private const val DELIMITER = "----------------------------------------------"
private fun solveTestInput(index: Int, input: TestInput) {
    println("$DELIMITER INPUT: $index $DELIMITER")
    println(input.input)
    println("$DELIMITER SOLUTION: $index $DELIMITER")
    solve(input)
}

private fun String.toInts() = split(" ").map { it.toInt() }

private interface Input {
    fun nextLine(): String
}

private object StdInput : Input {
    override fun nextLine(): String = readLine()!!
}

private class TestInput(val input: String) : Input {
    private val iterator = input.split('\n').iterator()
    override fun nextLine(): String = iterator.next()
}

private fun String.asTestInput() = TestInput(this)


fun main(args: Array<String>) {
        val inputStream = System.`in`
        val outputStream: OutputStream = System.out
        val `in` = InputReader(inputStream)
        val out = PrintWriter(outputStream)
        val solver = Task()
        var tc = `in`.nextInt()
        while (tc-- > 0) {
            solver.solve(1, `in`, out)
        }
        out.close()
    }

    internal class Task {
        internal inner class Pair(var a: Int, var b: Int) : Comparable<Pair> {
            override fun compareTo(other: Pair): Int {
                if (a == other.a) return 0
                return if (a > other.a) 1 else -1
            }

        }

        fun solve(testNumber: Int, `in`: InputReader, out: PrintWriter) {
            val n = `in`.nextInt()
            val k = `in`.nextInt()
            val org = IntArray(n)
            val s = arrayOfNulls<Pair>(n)
            for (i in 0 until n) {
                val `val` = `in`.nextInt()
                org[i] = `val`
                s[i] = Pair(`val`, i)
            }
            Arrays.sort(s)
            var lo = 0
            var hi = k
            var foo = LongArray(n)
            while (lo < hi) {
                val m = (lo + hi) / 2
                foo = LongArray(n)
                for (i in n - 1 downTo 0) {
                    foo[s[i]!!.b] = s[i]!!.a.toLong()
                }
                foo[s[n - 1]!!.b] = (s[n - 1]!!.a + m).toLong()
                var rest = k - m.toLong()
                var last = foo[s[n - 1]!!.b]
                var i = n - 2
                while (i >= 0 && rest > 0) {
                    val need = Math.min(rest, last - s[i]!!.a - 1)
                    foo[s[i]!!.b] = s[i]!!.a + need
                    rest -= need
                    last = foo[s[i]!!.b]
                    i--
                }
                if (rest == 0L) {
                    hi = m
                } else {
                    lo = m + 1
                }
            }
            foo = LongArray(n)
            for (i in n - 1 downTo 0) {
                foo[s[i]!!.b] = s[i]!!.a.toLong()
            }
            foo[s[n - 1]!!.b] = (s[n - 1]!!.a + lo).toLong()
            var rest = k - lo.toLong()
            var last = foo[s[n - 1]!!.b]
            run {
                var i = n - 2
                while (i >= 0 && rest > 0) {
                    val need = Math.min(rest, last - s[i]!!.a - 1)
                    foo[s[i]!!.b] = s[i]!!.a + need
                    rest -= need
                    last = foo[s[i]!!.b]
                    i--
                }
            }
            for (i in 0 until n) {
                out.print((foo[i] - org[i]).toString() + " ")
            }
            out.println()
        }
    }

    internal class InputReader(stream: InputStream?) {
        var `in`: BufferedReader
        var tok: StringTokenizer?
        fun nextToken(): String? {
            var line: String? = ""
            while (tok == null || !tok!!.hasMoreTokens()) {
                try {
                    if (`in`.readLine().also { line = it } != null) tok = StringTokenizer(line) else return null
                } catch (e: IOException) { // TODO Auto-generated catch block
                    e.printStackTrace()
                    return null
                }
            }
            return tok!!.nextToken()
        }

        fun nextInt(): Int {
            return nextToken()!!.toInt()
        }

        fun nextLong(): Long {
            return nextToken()!!.toLong()
        }

        fun nextDouble(): Double {
            return nextToken()!!.toDouble()
        }

        init {
            `in` = BufferedReader(InputStreamReader(stream), 32768)
            tok = null
        }
    }


import com.sun.corba.se.spi.orbutil.threadpool.Work

import java.util.*
import java.io.*

/**
 * A Template Used For Competitive Programming
 * By XGN from HHS 2020
 * Intellij is too hard to use...
 * Code created at 2020/2/27 21:59
 */
class D1297 {

    internal inner class Worker(var salary: Int, var id: Int)

    internal fun ok(maxW: Int, k: Int, wo: Array<Worker>): Boolean {
        var leftOver = k - maxW
        var lastSal = wo[0].salary + maxW
        for (i in 1 until wo.size) {
            if (leftOver <= 0) {
                return true
            }
            val toCost = lastSal - 1 - wo[i].salary
            if (toCost < 0) {
                return false
            }
            lastSal = lastSal - 1
            leftOver -= toCost
        }
        return leftOver <= 0
    }

    fun solve(args: Array<String>) {
        val `in` = InputReader(System.`in`)
        val out = PrintWriter(System.out)

        var t = `in`.nextInt()
        while (t-- != 0) {
            val n = `in`.nextInt()
            val k = `in`.nextInt()
            val wo = arrayOfNulls<Worker>(n)
            for (i in 0 until n) {
                wo[i] = Worker(`in`.nextInt(), i)
            }

            Arrays.sort<Worker>(wo) { o1, o2 -> -Integer.compare(o1.salary, o2.salary) }

            var l = 0
            var r = k
            while (l <= r) {
                val m = (l + r) / 2
                if (ok(m, k, wo)) {
                    r = m - 1
                } else {
                    l = m + 1
                }
            }

            //            out.println(l);
            //construct
            val ans = IntArray(n)
            var leftOver = k - l
            var lastSal = wo[0].salary + l
            ans[wo[0].id] = l
            for (i in 1 until wo.size) {
                if (leftOver <= 0) {
                    break
                }
                val toCost = Math.min(leftOver, lastSal - 1 - wo[i].salary)
                ans[wo[i].id] = toCost
                lastSal = lastSal - 1
                leftOver -= toCost
            }

            for (i in 0 until n) {
                out.print(ans[i].toString() + " ")
            }
            out.println()
        }

        out.flush()
        out.close()
    }

    internal class InputReader(stream: InputStream) {
        var reader: BufferedReader
        var tokenizer: StringTokenizer? = null

        init {
            reader = BufferedReader(InputStreamReader(stream), 32768)
            tokenizer = null
        }

        operator fun next(): String {
            while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
                try {
                    tokenizer = StringTokenizer(reader.readLine())
                } catch (e: IOException) {
                    throw RuntimeException(e)
                }

            }
            return tokenizer!!.nextToken()
        }

        fun nextInt(): Int {
            return Integer.parseInt(next())
        }

    }

    companion object {
        @JvmStatic
        fun main(args: Array<String>) {
            val me = D1297()
            me.solve(args)
        }
    }
}

fun main(){
    D1297.main(arrayOf(""));
}


import java.io.OutputStream
import java.io.IOException
import java.io.InputStream
import java.util.Random
import java.io.UncheckedIOException
import java.io.Closeable
import java.io.Writer
import java.io.OutputStreamWriter

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
object programkt {
    @Throws(Exception::class)
    @JvmStatic
    fun main(args: Array<String>) {
        val thread = Thread(null, TaskAdapter(), "", (1 shl 27).toLong())
        thread.start()
        thread.join()
    }

    internal class TaskAdapter : Runnable {
        override fun run() {
            val inputStream = System.`in`
            val outputStream = System.out
            val `in` = FastInput(inputStream)
            val out = FastOutput(outputStream)
            val solver = DBonusDistribution()
            val testCount = Integer.parseInt(`in`.next())
            for (i in 1..testCount)
                solver.solve(i, `in`, out)
            out.close()
        }
    }

    internal class DBonusDistribution {
        fun solve(testNumber: Int, `in`: FastInput, out: FastOutput) {
            val n = `in`.readInt()
            var k = `in`.readInt()
            val a = IntArray(n)
            val index = IntArray(n)
            for (i in 0 until n) {
                a[i] = `in`.readInt()
                index[i] = i
            }
            CompareUtils.quickSort(index, { i: Int, j: Int -> -Integer.compare(a[i], a[j]) }, 0, n)
            val dist = IntArray(n)
            for (i in 1 until n) {
                var allow = a[index[i - 1]] - 1 - a[index[i]]
                allow = Math.min(k, allow)
                k -= allow
                a[index[i]] += allow
                dist[index[i]] = allow
            }
            val avg = k / n
            for (i in 0 until n) {
                dist[index[i]] += avg
            }
            val remain = k % n
            for (i in 0 until remain) {
                dist[index[i]]++
            }

            for (d in dist) {
                out.append(d).append(' ')
            }
            out.println()
        }

    }

    internal class FastOutput(private val os: Writer) : AutoCloseable, Closeable, Appendable {
        private val cache = StringBuilder(10 shl 20)

        override fun append(csq: CharSequence): FastOutput {
            cache.append(csq)
            return this
        }

        override fun append(csq: CharSequence, start: Int, end: Int): FastOutput {
            cache.append(csq, start, end)
            return this
        }

        constructor(os: OutputStream) : this(OutputStreamWriter(os)) {}

        override fun append(c: Char): FastOutput {
            cache.append(c)
            return this
        }

        fun append(c: Int): FastOutput {
            cache.append(c)
            return this
        }

        fun println(): FastOutput {
            cache.append(System.lineSeparator())
            return this
        }

        fun flush(): FastOutput {
            try {
                os.append(cache)
                os.flush()
                cache.setLength(0)
            } catch (e: IOException) {
                throw UncheckedIOException(e)
            }

            return this
        }

        override fun close() {
            flush()
            try {
                os.close()
            } catch (e: IOException) {
                throw UncheckedIOException(e)
            }

        }

        override fun toString(): String {
            return cache.toString()
        }

    }

    internal object Randomized {
        private val random = Random(0)

        fun nextInt(l: Int, r: Int): Int {
            return random.nextInt(r - l + 1) + l
        }

    }

    internal class FastInput(private val `is`: InputStream) {
        private val defaultStringBuf = StringBuilder(1 shl 13)
        private val buf = ByteArray(1 shl 20)
        private var bufLen: Int = 0
        private var bufOffset: Int = 0
        private var next: Int = 0

        private fun read(): Int {
            while (bufLen == bufOffset) {
                bufOffset = 0
                try {
                    bufLen = `is`.read(buf)
                } catch (e: IOException) {
                    bufLen = -1
                }

                if (bufLen == -1) {
                    return -1
                }
            }
            return buf[bufOffset++].toInt()
        }

        fun skipBlank() {
            while (next >= 0 && next <= 32) {
                next = read()
            }
        }

        operator fun next(): String {
            return readString()
        }

        fun readInt(): Int {
            var sign = 1

            skipBlank()
            if (next == '+'.toInt() || next == '-'.toInt()) {
                sign = if (next == '+'.toInt()) 1 else -1
                next = read()
            }

            var `val` = 0
            if (sign == 1) {
                while (next >= '0'.toInt() && next <= '9'.toInt()) {
                    `val` = `val` * 10 + next - '0'.toInt()
                    next = read()
                }
            } else {
                while (next >= '0'.toInt() && next <= '9'.toInt()) {
                    `val` = `val` * 10 - next + '0'.toInt()
                    next = read()
                }
            }

            return `val`
        }

        fun readString(builder: StringBuilder): String {
            skipBlank()

            while (next > 32) {
                builder.append(next.toChar())
                next = read()
            }

            return builder.toString()
        }

        fun readString(): String {
            defaultStringBuf.setLength(0)
            return readString(defaultStringBuf)
        }

    }

    internal interface IntComparator {
        fun compare(a: Int, b: Int): Int

    }

    internal object SequenceUtils {
        fun swap(data: IntArray, i: Int, j: Int) {
            val tmp = data[i]
            data[i] = data[j]
            data[j] = tmp
        }

    }

    internal object CompareUtils {
        private val THRESHOLD = 4

        fun <T> insertSort(data: IntArray, cmp: IntComparator, l: Int, r: Int) {
            for (i in l + 1..r) {
                var j = i
                val `val` = data[i]
                while (j > l && cmp.compare(data[j - 1], `val`) > 0) {
                    data[j] = data[j - 1]
                    j--
                }
                data[j] = `val`
            }
        }

        fun quickSort(data: IntArray, cmp: IntComparator, f: Int, t: Int) {
            if (t - f <= THRESHOLD) {
                insertSort<Any>(data, cmp, f, t - 1)
                return
            }
            SequenceUtils.swap(data, f, Randomized.nextInt(f, t - 1))
            var l = f
            var r = t
            var m = l + 1
            while (m < r) {
                val c = cmp.compare(data[m], data[l])
                if (c == 0) {
                    m++
                } else if (c < 0) {
                    SequenceUtils.swap(data, l, m)
                    l++
                    m++
                } else {
                    SequenceUtils.swap(data, m, --r)
                }
            }
            quickSort(data, cmp, f, l)
            quickSort(data, cmp, m, t)
        }

    }
}


package contest

import java.io.OutputStream
import java.io.IOException
import java.io.InputStream
import java.util.Arrays
import java.io.UncheckedIOException
import java.io.Closeable
import java.io.Writer
import java.io.OutputStreamWriter

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
object programkt {
    @Throws(Exception::class)
    @JvmStatic
    fun main(args: Array<String>) {
        val thread = Thread(null, TaskAdapter(), "", (1 shl 27).toLong())
        thread.start()
        thread.join()
    }

    internal class TaskAdapter : Runnable {
        override fun run() {
            val inputStream = System.`in`
            val outputStream = System.out
            val `in` = FastInput(inputStream)
            val out = FastOutput(outputStream)
            val solver = DBonusDistribution()
            val testCount = Integer.parseInt(`in`.next())
            for (i in 1..testCount)
                solver.solve(i, `in`, out)
            out.close()
        }
    }

    internal class DBonusDistribution {
        fun solve(testNumber: Int, `in`: FastInput, out: FastOutput) {
            val n = `in`.readInt()
            var k = `in`.readInt()
            val a = arrayOfNulls<Employee>(n)
            for (i in 0 until n) {
                a[i] = Employee()
                a[i]?.v = `in`.readInt()
            }
            val sorted = a.clone()
            Arrays.sort(sorted) { x, y -> -Integer.compare(x!!.v, y!!.v) }
            for (i in 1 until n) {
                var allow = sorted[i - 1]!!.v - 1 - sorted[i]!!.v
                allow = Math.min(k, allow)
                k -= allow
                sorted[i]!!.v += allow
                sorted[i]!!.k = allow
            }
            val avg = k / n
            for (i in 0 until n) {
                sorted[i]!!.k += avg
            }
            val remain = k % n
            for (i in 0 until remain) {
                sorted[i]!!.k++
            }

            for (e in a) {
                out.append(e!!.k).append(' ')
            }
            out.println()
        }

    }

    internal class FastOutput(private val os: Writer) : AutoCloseable, Closeable, Appendable {
        private val cache = StringBuilder(10 shl 20)

        override fun append(csq: CharSequence): FastOutput {
            cache.append(csq)
            return this
        }

        override fun append(csq: CharSequence, start: Int, end: Int): FastOutput {
            cache.append(csq, start, end)
            return this
        }

        constructor(os: OutputStream) : this(OutputStreamWriter(os)) {}

        override fun append(c: Char): FastOutput {
            cache.append(c)
            return this
        }

        fun append(c: Int): FastOutput {
            cache.append(c)
            return this
        }

        fun println(): FastOutput {
            cache.append(System.lineSeparator())
            return this
        }

        fun flush(): FastOutput {
            try {
                os.append(cache)
                os.flush()
                cache.setLength(0)
            } catch (e: IOException) {
                throw UncheckedIOException(e)
            }

            return this
        }

        override fun close() {
            flush()
            try {
                os.close()
            } catch (e: IOException) {
                throw UncheckedIOException(e)
            }

        }

        override fun toString(): String {
            return cache.toString()
        }

    }

    internal class FastInput(private val `is`: InputStream) {
        private val defaultStringBuf = StringBuilder(1 shl 13)
        private val buf = ByteArray(1 shl 20)
        private var bufLen: Int = 0
        private var bufOffset: Int = 0
        private var next: Int = 0

        private fun read(): Int {
            while (bufLen == bufOffset) {
                bufOffset = 0
                try {
                    bufLen = `is`.read(buf)
                } catch (e: IOException) {
                    bufLen = -1
                }

                if (bufLen == -1) {
                    return -1
                }
            }
            return buf[bufOffset++].toInt()
        }

        fun skipBlank() {
            while (next >= 0 && next <= 32) {
                next = read()
            }
        }

        operator fun next(): String {
            return readString()
        }

        fun readInt(): Int {
            var sign = 1

            skipBlank()
            if (next == '+'.toInt() || next == '-'.toInt()) {
                sign = if (next == '+'.toInt()) 1 else -1
                next = read()
            }

            var `val` = 0
            if (sign == 1) {
                while (next >= '0'.toInt() && next <= '9'.toInt()) {
                    `val` = `val` * 10 + next - '0'.toInt()
                    next = read()
                }
            } else {
                while (next >= '0'.toInt() && next <= '9'.toInt()) {
                    `val` = `val` * 10 - next + '0'.toInt()
                    next = read()
                }
            }

            return `val`
        }

        fun readString(builder: StringBuilder): String {
            skipBlank()

            while (next > 32) {
                builder.append(next.toChar())
                next = read()
            }

            return builder.toString()
        }

        fun readString(): String {
            defaultStringBuf.setLength(0)
            return readString(defaultStringBuf)
        }

    }

    internal class Employee {
        var v: Int = 0
        var k: Int = 0

    }
}


import java.lang.AssertionError
import java.util.Scanner
private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readDouble() = readLn().toDouble() // single double
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints
private fun readLongs() = readStrings().map { it.toLong() } // list of longs
private fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles

fun main(args: Array<String>)
{
	val sc = Scanner(System.`in`)
    var t:Int = 1

    while(t>0)
    {

        var n = readInt()
        var dp = ArrayInt(n+9)
        var sum = ArrayLong(n+9)
        var cnt = ArrayInt(n+9)

        for(i in 1..n)
        {
            var j = i
            cnt[j] = 0
            while(j<=n){
                cnt[j]++
                j+=i
            }
        }

        dp[0] = 1; dp[1] = 1; sum[1] = 1
        for(i in 2..n)
        {
            dp[i] = cnt[i]
            dp[i]+=cnt[i]; dp[i]%=998244353
            sum[i] = (sum[i-1]+dp[i])%998244353
        }

        println(dp[n])

        t--
    }

}


/**
 * Class that solves codeforces problem.
 * It tries to replace wild cards(?) to letters to create lexicographically smallest palindrome.
 */
class PatternHandler(private val pattern: CharArray,
                     private val alphabet: Int) {

    private val IMPOSSIBLE_MESSAGE = "IMPOSSIBLE"
    private val usedChars = BitSet(alphabet)

    init {
        pattern
                .filter { it != '?' }
                .map { getIndex(it) }
                .forEach { usedChars[it] = true }
    }

    /**
     * Returns index of symbol in usedChars array
     */
    private fun getIndex(symbol: Char): Int = symbol - 'a'

    /**
     * Returns index of symbol in usedChars array
     */
    private fun getSymbol(index: Int): Char = 'a' + index

    /**
     * Get index letter that should be on the wild card sign.
     * It's take the most biggest lexicographically letter,
     * because we are starting to remove wild cards from center of the palindrome.
     */
    private fun getAppropriateLetterIndex(): Int {
        val index = usedChars.previousClearBit(alphabet - 1)

        return if (index == -1) {
            0
        } else {
            index
        }
    }

    /**
     * l, r -- indices in pattern.
     * If they are both wild cards they will be replaced by most biggest lexicographically letter.
     */
    private fun removeWildCardPairs(l: Int, r: Int) {
        if (pattern[l] == '?' && pattern[r] == '?') {
            val letterIndex = getAppropriateLetterIndex()
            val letter = getSymbol(letterIndex)
            usedChars[letterIndex] = true
            pattern[l] = letter
            pattern[r] = letter
        }
    }

    /**
     * Cleaning rest of wild cards.
     * If there any of chars at indices l, r equals wild card, then it should be replaced by another char.
     */
    private fun cleanWildCards(l: Int, r: Int) {
        if (pattern[l] == '?') {
            pattern[l] = pattern[r]
        }

        if (pattern[r] == '?') {
            pattern[r] = pattern[l]
        }
    }

    /**
     * Solving codeforces task.
     * It returns processed symmetric palindrome if it's possible.
     * Otherwise it returns IMPOSSIBLE_MESSAGE
     */
    fun solve(): String {
        if (alphabet > pattern.size) {
            return IMPOSSIBLE_MESSAGE
        }

        var r = pattern.size / 2
        while (r < pattern.size) {
            val indent = r - pattern.size / 2
            val l = r - (pattern.size + 1) % 2 - 2 * indent

            // process pattern
            removeWildCardPairs(l, r)
            cleanWildCards(l, r)

            if (pattern[l] != pattern[r]) {
                return IMPOSSIBLE_MESSAGE
            }

            r++
        }

        if (usedChars.cardinality() != alphabet) {
            return IMPOSSIBLE_MESSAGE
        }

        return String(pattern)
    }
}

/**
 * CLI for task: http://codeforces.com/contest/59/problem/C
 * Successful submission: http://codeforces.com/contest/59/my
 * Input contains of two lines. At the first line there is a number k.
 * On the second line there is pattern for constructing palindrome.
 */
fun main(args: Array<String>) {
    val k = Integer.parseInt(readLine())
    val pattern = readLine()!!
    val result = PatternHandler(pattern.toCharArray(), k).solve()
    print(result)
}


package ru.hse.spb

import java.util.*

fun main(args: Array<String>) {
    val input = Scanner(System.`in`)
    val k = input.nextInt()
    val pattern: String = input.next()

    val len = pattern.length
    var possible = true
    var free = 0

    val answer = CharArray(len)
    val used = BooleanArray(k)

    loop@ for (symbol in pattern) {
        val number = symbol.minus('a')
        when {
            number < 0 -> continue@loop
            number >= k -> possible = false
            else -> used[number] = true
        }
    }

    for (index in 0..(len - 1) / 2) {
        val left = pattern[index]
        val right = pattern[len - 1 - index]

        when {
            left != '?' && right != '?' && left != right -> possible = false
            left == '?' && right != '?' -> {
                answer[index] = right
                answer[len - 1 - index] = right
            }
            left != '?' && right == '?' -> {
                answer[index] = left
                answer[len - 1 - index] = left
            }
            left == '?' && right == '?' -> free++
            left == right -> {
                answer[index] = left
                answer[len - 1 - index] = right
            }
        }
    }

    val need = k - (used.filter { it }).size
    free -= need

    var currentPosition = 0
    (0..(len - 1) / 2)
            .asSequence()
            .filter { pattern[it] == '?' && pattern[len - 1 - it] == '?' }
            .forEach {
                if (free-- > 0) {
                    answer[it] = 'a'
                    answer[len - 1 - it] = 'a'
                } else {
                    while (currentPosition < k && used[currentPosition]) {
                        currentPosition++
                    }

                    if (currentPosition >= k) {
                        possible = false
                    }
                    val symbol = 'a'.plus(currentPosition++)
                    answer[it] = symbol
                    answer[len - 1 - it] = symbol
                }
            }

    if (possible) {
        println(String(answer))
    } else {
        println("IMPOSSIBLE")
    }
}


package ru.hse.spb

fun checkIn(character: Char, maxChar: Char) = character in 'a'..maxChar

fun main() {
    val numberOfRequiredLetters = readLine()?.toInt()
    val pattern = readLine()

    if (numberOfRequiredLetters == null || pattern == null) {
        println("Wrong input")
        return
    }

    val sz = pattern.length
    var free = 0
    val maxChar = ('a' + numberOfRequiredLetters - 1)
    val unusedChars = ('a'..maxChar).toHashSet()
    val stringArray = Array(sz) {'?'}

    for ((i, j) in (0 until sz).zip(sz - 1 downTo 1)) {
        val first = pattern[i]
        val second = pattern[j]

        if (first == '?' && second == '?') {
            free++
            continue
        }

        if (first == '?') {
            stringArray[i] = second
            stringArray[j] = second
        } else {
            stringArray[i] = first
            stringArray[j] = first
        }

        if (!checkIn(stringArray[i], maxChar)) {
            println("IMPOSSIBLE")
            return
        }
        unusedChars.remove(stringArray[i])
    }

    if (free < unusedChars.size) {
        println("IMPOSSIBLE")
        return
    }

    for ((i, j) in (0 until sz).zip(sz - 1 downTo 1)) {
        if (stringArray[i] != '?') {
            continue
        }

        val unusedCharacter = unusedChars.firstOrNull() ?: 'a'
        stringArray[i] = unusedCharacter
        stringArray[j] = unusedCharacter
        unusedChars.remove(unusedCharacter)
    }

    println(stringArray.joinToString(separator = ""))
}


package ru.spbau.mit
import java.util.*

fun getTitle(amountOfLetters: Int, pattern: String): String {
    val patternChars: CharArray = pattern.toCharArray()
    val patternLength = patternChars.size
    val occupiedLetters = mutableListOf<Boolean>()
    for (index in 0 until amountOfLetters) {
        occupiedLetters.add(index, false)
    }
    patternChars.forEach { letter ->
        run {
            if (letter != '?') {
                occupiedLetters[letter - 'a'] = true
            }
        }
    }
    val startIndex = if (patternLength % 2 == 0)
        patternLength / 2 - 1
    else
        patternLength / 2
    for (i in startIndex downTo 0) {
        if (patternChars[i] == '?') {
            val symmetricLetterIndex = patternLength - i - 1
            if (patternChars[patternLength - i - 1] == '?') {
                val theLastNotOccupiedLetterIndex = occupiedLetters.lastIndexOf(false)
                if (theLastNotOccupiedLetterIndex == -1) {
                    patternChars[i] = 'a'
                } else {
                    patternChars[i] = 'a' + theLastNotOccupiedLetterIndex
                    occupiedLetters[theLastNotOccupiedLetterIndex] = true
                }
                patternChars[patternLength - i - 1] = patternChars[i]
            } else {
                patternChars[i] = patternChars[symmetricLetterIndex]
            }
        }
    }

    (0 until patternLength)
            .filter { patternChars[it] == '?' }
            .forEach { patternChars[it] = patternChars[patternLength - it - 1] }
    (0 until patternLength)
            .filter { patternChars[it] != patternChars[patternLength - it - 1] }
            .forEach { return "IMPOSSIBLE" }

    if (occupiedLetters.contains(false)) {
        return "IMPOSSIBLE"
    }
    return patternChars.joinToString(separator = "")
}

fun main(args: Array<String>) {
    val input = Scanner(System.`in`)
    val amountOfLetters: Int = input.nextInt()
    val pattern: String = input.next()
    input.close()
    println(getTitle(amountOfLetters, pattern))
}