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

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 main(args: Array<String>)
{
    val sc = Scanner(System.`in`)
    var t:Int = sc.nextInt()
    while(t>0)
    {
        var n:Int = sc.nextInt()
        println((n-1)/2)
    }
}


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


fun main() {
    repeat(readLine()!!.toInt()) {

        val c = readLine()!!.toInt()
        var n = 0
        var i = c - 1
        var j = 1

        while (i > j) {
            n++
            i--
            j++
        }

        println(n)
    }
}


fun main() {
    val n = readLine()!!.toInt()
    repeat(n) {
        val k = readLine()!!.toInt()
        var a = k - 1
        var b = 1
        var sum = 0
        while(a > b){
            a--
            b++
            sum++
        }
        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.util.Scanner

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

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


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


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


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

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


import java.util.*
fun main(args: Array<String>) {

    val read = Scanner(System.`in`)
var t=read.nextInt()
while(t!=0)
    {
    var n = read.nextInt()

     if(n%2==0)
    println((n/2)-1)
    else
    println(n/2)
}
}


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

fun a6() {
    val list: List<Int> = readInts().sortedDescending()

    if (list[1] + list[2] > list[0] || list[2] + list[3] > list[0] || list[1] + list[3] > list[0] || list[2] + list[3] > list[1])
        print("TRIANGLE")
    else if (list[1] + list[2] + list[3] > list[0])
        print("SEGMENT")
    else
        print("IMPOSSIBLE")
}

fun main() {
    a6()
}


package codeforces

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

fun main() {
    val In = BufferedReader(InputStreamReader(System.`in`))
    val sticks = In.readLine()!!.split(" ").map {it.toInt()}
    sticks.sorted()
    if(sticks[0] + sticks[1] > sticks[2] && sticks[1] + sticks[2] > sticks[0] &&  sticks[0] + sticks[2] > sticks[1] ||
        sticks[1] + sticks[2] > sticks[3] && sticks[2] + sticks[3] > sticks[1] &&  sticks[1] + sticks[3] > sticks[2] ||
        sticks[0] + sticks[2] > sticks[3] && sticks[2] + sticks[3] > sticks[0] &&  sticks[0] + sticks[3] > sticks[2] ||
        sticks[1] + sticks[0] > sticks[3] && sticks[0] + sticks[3] > sticks[1] &&  sticks[1] + sticks[3] > sticks[0]) {
        println("TRIANGLE")
    } else if(sticks[0] + sticks[1] == sticks[2] || sticks[0] + sticks[1] == sticks[3] ||
        sticks[1] + sticks[2] == sticks[3] || sticks[0] + sticks[2] == sticks[3]) {
            println("SEGMENT")
    } else
        println("IMPOSSIBLE")

}


//package codeforces

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

fun main() {
    val In = BufferedReader(InputStreamReader(System.`in`))
    val sticks = In.readLine()!!.split(" ").map {it.toInt()}
    sticks.sorted()
    if(sticks[0] + sticks[1] > sticks[2] && sticks[1] + sticks[2] > sticks[0] &&  sticks[0] + sticks[2] > sticks[1] ||
        sticks[1] + sticks[2] > sticks[3] && sticks[2] + sticks[3] > sticks[1] &&  sticks[1] + sticks[3] > sticks[2] ||
        sticks[0] + sticks[2] > sticks[3] && sticks[2] + sticks[3] > sticks[0] &&  sticks[0] + sticks[3] > sticks[2] ||
        sticks[1] + sticks[0] > sticks[3] && sticks[0] + sticks[3] > sticks[1] &&  sticks[1] + sticks[3] > sticks[0]) {
        println("TRIANGLE")
    } else if(sticks[0] + sticks[1] == sticks[2] || sticks[0] + sticks[1] == sticks[3] ||
        sticks[1] + sticks[2] == sticks[3] || sticks[0] + sticks[2] == sticks[3]) {
            println("SEGMENT")
    } else
        println("IMPOSSIBLE")

}


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

fun main(args: Array<String>) {
    solve(System.`in`, System.out)
}

val MAX_N = (1e6 + 10).toInt()
val INF = (1e9 + 7).toInt()
val MOD = (1e9 + 7).toInt()

fun solve(input: InputStream, output: OutputStream) {
    val reader = InputReader(BufferedInputStream(input))
    val writer = PrintWriter(BufferedOutputStream(output))

    solve(reader, writer)
    writer.close()
}

fun solve(reader: InputReader, writer: PrintWriter) {
    val n = reader.nextInt()
    val s = reader.next()

    var i = 0
    var ans = 0
    while (i + 1 < n) {
        if (s[i] == 'U' && s[i + 1] == 'R') {
            ans++
            i++
        } else if (s[i] == 'R' && s[i + 1] == 'U') {
            ans++
        }

        i++
    }
    ans = n - ans
    writer.println(ans)
}

class InputReader(stream: InputStream) {
    val 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())
    }

    fun nextLong(): Long {
        return java.lang.Long.parseLong(next())
    }

    fun nextArrayInt(count: Int): IntArray {
        return nextArrayInt(0, count)
    }

    fun nextArrayInt(start: Int, count: Int): IntArray {
        val a = IntArray(start + count)
        for (i in start until start + count) {
            a[i] = nextInt()
        }
        return a
    }

    fun nextArrayLong(count: Int): LongArray {
        val a = LongArray(count)
        for (i in 0 until count) {
            a[i] = nextLong()
        }
        return a
    }
}


import java.io.*
import java.util.*
import kotlin.math.abs

private typealias Point = Pair<Long, Long>

private class B {
    var st = StringTokenizer("")
    val reader = BufferedReader(InputStreamReader(System.`in`))

    fun next(): String {
        while (!st.hasMoreTokens()) {
            st = StringTokenizer(reader.readLine())
        }
        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextDouble() = next().toDouble()
    fun nextLongPair() = nextLong() to nextLong()

    class Walker(var cur: Point, var t: Long) {
        fun dist(p1: Point, p2: Point): Long = abs(p1.first - p2.first) + abs(p1.second - p2.second)

        var res = 0
        fun goNext(p: Point) {
            if (t >= 0) {
                t -= dist(cur, p)
                cur = p
            }
            if (t >= 0) res++
        }

        fun walk(points: List<Point>) = points.forEach { goNext(it) }
    }

    fun tryIndex(start: Point, points: List<Point>, t: Long, i: Int): Int {
        val left = points.slice(0 until i).reversed()
        val right = points.slice(i until points.size)
        var max = 0
        for (i in 0..right.size) {
            for (j in 0..left.size) {
                val w1 = Walker(start, t)
                w1.walk(right.take(i) + left.take(j))
                max = maxOf(w1.res, max)
                val w2 = Walker(start, t)
                w2.walk(left.take(j) + right.take(i))
                max = maxOf(w2.res, max)
            }
        }
        return max
    }

    fun run() {
        val seed = nextLongPair()
        val (ax, ay) = nextLongPair()
        val (bx, by) = nextLongPair()
        val points = generateSequence(seed) { (x, y) ->
            val nx = x * ax + bx
            val ny = y * ay + by
            if (nx > 3 * 1e16 || ny > 3 * 1e16) null else nx to ny
        }.toList()
        println(points)
        val start = nextLongPair()
        val t = nextLong()
        println((0..points.size).map { tryIndex(start, points, t, it) }.max())
    }
}

fun main() {
    B().run()
}


import java.util.*
import kotlin.math.abs

fun main() {
    val sc = Scanner(System.`in`)
    val dots = mutableListOf(Pair(sc.nextLong(), sc.nextLong()))
    val ax = sc.nextLong()
    val ay = sc.nextLong()
    val bx = sc.nextLong()
    val by = sc.nextLong()
    val xs = sc.nextLong()
    val ys = sc.nextLong()
    var t = sc.nextLong()
    var devices = 0

    var minDistance = Long.MAX_VALUE
    var distanceDots = Long.MAX_VALUE
    var nextDot: Pair<Long, Long>? = null
    var currentDot = Pair(xs, ys)
    while (minDistance >= distanceDots) {
        if (nextDot != null) {
            dots.add(nextDot)
        }
        if (minDistance > distanceDots) {
            minDistance = distanceDots
        }
        nextDot = generateNextDot(ax, ay, bx, by, dots.last())
        distanceDots = distanceDots(currentDot, nextDot)
    }

    for (e in dots.asReversed()) {
        val time = distanceDots(currentDot, e)
        t -= time
        if (t < 0) {
            break
        }
        currentDot = e
        devices++
    }
    nextDot = dots.last()
    while (t > 0) {
        nextDot = generateNextDot(ax, ay, bx, by, nextDot!!)
        val time = distanceDots(currentDot, nextDot)
        t -= time
        if (t < 0) {
            break
        }
        currentDot = nextDot
        devices++
    }
    println(devices)
}

fun distanceDots(pair: Pair<Long, Long>, nextDot: Pair<Long, Long>) =
    abs(pair.first - nextDot.first) + abs(pair.second - nextDot.second)

fun generateNextDot(ax: Long, ay: Long, bx: Long, by: Long, last: Pair<Long, Long>) =
    Pair(ax * last.first + bx, ay * last.second + by)


import java.io.*
import java.util.*
import kotlin.math.abs

data class Point(val x: Long, val y: Long)

fun solve(inn: InputReader, out: PrintWriter) {
    val x0 = inn.readLong()
    val y0 = inn.readLong()
    val ax = inn.readLong()
    val ay = inn.readLong()
    val bx = inn.readLong()
    val by = inn.readLong()
    val xs = inn.readLong()
    val ys = inn.readLong()
    val t = inn.readLong()

    val pts = mutableListOf<Point>()
    pts.add(Point(x0, y0))
    while (pts.last().x < Long.MAX_VALUE / 4 && pts.last().y < Long.MAX_VALUE / 4) {
        val (x, y) = pts.last()
        pts.add(Point(x * ax + bx, y * ay + by))
    }

    var result = 0
    for (i in 0 until pts.size) {
        var x = xs
        var y = ys
        val dist = abs(x - pts[i].x) + abs(y - pts[i].y)
        if (dist > t) {
            continue
        }

        x = pts[i].x
        y = pts[i].y

        var impact = 1
        var remT = t - dist
        for (j in i - 1 downTo 0) {
            val dist = abs(x - pts[j].x) + abs(y - pts[j].y)
            if (dist > remT) {
                break
            }

            remT -= dist
            ++impact
            x = pts[j].x
            y = pts[j].y
        }

        for (j in i + 1 until pts.size) {
            val dist = abs(x - pts[j].x) + abs(y - pts[j].y)
            if (dist > remT) {
                break
            }

            remT -= dist
            ++impact
            x = pts[j].x
            y = pts[j].y
        }

        result = result.coerceAtLeast(impact)
    }

    out.println(result)
}

fun main() {
    val inn = InputReader(System.`in`)
//    val inn = InputReader(FileInputStream("1.txt"))
    val out = PrintWriter(System.out)

    solve(inn, out)

    inn.close()
    out.close()
}

class InputReader(inputStream: InputStream) {
    private val mReader = inputStream.bufferedReader()
    private var mTokenizer = StringTokenizer("")

    fun close() = mReader.close()

    fun readString(): String {
        while (!mTokenizer.hasMoreTokens()) {
            mTokenizer = StringTokenizer(mReader.readLine())
        }

        return mTokenizer.nextToken()
    }

    fun readInt() = readString().toInt()
    fun readLong() = readString().toLong()
}


import java.util.*

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

    val alp = arrayOf('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z')
    var max = -1

    for (c:Char in sc.next()) {
        val n = alp.indexOf(c)
        if (n <= max+1) max = Math.max(max, n)
        else {
            max == -1
            break
        }
    }
    println(if (max==-1) "NO" else "YES")
}


class MisterBReader(val c: Int,
                    val v0: Int,
                    val v1: Int,
                    val a: Int,
                    val l: Int
) {
    var v = v0
    var readedPages = 0

    fun getDaysToRead() : Int {
        var days = 1
        readedPages += v
        while(readedPages < c) {
            readedPages -= l
            v = if (v >= v1) v else v + a
            readedPages += v
            days++
        }
        return days
    }
}

fun main(args: Array<String>) {
    val(c, v0, v1, a, l) = readLine()!!.split(' ').map(String::toInt)
    println(MisterBReader(c, v0, v1, a, l).getDaysToRead())
}


fun main() {
    val visited = BooleanArray(26)
    for (c in readLine()!!) visited[c - 'a'] = true
    var pos = -1
    while (++pos < 26) if (!visited[pos]) break
    while (++pos < 26) if (visited[pos]) return print("NO")
    print("YES")
}


/**
 * Created by tux on 31.12.16.
 */

fun main(args: Array<String>) {
    val T = readLine()!!

    var nextChar = 'a'
    var ret = true
    for (c in T) {
        if (c == nextChar) {
            nextChar = (nextChar.toInt() + 1).toChar()

        } else if (c > nextChar) {
            ret = false
            break
        } else if (nextChar > 'z') {
            ret = false
            break
        }
    }

    println(if (ret) "YES" else "NO")
}


fun main(args: Array<String>) {
    val line = readLine()!!.toCharArray().distinct()

    (1 until line.size).forEach {
        if (line[it] - line[it - 1] != 1){
            println("NO")
            return
        }
    }

    if (line.size > 26){
        println("NO")
        return
    }

    println("YES")
}


//xXHEQR_MAENXx
//  You are not prepared!
@file:Suppress("NOTHING_TO_INLINE", "EXPERIMENTAL_FEATURE_WARNING", "OVERRIDE_BY_INLINE")

import java.io.PrintWriter
import java.util.StringTokenizer
import kotlin.math.*
import kotlin.random.*
import kotlin.collections.sort as _sort
import kotlin.collections.sortDescending as _sortDescending

//@JvmField val INPUT = File("input.txt").inputStream()
//@JvmField val OUTPUT = File("output.txt").outputStream()
@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() }

@JvmField val _writer = PrintWriter(OUTPUT, false)

private inline fun <T> _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {
    // Fisher-Yates shuffle algorithm
    for (i in size - 1 downTo 1) {
        val j = rnd.nextInt(i + 1)
        val temp = get(i)
        set(i, get(j))
        set(j, temp)
    }
}

@JvmField var _random: Random? = null
val random get() = _random ?: Random(0x594E215C127 * System.nanoTime()).also { _random = it }

fun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
fun IntArray.sort() { shuffle(); _sort() }
fun IntArray.sortDescending() { shuffle(); _sortDescending() }

fun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
fun LongArray.sort() { shuffle(); _sort() }
fun LongArray.sortDescending() { shuffle(); _sortDescending() }

fun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
fun DoubleArray.sort() { shuffle(); _sort() }
fun DoubleArray.sortDescending() { shuffle(); _sortDescending() }

fun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
inline fun CharArray.sort() { _sort() }
inline fun CharArray.sortDescending() { _sortDescending() }

inline fun <T: Comparable<T>> Array<out T>.sort() = _sort()
inline fun <T: Comparable<T>> Array<out T>.sortDescending() = _sortDescending()
inline fun <T: Comparable<T>> MutableList<out T>.sort() = _sort()
inline fun <T: Comparable<T>> MutableList<out T>.sortDescending() = _sortDescending()

fun main() { _writer.solve(); _writer.flush() }
fun PrintWriter.solve() {
    var (n, m) = readInts(2);

    var res: Int;
    if (n < m) {
        res = n * (m / 2) + (m % 2);
    }
    else {
        res = m * (n / 2) + (n % 2);
    }

    println(res);
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smthn instead of nothing and stay organized
	* WRITE STUFF DOWN
*/


import java.util.*

    fun main(){
        var input = Scanner(System.`in`)
        var m = input.nextInt()
        var n = input.nextInt()
        if(m*n > 2){
            System.out.println("${(m*n)/2}")
        }else{
            System.out.println("0")
        }
    }


import kotlin.math.max
import kotlin.math.min

fun main() {
    val (m, n) = readLine()!!.split(' ').map{ it.toInt() }
    var larger = max(m, n)
    var smaller = min(m, n)

    var numDominoes = 0
    if (smaller % 2 != 0) {
        numDominoes = smaller / 2
    }
    numDominoes += larger * (smaller / 2)
    println(numDominoes)
}


fun main() {
    val(m, n) = readLine()!!.split(' ').map(String::toInt)

    if(m==1 && n==1) {
        println(0)
    }
    else {
        val res = ( m / 2 ) * n
        println(res)
    }
}


func main() {
    val n = readLine()!!.split(" ").map { it.toInt() }

    print(n[0] * n[1] / 2)

}


fun main() {
    val r = System.`in`.bufferedReader()
    val s = StringBuilder()
    val a = r.readLine()!!.toInt()
    val b = r.readLine()!!.toInt()
    val c = r.readLine()!!.toInt()
    val max1 = maxOf(a+b*c, (a+b)*c)
    val max2 = maxOf(a*(b+c), a*b*c)
    println(maxOf(max1, max2))
}


fun main(args : Array<String>) {
    var arr = IntArray(3)
    for (i in 0..2)
        arr[i] = readLine()!!.toInt()
    var max = arr[0] * arr[1]
    if (arr[0] + arr[1] > max)
        max = arr[0] + arr[1]
    if (max * arr[2] > max + arr[2])
        println(max * arr[2])
    else
        println(max + arr[2] )
}


fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val a = scanner.nextInt()
    val b = scanner.nextInt()
    val c = scanner.nextInt()

    val case1 = (a + b) * c
    val case6 = a * b + c

    val case2 = a + b + c
    val case3 = a * b * c

    val case4 = a * b + c
    val case5 = a * (b + c)

    val result = arrayOf(case1, case2, case3, case4, case5, case6)

    println(result.max())
}


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

fun main() {
    val br = BufferedReader(InputStreamReader(System.`in`))
    val abc = Array(3){0}
    for (i in 0 until 3){
        abc[i] = br.readLine().toInt()
    }
    val nums = abc.sorted()
    println(
        if (nums[0] == 1){
            (nums[0] + nums[1]) * nums[2]
        } else{
            nums[0] * nums[1] * nums[2]
        }
    )
}


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

val alg1 = { i1: Int, i2: Int, i3: Int -> i1 + i2 * i3 }
val alg2 = { i1: Int, i2: Int, i3: Int -> i1 * (i2 + i3) }
val alg3 = { i1: Int, i2: Int, i3: Int -> i1 * i2 * i3 }
val alg4 = { i1: Int, i2: Int, i3: Int -> (i1 + i2) * i3 }

fun main(args: Array<String>) {
    val reader = BufferedReader(InputStreamReader(System.`in`))
    val arg1 = reader.readLine().toInt()
    val arg2 = reader.readLine().toInt()
    val arg3 = reader.readLine().toInt()
    val answers = listOf(alg1(arg1, arg2, arg3),
            alg2(arg1, arg2, arg3),
            alg3(arg1, arg2, arg3),
            alg4(arg1, arg2, arg3))
    println(answers.max())
}


fun main(args: Array<String>) {
    val (a,b,c) = Array(3, { readLine()!!.toInt()})
    println(arrayOf(a*b*c,(a+b)*c,a*(b+c)).max())
}


fun main(args: Array<String>) {
    val a = readLine()!!.toInt()
    val b = readLine()!!.toInt()
    val c = readLine()!!.toInt()

    fun addOrMultiply(x: Int, y: Int): Int {
        if (x == 1 || y == 1) {
            return x + y
        }
        else {
            return x * y
        }
    }

    println(addOrMultiply(addOrMultiply(a, b), c))
}


import kotlin.math.min

/**
 * Petya studies in a school and he adores Maths. His class has been studying arithmetic expressions. On the last
 * class the teacher wrote three positive integers a, b, c on the blackboard. The task was to insert signs of
 * operations '+' and '*', and probably brackets between the numbers so that the value of the resulting expression is
 * as large as possible. Let's consider an example: assume that the teacher wrote numbers 1, 2 and 3 on the blackboard.
 * Here are some ways of placing signs and brackets:
 * 1+2*3=7
 * 1*(2+3)=5
 * 1*2*3=6
 * (1+2)*3=9
 * Note that you can insert operation signs only between a and b, and between b and c, that is, you cannot swap integers.
 * For instance, in the given sample you cannot get expression (1+3)*2.
 * It's easy to see that the maximum value that you can obtain is 9.
 * Your task is: given a, b and c print the maximum value that you can get.
 *
 * Input
 * The input contains three integers a, b and c, each on a single line (1 ≤ a, b, c ≤ 10).
 *
 * Output
 * Print the maximum value of the expression that you can obtain.
 */
fun readInt(): Int = readLine()!!.toInt()

fun readInputs():MutableList<Int> {
    val inputList:MutableList<Int> = mutableListOf()
    for (i in 0..2){
        inputList += listOf(readInt())
    }
    return inputList
}

fun sum0and1(list: MutableList<Int>):List<Int>{
    if (list.contains(0)) {
        list.remove(0)
    }
    var counter = 0
    for (i in 0..2){
        if (list[i] == 1) counter++
    }
    return if(counter < 2) {
        if (list.contains(1)) {
            val index = list.indexOf(1)
            list.remove(1)
            if(index!=0 || index!=2) {
                val minValue = min(list[index], list[index - 1])
                if (minValue == list[index]) list[index]++ else list[index - 1]++
            }
            else if(index == 0){
                list[index]++
            }
            else{
                list[index-1]++
            }
        }
        list.toList()
    }
    else {
        listOf(list.reduce { acc: Int, i: Int -> acc + i }.toInt())
    }
}

fun maxResult(list: List<Int>): Int = list.reduce { acc, i -> acc * i }

fun main(){
    val inputValues = readInputs().toMutableList()
    val filteredList = sum0and1(inputValues)
    val result = maxResult(filteredList)
    println(result)
}


import kotlin.math.*
import java.math.BigInteger

fun pow(n: Long, exp: Int): Long {
  val maxValue = BigInteger.valueOf(10).pow(9) + BigInteger.valueOf(7)
  return (BigInteger.valueOf(n).pow(exp) % maxValue).toLong()
}

fun main() {
  val r = System.`in`.bufferedReader()
  val input = r.readLine()!!.split(" ").map { it.toLong() }

  if (input[2] == 1L || input[2] > input[0]) {
    println(pow(input[1], input[0].toInt()))
  } else if (input[0] == input[2]) {
    println(pow(input[1], input[0].toInt()))
  } else {
    val maxValue = 10.toDouble().pow(9).toLong() + 7
    if (input[2] % 2L == 0L) {
      println(input[1] % maxValue)
    } else {
      println((input[1]*input[1]) % maxValue)
    }
  }
}


import java.util.*

fun main(args: Array<String>){

    var bool = false
    val array = arrayOf(4,7,44,47,74,77,444,447,474,477,744,747,774,777)
    val scan = Scanner(System.`in`)
    val n = scan.nextByte()

    for (i in array){
        if (n % i == 0) bool = true
    }

    if (bool) println("YES")
    else println("NO")
}


fun main() {
    val n = readLine()!!
    val regex = Regex("[47]*")
    val num = n.toInt()
    val ans = if (regex.matches(n) || num % 4 == 0 || num % 7 == 0) {
        "YES"
    } else {
        "NO"
    }
    println(ans)
}


fun main() {
        val number = readLine()!!
        if(number.replace("4", "").replace("7", "").isEmpty()) {
            println("YES")
        } else {
           val pn = number.toInt()
            if(pn % 4 == 0 || pn % 7 == 0) {
                println("YES")
            } else {
                println("NO")
            }
        }
    }


import kotlin.math

fun main(args: Array<String>) {
	val matrix: MutableList<List<Int>> = mutableListOf()
	for (i in 0 until 5) {
		val row = readLine()!!.split(' ').map(String::toInt)
		matrix.add(row)
	}
	println(getResult(matrix))
}

fun getResult(matrix: List<List<Int>>): Int {
	val centerI = 3
	val centerJ = 3
	var integerI = 0
	var integerJ = 0

	loop@ for (i in 0 until matrix.size) {
		for (j in 0 until matrix[i].size) {
			if (matrix[i][j] == 1) {
				integerI = i
				integerJ = j
				break@loop
			}
		}
	}

	return abs(integerI - centerI) + abs(integerJ - centerJ)

}


import kotlin.math.abs

fun main(args: Array<String>) {
	val matrix: MutableList<List<Int>> = mutableListOf()
	for (i in 0 until 6) {
		val row = readLine()!!.split(' ').map(String::toInt)
		matrix.add(row)
	}
	println(getResult(matrix))
}

fun getResult(matrix: List<List<Int>>): Int {
	val centerI = 3
	val centerJ = 3
	var integerI = 0
	var integerJ = 0

	loop@ for (i in 0 until matrix.size) {
		for (j in 0 until matrix[i].size) {
			if (matrix[i][j] == 1) {
				integerI = i
				integerJ = j
				break@loop
			}
		}
	}

	return abs(integerI - centerI) + abs(integerJ - centerJ)

}


import java.io.PrintWriter
import java.util.StringTokenizer
import kotlin.math.*
import kotlin.random.*
import kotlin.collections.sort as _sort
import kotlin.collections.sortDescending as _sortDescending
import kotlin.io.println as iprintln

fun main() { _writer.solve(); _writer.flush() }

fun PrintWriter.solve() {
    var pos = 0
    var totalMove = 0
    for (i in 0 until 5) {
        val intData = readInts(5)
        for (j in intData.indices) {
            if (intData[j] == 1) break
            else pos ++
        }
    }
    while (pos != 12) {
        when(pos) {
            in 0..4-> {
                pos += 5
                totalMove++
            }
            in 5..9-> {
                pos += 5
                totalMove++
            }
            in 15..19-> {
                pos -= 5
                totalMove++
            }
            in 20..24-> {
                pos -= 5
                totalMove++
            }
            in 10..14 -> {
                totalMove += Math.abs(12 - pos)
                pos == 12
            }
        }
    }
    println(totalMove)
 }

/** IO code start */
//@JvmField val INPUT = File("input.txt").inputStream()
//@JvmField val OUTPUT = File("output.txt").outputStream()
@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() }

@JvmField val _writer = PrintWriter(OUTPUT, false)

/** shuffles and sort overrides to avoid quicksort attacks */
private inline fun <T> _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {
    // Fisher-Yates shuffle algorithm
    for (i in size - 1 downTo 1) {
        val j = rnd.nextInt(i + 1)
        val temp = get(i)
        set(i, get(j))
        set(j, temp)
    }
}

@JvmField var _random: Random? = null
val random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }

fun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
fun IntArray.sort() { shuffle(); _sort() }
fun IntArray.sortDescending() { shuffle(); _sortDescending() }

fun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
fun LongArray.sort() { shuffle(); _sort() }
fun LongArray.sortDescending() { shuffle(); _sortDescending() }

fun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
fun DoubleArray.sort() { shuffle(); _sort() }
fun DoubleArray.sortDescending() { shuffle(); _sortDescending() }

fun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
inline fun CharArray.sort() { _sort() }
inline fun CharArray.sortDescending() { _sortDescending() }

inline fun <T: Comparable<T>> Array<out T>.sort() = _sort()
inline fun <T: Comparable<T>> Array<out T>.sortDescending() = _sortDescending()
inline fun <T: Comparable<T>> MutableList<out T>.sort() = _sort()
inline fun <T: Comparable<T>> MutableList<out T>.sortDescending() = _sortDescending()


[3:36 PM] NamHP
    + tức là 1 lần đúng luôn
[3:36 PM] NamHP
    fun main()
{
    var result = 0
    for (i in 1..5)
    {
        val (a, b, c, d, e) = readLine()!!.split(" ").map { it.toInt() }
        if(i==1 || i==5)
        {
            if (a == 1 || e == 1) {
                result = 4
            break
            }
            if (b == 1 || d == 1) {
                result = 3
            break
            }
            if (c == 1) {
                result = 2
            break
            }
        }
        if(i==2 || i==4)
        {
            if (a == 1 || e == 1) {
                result = 3
            break
            }
            if (b == 1 || d == 1) {
                result = 2
            break
            }
            if (c == 1) {
                result = 1
            break
            }
        }
        if(i==3)
        {
            if (a == 1 || e == 1) {
                result = 2
            break
            }
            if (b == 1 || d == 1) {
                result = 1
            break
            }
            if (c == 1) {
                result = 0
            break
            }
        }
    }
    println(result)
}


import java.util.*
import kotlin.math.abs

    var array=Array(5){IntArray(5)}
    var read: Scanner=Scanner(System.`in`)
    fun main(){

        var x:Int=0
        var y:Int=0
        for(i in 1..5)
            for(j in 1..5){
                array[i][j]=read.nextInt()
                if(array[i][j]==1){
                    x=i
                    y=j
                }
            }
        println(abs(x-3)+ abs(y-3))
    }


fun main()
{
	var result = 0
	for (i in 1..5)
	{
		val (a, b, c, d, e) = readLine()!!.split(" ").map { it.toInt() }
		if(i==1 || i==5)
		{
			if (a == 1) {
				result = 4
			break
			}
			if (b == 1) {
				result = 3
			break
			}
			if (c == 1) {
				result = 1
			break
			}
			if (d == 1) {
				result = 1
			break
			}
			if (e == 1) {
				result = 2
			break
		}
		if(i==2 || i==4)
		{
			if (a == 1) {
				result = 3
			break
			}
			if (b == 1) {
				result = 2
			break
			}
			if (c == 1) {
				result = 1
			break
			}
			if (d == 1) {
				result = 2
			break
			}
			if (e == 1) {
				result = 3
			break
		}
		if(i==3)
		{
			if (a == 1) {
				result = 2
			break
			}
			if (b == 1) {
				result = 1
			break
			}
			if (c == 1) {
				result = 0
			break
			}
			if (d == 1) {
				result = 1
			break
			}
			if (e == 1) {
				result = 2
			break
		}
	}
	println(result)
}


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

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

fun qpowmod(ta:Long, tb:Long, mod:Long):Long {
	var a = ta
	var b = tb
	var res=1L
	while(b>0) {
		if(b%2==1L)
			res=res*a
		b/=2
		a=a*a%mod
	}
	return res
}

fun main(args: Array<String>) {
	var (n,m) = readInts()
	println(qpowmod(2,(n+m).toLong(), 998244353))
}


fun main() {
	var (x, y, z) = readLine()!!.split(' ').map(String::toInt)
	var (a, b, c) = readLine()!!.split(' ').map(String::toInt)
	if (a < x || a + b < x + y || a + b + c < x + y + z) {
		println("NO")
	} else {
		println("YES")
	}
	return 0;
}


fun main() {
    val r = System.`in`.bufferedReader()
    val s = StringBuilder()
    //val n = r.readLine()!!.toInt()
    //var (n, m) = r.readLine()!!.split(" ").map { it.toInt() }
    val (x, y, z) = r.readLine()!!.split(" ").map { it.toInt() }
    val (a, b, c) = r.readLine()!!.split(" ").map { it.toInt() }
    val ans = a>=x&&(a+b>=y)&&(a+b+c>=z)
    println(if (ans)"YES" else "NO")
}


import java.util.*

fun isOdd(x:Int) :Boolean
{
    if (x%2 == 0)
        return false
    else
        return true
}

fun isValid(x:Int,y:Int):Boolean
{
    if (x>=0 && x<=2 && y>=0 && y<=2)
        return true
    else
        return false
}

val reader = Scanner(System.`in`)
var arr = arrayOf<Array<Int>>()
var ans = arrayOf<Array<Int>>()
val dx = intArrayOf(0,0, 0,1,-1)
val dy = intArrayOf(0,1,-1,0, 0)

fun main(args: Array<String>) {
    for (x in 0..2)
    {
        val row = Array<Int>(3,{i -> reader.nextInt()})
        val reset = Array<Int>(3,{i -> 1})
        arr+=row
        ans+=reset
    }

    for (i in 0..2)
        for (j in 0..2)
            if (isOdd(arr[i][j]))
                for (k in 0..4)
                    if (isValid(i+dx[k],j+dy[k]))
                        ans[i+dx[k]][j+dy[k]] = ans[i+dx[k]][j+dy[k]] xor 1

    for (row in ans)
        for (value in row)
            print(value)
        println()

}


import kotlin.math.min
import kotlin.math.sign

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 main() {
    val arr = Array(4) { IntArray(4) }
    for (i in 1..3) {
        val s = readInts()
        for (j in 1..3) {
            arr[i][j] = s[j - 1]
        }
    }
    for (i in 1..3) {
        for (j in 1..3) {
            val sum = arr[i][j] + arr[i - 1][j] + arr[i + 1][j] + arr[i][j - 1] + arr[i][j + 1]
            print(if (sum % 2 == 0) 1 else 0)
        }
        println()
    }
}


import java.util.*

fun main(args: Array<String>) = with(Scanner(System.`in`), {
    var n = nextInt()
    if (n == 2) print("NO")
    else print("YES")
})


private fun solve() {
    val n = readInt()
    var l = 0
    var r = n-1
    var a = mutableListOf<Int>()
    repeat(n) {
        a.add(readInt())
    }
    var pre = 0
    var times = 0
    var turn = 0
    var A = 0
    var B = 0
    while (true) {
        var cur = 0
        if (turn==0) {
            while (l<=r && cur<=pre) {
                cur += a[l];
                ++l;
            }
            A += cur
        }
        else {
            while (l<=r && cur<=pre) {
                cur += a[r];
                --r;
            }
            B += cur
        }
        pre = cur
        ++times
        if (l>r)
            break
        turn = 1 - turn
    }
    println ("${times.toString()} ${A.toString()} ${B.toString()} ")
}

fun main () {
    val n = readInt()
    for (i in 1..n) solve()
}

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

@JvmField val _writer = PrintWriter(OUTPUT, false)
inline fun output(block: PrintWriter.() -> Unit) { _writer.apply(block).flush() }


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

public class Main {
  public static IO in;
  public static PrintWriter out;

  static void init_io(String filename) throws Exception {
    if (filename.equals("")) {
      in = new IO(System.in);
      out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), true);
    } else {
      in = new IO(new FileInputStream(filename + ".in"));
      out = new PrintWriter(new BufferedWriter(new FileWriter(filename + ".out")), true);
    }
  }

  final static long mod = 998244353;

/*
fun main(args: Array<String>) {
    Main.main(args);
}
*/

  static void solve(int tc) throws Exception {
    int n = in.nint();

    int[] a = new int[n];
    for (int i = 0; i < n; i++) a[i] = in.nint();

    int v = 0, u = 0;
    int c = 0, t = 0;
    int l = 0, r = n - 1;
    while (l <= r) {
      int x = 0;
      ++t;
      while (l <= r && x <= c) {
        x += a[l];
        v += a[l];
        ++l;
      }
      if (l > r) break;
      ++t;
      c = x;
      x = 0;
      while (l <= r && x <= c) {
        x += a[r];
        u += a[r];
        --r;
      }
      c = x;
    }
    out.println(t + " " + v + " " + u);
  }

  public static void main(String[] _u_n_u_s_e_d_) throws Exception {
    init_io("");

    int t = 1;
    t = in.nint();
    for (int tc = 0; tc < t; tc++) {
      solve(tc);
    }
  }

  static long minv(long v) {
    return mpow(v, mod - 2);
  }

  static long mpow(long base, long exp) {
    long res = 1;

    while (exp > 0) {
      if ((exp & 1) == 1) {
        res = (res * base) % mod;
      }
      base = (base * base) % mod;
      exp >>= 1;
    }

    return res;
  }

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

  static void rsort(long[] arr) {
    Random r = new Random();
    for (int i = 0; i < arr.length; i++) {
      int j = i + r.nextInt(arr.length - i);
      long t = arr[i];
      arr[i] = arr[j];
      arr[j] = t;
    }
    Arrays.sort(arr);
  }

  static void rsort(int[] arr) {
    Random r = new Random();
    for (int i = 0; i < arr.length; i++) {
      int j = i + r.nextInt(arr.length - i);
      int t = arr[i];
      arr[i] = arr[j];
      arr[j] = t;
    }
    Arrays.sort(arr);
  }

  /* static void qsort(long[] arr) {
    Long[] oarr = new Long[arr.length];
    for (int i = 0; i < arr.length; i++) {
      oarr[i] = arr[i];
    }

    ArrayList<Long> alist = new ArrayList<Long>(Arrays.asList(oarr));
    Collections.sort(alist);

    for (int i = 0; i < arr.length; i++) {
      arr[i] = (long)alist.get(i);
    }
  } */

  static void reverse(long[] arr) {
    for (int i = 0; i < arr.length / 2; i++) {
      long temp = arr[i];
      arr[i] = arr[arr.length - 1 - i];
      arr[arr.length - 1 - i] = temp;
    }
  }

  static String atos(long[] arr) {
    String s = Arrays.toString(arr);
    s = s.substring(1, s.length() - 1);
    return s.replace(",", "");
  }

  static class IO {
    public BufferedReader in;
    public StringTokenizer tokens;

    public IO(InputStream x) throws Exception {
      in = new BufferedReader(new InputStreamReader(x));
      tokens = new StringTokenizer(in.readLine());
    }

    int nint() throws Exception {
      return Integer.parseInt(nstr());
    }

    long nlong() throws Exception {
      return Long.parseLong(nstr());
    }

    double ndouble() throws Exception {
      return Double.parseDouble(nstr());
    }

    String nstr() throws Exception {
      if (!tokens.hasMoreTokens()) tokens = new StringTokenizer(in.readLine());
      return tokens.nextToken();
    }

    long[] nla(int n) throws Exception {
      long[] arr = new long[n];
      for (int i = 0; i < n; i++) {
        arr[i] = nlong();
      }
      return arr;
    }
  }

  static class Pair<A extends Comparable<A>, B extends Comparable<B>> implements Comparable<Pair<A, B>> {
    public A f;
    public B s;

    public Pair(A a, B b) {
      f = a;
      s = b;
    }

    public int compareTo(Pair<A, B> other) {
      int v = f.compareTo(other.f);
      if (v != 0) return v;
      return s.compareTo(other.s);
    }

    public String toString() {
      return "(" + f.toString() + ", " + s.toString() + ")";
    }
  }
}


fun main() {
    val lines: Int = readLine()?.toInt() ?: 0
    for (i in 0 until lines) {
        val count = readLine()?.toInt() ?: 0
        val sweets = (readLine() ?: "").split(" ")
        val list = LinkedList<Int>(sweets.map { it.toInt() })
        val alice = mutableListOf<Int>()
        val bob = mutableListOf<Int>()
        var turn = 0
        var min = 0
        while (!list.isEmpty()) {
            if (turn % 2 != 0) {  //Bob
                var tmp = 0
                while (tmp <= min) {
                    val n = list.pollLast() ?: break
                    bob.add(n)
                    tmp += n
                }
                min = tmp
            } else { // Alice
                var tmp = 0
                while (tmp <= min) {
                    val n = list.pollFirst() ?: break
                    alice.add(n)
                    tmp += n
                }
                min = tmp
            }
            turn++
        }
        println("$turn ${alice.sum()} ${bob.sum()}")
    }
}


import java.util.Scanner

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

    while(t > 0) {
        t--;
        var size = read.nextInt()
        var Candy = ArrayList<Int>()
        for(i in 1..size) {
            var temp = read.nextInt()
            Candy.add(temp)
        }
        var a_idx = -1
        var b_idx = size
        var a_sum = 0
        var b_sum = 0
        var prevEat = 0
        var thisEat = 0
        var turnWho = 0
        var turnCount = 0
        while(a_idx + 1 < b_idx) {
            if(thisEat == 0) {
                turnCount += 1
            }

            if(turnWho == 0) {
                a_idx + 1
                a_sum += Candy[a_idx]
                thisEat += Candy[a_idx]
            } else {
                b_idx += 1
                b_sum += Candy[b_idx]
                thisEat += Candy[b_idx]
            }

            if(thisEat > prevEat) {
                prevEat = thisEat
                thisEat = 0
                turnWho = if(turnWho == 0) 1 else 0
            }
        }

        println("$turnCount $a_sum $b_sum")
    }
}


import java.util.*
import java.io.PrintWriter
import kotlin.collections.ArrayList
fun main(args: Array<String>) {
    val out=PrintWriter(System.out)
    val read = Scanner(System.`in`)
    var t=read.nextInt()
	while(t-->0){
       var n=read.nextInt()
       var queue = ArrayDeque<Int>()
       for(i in 0 until n){
           queue.add(read.nextInt())
       }
       var a = 0;var pa=0
       var b = 0;var pb=0
       var move = 0;var turn=0
       while(!queue.isEmpty()){
           move++
           if(turn==0){
               var na=0
               while(!queue.isEmpty()&&na<pb) na+=queue.pollFirst()
               pa=na
               a+=na
           }
           else{
               var nb=0
               while(!queue.isEmpty()&&nb<pa) nb+=queue.pollLast()
               pb=nb
               b+=nb
           }
           turn=turn.xor(1)
       }
       out.printf("%d %d %d\n",move,a,b)
    }
	out.close()

}


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

fun main() {
    var T = readInt()
    for (q in 1..T) {
        var N = readInt()
        var Candy = readInts()
        var A_idx = -1
        var B_idx = N
        var A_sum = 0
        var B_sum = 0
        var PrevEat = 0
        var ThisEat = 0
        var TurnWho = 0
        var TurnCnt = 0
        while (A_idx < B_idx) {
            if (ThisEat == 0) TurnCnt += 1
            if (TurnWho == 0) {
                A_idx += 1
                A_sum += Candy[A_idx]
                ThisEat += Candy[A_idx]
            } else {
                B_idx -= 1
                B_sum += Candy[B_idx]
                ThisEat += Candy[B_idx]
            }
            if (ThisEat > PrevEat) {
                PrevEat = ThisEat
                ThisEat = 0
                TurnWho = if (Turn == 0) 1 else 0
            }
        }
        print("$TurnCnt $A_sum $B_sum\n")
    }
}


fun main(){
    val t = readLine()!!.toInt()
	for (i in 1..t){
        var m = readLine()!!.toInt()
	var n = readLine()!!.split(" ").map { it.toInt() }
        var b = m
        var count = 0
        var counta:Int
        var countb:Int
        var totala = 0
        var totalb = 0
        var step = 0
      	while (b>a+1){
            counta = 0
            while ((counta<=count)&&(a+1<b)){
                a++
                counta=counta+n[a]
            }
            step++
	        count=counta
            totala=totala+counta
			if (a+1<b){
	            countb = 0
   		        while ((countb<=count)&&(a+1<b)){
	                b--
    	            countb=countb+n[b]
       		    }
	            step++
    	        count=countb
	            totalb=totalb+countb
            }
        }
    println("${step} ${totala} ${totalb}")
    }
}


fun main(){
    val t = readLine()!!.toInt()
	for (i in 1..t){
        var m = readLine()!!.toInt()
	var n = readLine()!!.split(" ").map { it.toInt() }
	var a = 0
        var b = m+1
        var count = 0
        var counta = 0
        var countb = 0
        var totala = 0
        var totalb = 0
      	while (b>a){
            counta = 0
            while ((counta<=count)&&(a<b)){
                a++
                counta=counta+n[a]
            }
	        count=count+counta
            totala=totala+counta
            countb = 0
            while ((countb<=count)&&(a<b)){
                b--
                countb=countb+n[b]
            }
            count=count+countb
            totalb=totalb+countb
        }
    }
}


fun main() {

    var count = readLine()!!.toInt()
    val results = mutableListOf<GameResult>()

    while (count-- != 0) {
        val size = readLine()
        val sweets = readLine()!!.split(' ').map { it.toInt() }.toMutableList()
        results.add(game(sweets))
    }

    results.forEach { r ->
        println("${r.moves} ${r.leftWeight} ${r.rightWeight}")
    }
}

data class GameResult(
        val moves: Int,
        val leftWeight: Int,
        val rightWeight: Int
)

fun game(sweets: MutableList<Int>): GameResult {
    var moves = 0
    var leftWeight = 0
    var rightWeight = 0

    while (sweets.isNotEmpty()) {
        leftWeight += eatLeft(rightWeight, sweets)
        moves++

        if (sweets.isEmpty())
            break

        rightWeight += eatRight(leftWeight, sweets)
        moves++
    }

    return GameResult(moves, leftWeight, rightWeight)
}

fun eatLeft(min: Int, sweets: MutableList<Int>): Int {
    var eaten = 0
    do {
        eaten += sweets.removeAt(0)
    } while (eaten < min && sweets.isNotEmpty())

    return eaten
}

fun eatRight(min: Int, sweets: MutableList<Int>): Int {
    var eaten = 0
    do {
        eaten += sweets.removeAt(sweets.size - 1)
    } while (eaten < min && sweets.isNotEmpty())

    return eaten


fun main() {
    val numbers = readLine()!!.toInt()
    (0..numbers - 1).forEach {
        readLine()!!
        var mas = readLine()!!.split(" ").map { it.toInt() }
        var alice = 0
        var bob = 0
        var last = 0
        var hod = 0

        while (mas.isNotEmpty()) {
            var collect = 0
            mas = mas.dropWhile {
                val b = collect <= last
                if (b) collect += it
                b
            }
            if (hod % 2 == 0) {
                alice += collect
            } else {
                bob += collect
            }
            last = collect
            hod = hod + 1
            mas = mas.reversed()
        }
        println("$hod $alice $bob")
    }
}


private fun solve(){
    val nn = readLine()!!.toInt()
    val aa = readLine()!!.split(" ").map{it.toInt()}
    var moves=0; var asum=0; var bsum=0; var prevv=0; var ll=0; var rr=nn-1;
    while (ll<=rr) {
        if(ll<=rr) {
            moves++
            var cur=0
            while (ll<=rr && cur<=prevv) cur += aa[l++]
            asum+=cur
            prevv=cur
        }
        if(ll<=rr){
            moves++
            var cur=0
            while (ll<=rr && cur<=prevv) cur += aa[rr--]
            bsum+=cur
            prevv=cur
        }
    }
    println("$moves $asum $bsum")
}

fun main(){
    var T = readLine()!!.toInt()
    while(T-->0) solve()
}


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

            }
        }
    }


import java.util.*
import kotlin.math.ceil

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


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


fun main() {
    val numberOfTests = readLine()!!.toInt()
    repeat(numberOfTests){
        val numberOfCandies = readLine()!!.split(' ')[0].toInt()
        if(numberOfCandies <= 2) {
            println(0)
            return@repeat
        }
        var alice = numberOfCandies - 1
        var betty = numberOfCandies - alice
        var ct = 0
        while (alice > betty){
            alice -= 1
            betty = numberOfCandies - alice
            ct++
        }
        println(ct)
    }

}


fun main(args: Array<String>) {
    val t = readLine()!!.toInt()
    for (i in 0..t) {
        val n = readLine()!!.toInt()
        when {
            n < 3 -> {
                println(0)
            }
            n % 2 == 0 -> {
                println(n / 2 - 1)
            }
            else -> {
                println(n / 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)
    }
}


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(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() {
    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.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)}")
    }
}


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


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
        var count = 0
        while (A > B) {
            count += 1
        }
        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

fun main() {
  val i = readInt()
  var results = mutableListOf()
  for(x in 1..i) {
    val g = readInt() - 1
    results.add(g / 2)
  }
  print(results)
}


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 main() = for(x in 1..readInt()) println((readInt() - 1) / 2)


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.io.BufferedReader
import java.io.InputStreamReader
import java.util.*
import java.util.Collections.min
import java.util.Collections.swap
import kotlin.collections.ArrayList
import kotlin.math.min
import kotlin.random.Random.Default.nextInt

fun main(args: Array<String>) {

    // Creates a reader instance which takes
    // input from standard input - keyboard
    val reader = Scanner(System.`in`)
    var n:Int = reader.nextInt()
    while (n -- > 0){
       solve()
    }
}

fun solve(){
    val reader = Scanner(System.`in`)
    var v = mutableListOf<Int>()
    var n :Int
    var k : Int
    var s : String
    var w : String
    n = reader.nextInt()
    k = reader.nextInt()
    s = reader.nextLine()
    var ss =  IntArray(s.length)
    for (i in 0 until n) {
        if(s[i] == '0'){
            ss[i] = 0
            v.add(i)
        }
        else{
            ss[i] = 1
        }
    }
    var b = 0
    var r = 0

    while(k > 0 ){
        if(r == v.size){
            break
        }
        if(k >= v[r] - b){
            var temp = ss[v[r]]
            ss[v[r]] = ss[b]
            ss[b] = temp
            k -= v[r]-b
            b++
            r++
        }
        else {
            var temp = ss[v[r]]
            ss[v[r]] = ss[v[r]-k]
            ss[v[r]-k]=temp
            k = 0
        }
    }
    var sss = ""
    for(i in ss){
        sss += i.toString()
    }
    println(sss)
    return

}


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)

    }

}


fun main() {
    var l: String? = null
    while (run {l = readLine(); l} != null)
        println((l+1)/2)
}


import java.util.Scanner;

fun main() {
   var sc = Scanner(System.`in`);
   var t = sc.nextInt();
   while( t > 0) {
     var n = sc.nextInt();
      println((n+1)/2-1)
   }
}


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


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>) {
    var t = readInt()
    while (t--) {
        var n = readInt();
        println((n-1)/2);
    }

}


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


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


import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.lang.StringBuilder
import java.util.*

fun main(args: Array<String>) {
    val sc = FastScanner(System.`in`)
    val n = sc.nextLong()
    val m = sc.nextLong()
    var ans = ModInt(n - 2) * ModInt(2).pow(n - 3) * comb(ModInt(m), ModInt(n - 1))
    println(ans)
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

private class ModInt(x: Long) {

    companion object {
        const val MOD = 998244353L
    }

    val x = (x % MOD + MOD) % MOD

    operator fun plus(other: ModInt): ModInt {
        return ModInt(x + other.x)
    }

    operator fun minus(other: ModInt): ModInt {
        return ModInt(x - other.x)
    }

    operator fun times(other: ModInt): ModInt {
        return ModInt(x * other.x)
    }

    operator fun div(other: ModInt): ModInt {
        return this * other.inv()
    }

    fun pow(exp: Long): ModInt {
        if (exp == 0L) return ModInt(1L)
        var a = pow(exp shr 1)
        a *= a
        if (exp and 1L == 0L) return a
        return this * a
    }

    fun inv(): ModInt {
        return this.pow(MOD - 2)
    }

    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (javaClass != other?.javaClass) return false

        other as ModInt

        if (x != other.x) return false

        return true
    }

    override fun hashCode(): Int {
        return x.hashCode()
    }

    override fun toString(): String {
        return "$x"
    }

}

private fun fact(n: ModInt): ModInt {
    return (2..n.x).fold(ModInt(1L)) { acc, l -> acc * ModInt(l) }
}

private fun comb(n: ModInt, k: ModInt): ModInt {
    return fact(n) / fact(k) / fact(n - k)
}

private fun comb2(n: Long, k: Long): ModInt {
    var ans = ModInt(1)
    for (i in 0 until k) {
        ans = ans * ModInt(n - i) / ModInt(k - i)
    }
    return ans
}


import java.io.BufferedReader
import java.io.InputStreamReader
import java.lang.Math.*
import java.util.*

val scanner = Scanner(System.`in`)
val fastReader = BufferedReader(InputStreamReader(System.`in`))
val output = StringBuilder()
val INF = Long.MAX_VALUE
val mod = 998244353L
val N = 200005

val fact = LongArray(N)
fun fillFact() {
    fact[0] = 1
    for (i in 1 until N) {
        fact[i] = (fact[i - 1] * i) % mod
    }
}

fun mult(x: Long, y: Long) = (x * y) % mod

fun binPow(x: Long, y: Long): Long {
    if (y == 1L) return x
    return if (y and 1 == 0L) {
        val temp = binPow(x, y / 2)
        mult(temp, temp)
    } else mult(binPow(x, y - 1), x)
}

fun inv(x: Long) = binPow(x, mod - 2)

fun divide(x: Long, y: Long) = mult(x, inv(y))
fun readInt() = fastReader.readLine()!!.toInt()
fun readInts() = fastReader.readLine()!!.split(" ").map { it.toInt() }
fun readLong() = fastReader.readLine()!!.toLong()
fun readLongs() = fastReader.readLine()!!.split(" ").map { it.toLong() }
fun readDouble() = fastReader.readLine()!!.toDouble()
fun readDoubles() = fastReader.readLine()!!.split(" ").map { it.toDouble() }

fun main() {
    fillFact()
    val n = scanner.nextInt()
    val m = scanner.nextInt()
    println(
        if (n == 2) 0 else mult(
            divide(fact[m], mult(fact[n - 1], fact[m - n + 1])),
            mult(n - 2L, binPow(2, n - 3L))
        )
    )
}


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

class ProblemIO(val rd: BufferedReader, val wr: PrintWriter) {
    var tok = StringTokenizer("")

    companion object {
        fun console() = ProblemIO(BufferedReader(InputStreamReader(System.`in`)), PrintWriter(System.out))
        fun files(inputFilename: String, outputFilename: String) =
                ProblemIO(BufferedReader(FileReader(File(inputFilename))), PrintWriter(File(outputFilename)))
    }

    fun readToken(): String {
        while (!tok.hasMoreTokens()) {
            tok = StringTokenizer(rd.readLine())
        }
        return tok.nextToken()
    }

    fun readInt(): Int = readToken().toInt()
    fun <T> print(v: T) = wr.print(v)
    fun <T> println(v: T) = wr.println(v)
    fun close() {
        rd.close()
        wr.close()
    }
}

fun solve() {
    val io = ProblemIO.console()
    val a = IntArray(5, { io.readInt() })
    val s = a.sum()
    val res = if (s % a.size == 0) s / a.size else -1
    io.println(res)
    io.close()
}

fun main(args: Array<String>) {
    Thread({ solve() }).start()
}


fun main() {
    val r = System.`in`.bufferedReader()
    val s = StringBuilder()
    val l = r.readLine()!!.split(" ").map { it.toInt() }
    println(if (l.sum()%5==0) l.sum()/5 else -1)
}


import kotlin.math.absoluteValue

fun main(args: Array<String>) {
    val m = readLine()!!.split(' ').map { it.toInt() }.sum()
    if (m.rem(5) == 0)
        println(m / 5)
    else
        println(-1)
}


fun main() {
    val a = readLine()!!.split(" ").map { it.toInt() }.sum()
    print(if (a % 5 == 0) a.div(5) else -1)
}


fun main(args : Array<String>) {
    val bets_nullable_str = readLine()
    if (bets_nullable_str == null) {
        // Do nothing ...
    } else {
        val bets_str = bets_nullable_str
        val bets = bets_str.split(' ').map(String::toInt)
        val sum_bets = bets.sum()
        if ((sum_bets % 5) == 0) {
            val result = sum_bets / 5
            println("${result}")
        } else {
            println("-1")
        }
    }
}


fun main(args: Array<String>) {
    println(readLine()!!.split(' ').map { it.toInt() }.let { if (it.sum() % 5 == 0) it.sum()/5 else -1 })
}


fun main(args: Array<String>) {
    val sum = readLine()!!.split(' ').map { it.toInt() }.reduce { total, next -> total + next }
    println(if (sum % 5 == 0) sum / 5 else "-1")
}


import java.io.BufferedReader
import java.io.InputStreamReader
import java.util.*
import java.util.Collections.min
import kotlin.math.min

fun main() {
    val r = FastReader()
    val n = r.nextInt()
    print(solve(n))

}

fun isp(m:Int): Int {
    var i : Int= 2
    while(i * i <= m){
        if(m % i == 0){
            return (m / i)
        }
        i ++
    }
    return 1
}

fun solve(n:Int):Int{
    var k = isp(n)
    if(k < 3) return k
    var m = n-1
    while(isp(m) != 1){
        m --
    }
    //println(m)
    return 1 +solve( n - m)

}
@Suppress("MemberVisibilityCanBePrivate")
internal class FastReader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    private var tokenizer: StringTokenizer? = null

    operator fun next(): String {
        var t = tokenizer
        while (t == null || !t.hasMoreElements())
            t = StringTokenizer(br.readLine())
        tokenizer = t
        return t.nextToken()
    }

    fun nextInt():Int= next().toInt()

    fun nextLong(): Long = next().toLong()

    fun nextDouble(): Double = next().toDouble()

    fun nextLine(): String = br.readLine()

    fun nextIntArr(n: Int): IntArray = IntArray(n) { nextInt() }

    fun nextDoubleArr(n: Int): DoubleArray = DoubleArray(n) { nextDouble() }

    fun nextLongArr(n: Int): LongArray = LongArray(n) { nextLong() }

    fun nextIntArr2(n: Int, m: Int): Array<IntArray> = Array(n) { IntArray(m) { nextInt() } }

    fun nextLongArr2(n: Int, m: Int): Array<LongArray> = Array(n) { LongArray(m) { nextLong() } }
}


import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min

val MOD = 1_000_000_007

class Solver(stream: InputStream, private val out: java.io.PrintWriter) {
  fun solve() {
    val A = na(3).map{it.toLong()}
    val S = A.sum()
    val remain = min(
      max(0, A[0] - 2 * (A[1] + A[2]))
    , min(
        max(0, A[1] - 2 * (A[0] + A[2]))
      , max(0, A[2] - 2 * (A[0] + A[1]))
      )
    )
    out.println((S - remain) / 3)
  }

  private val isDebug = try {
    // なんか本番でエラーでる
    System.getenv("MY_DEBUG") != null
  } catch (t: Throwable) {
    false
  }

  private var tokenizer: StringTokenizer? = null
  private val reader = BufferedReader(InputStreamReader(stream), 32768)
  private fun next(): String {
    while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
      tokenizer = StringTokenizer(reader.readLine())
    }
    return tokenizer!!.nextToken()
  }

  private fun ni() = next().toInt()
  private fun nl() = next().toLong()
  private fun ns() = next()
  private fun na(n: Int, offset: Int = 0): IntArray {
    return map(n, offset) { ni() }
  }

  private inline fun map(n: Int, offset: Int = 0, f: (Int) -> Int): IntArray {
    val res = IntArray(n)
    for (i in 0 until n) {
      res[i] = f(i + offset)
    }
    return res
  }

  private inline fun debug(msg: () -> String) {
    if (isDebug) System.err.println(msg())
  }

  private fun debug(a: LongArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: IntArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: BooleanArray) {
    debug { a.map { if (it) 1 else 0 }.joinToString("") }
  }

  private fun debugDim(A: Array<LongArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }

  /**
   * 勝手にimport消されるのを防ぎたい
   */
  private fun hoge() {
    min(1, 2)
    max(1, 2)
    abs(-10)
  }
}

fun <A, B> pair(a: A, b: B) = RPair(a, b)
data class RPair<A, B>(val _1: A, val _2: B)

fun main() {
  val out = java.io.PrintWriter(System.out)
  Solver(System.`in`, out).solve()
  out.flush()
}


fun main() {
    val r = System.`in`.bufferedReader()
    val s = StringBuilder()
    //val n = r.readLine()!!.toInt()
    //val (n, time) = r.readLine()!!.split(" ").map { it.toInt() }
    //val v = r.readLine()!!.split(" ").map { it.toInt() }
    val s1 = r.readLine()!!.split("").filter { it.length>0 }.map { it.toInt() }.map { if (it>=5) 9-it else it }
    println(s1.joinToString(""))
}


fun main() {
    readLine()!!.withIndex().forEach { char ->
        val min = 9 - (char.value - '0')
        if (min < (char.value - '0') && (min != 0 || char.index > 0)) {
            print(min)
        } else if (min == 0) {
            print(1)
        } else {
            print(char.value)
        }
    }
    println()
}


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

fun main() {
    val br = BufferedReader(InputStreamReader(System.`in`))
    var x = br.readLine().toLong()
    val ans = ArrayList<Long>()
    while (x > 0) {
        val digit = x % 10
        if (digit >= 5) {
            ans.add(9 - digit)
        } else {
            ans.add(digit)
        }
        x /= 10
    }
    println(ans.joinToString(""))
}


fun main() {
    val x = readLine()!!.toCharArray()
    var first = true
    print(x.asSequence().map {
        if (!first && it > '4') {
            first = false
            '9' - it
        } else {
            first = false
            it
        }
    }.joinToString(""))
}


import java.util.*

fun main(args: Array<String>){
    //val ( n, m ) = readLine()!!.split(' ').map(String::toInt)
    var s = readLine()!!
    print( if( s[0] >= '5' && s[0] != '9' ) '9' - s[0] else s[0] )
    s = s.removeRange(0, 0)
    for( i in s ){
        print( if ( i >= '5' ) '9' - i else i )
    }
}


fun readInts(): List<Int> = readLine()!!.split(" ").map{ it.toInt() }

fun main(){
    var (m, s) = readInts()
    val digits = (9 downTo 0).toMutableList()
    val result = mutableListOf<Int>()
    var index = 0
    while(m != 0 || s != 0){
        if(s - digits[index] >= 0){
            result.add(digits[index])
            s -= digits[index]
            m --
        }
        if(s < digits[index]){
            index ++
        }
    }
    if(result.isEmpty() || result.reduce{acc: Int, i: Int -> acc+i } == 0){
        println("-1 -1")
        return
    }
    val resultStringHigh = result.joinToString(separator = "")
    val resultStringLow = if(resultStringHigh[resultStringHigh.lastIndex]!='0'){
        resultStringHigh.reversed()
    }
    else{
        val aux = StringBuilder()
        aux.append(resultStringHigh.reversed())
        aux[0] = aux.first { it != '0' }.also { aux[aux.indexOfFirst { it != '0' }]= aux[0] }
        aux.toString()
    }
    println("$resultStringLow $resultStringHigh")
}


import kotlin.math.max

fun readInts(): List<Int> = readLine()!!.split(" ").map{ it.toInt() }
fun findMin(m: Int, s: Int): String{
    val digits = (m-2 downTo 0).toMutableList()
    if (s > m * 9) return "-1"
    val result = mutableListOf(max(1, s - 9*(m-1)))
    var auxS = s - result[0]
    var auxM = m - 1
    var index = 0
    while(auxM != 0 || auxS != 0){
        val value = max(0, auxS - 9 * digits[index])
        result.add(value)
        index ++
        auxS -= value
        auxM --
        if(auxM == 0) break
    }
    if(result.isEmpty() || auxM + auxS != 0){
        return "-1"
    }
    return result.joinToString(separator = "")
}
fun findMax(m: Int, s: Int): String{
    val digits = (9 downTo 0).toMutableList()
    var auxS = s
    var auxM = m
    val result = mutableListOf<Int>()
    var index = 0
    if( m == 1 && s <= 9)
    {
        return "$s"
    }
    while(auxM != 0 || auxS != 0){
        if(auxS - digits[index] >= 0){
            result.add(digits[index])
            auxS -= digits[index]
            auxM --
        }
        if(auxS < digits[index]){
            index ++
        }
        if(auxM == 0) break
    }
    if(result.isEmpty() || result.reduce{acc: Int, i: Int -> acc+i } == 0 || auxM + auxS != 0){
        return "-1"
    }
    return result.joinToString(separator = "")
}

fun main(){
    val (m, s) = readInts()

    println("${findMin(m, s)} ${findMax(m,s)}")
}


import java.util.*

fun findMin(n: Int, sum: Int): String {

	if ( sum == 0 ) return if ( n == 1 ) "0" else "-1"
	if ( sum > 9*n ) return "-1"

	val firstDigit = Math.max(1, sum - 9*(n-1))
	var left = sum - firstDigit

	val r = StringBuilder()
	r.append ( firstDigit )
	for ( i in n-2 downTo 0 ) {
		val d = Math.max ( 0, left - 9*i )
		r.append(d)
		left -= d
	}

	return r.toString()
}

fun findMax(n: Int, sum: Int): String {

	if ( sum == 0 ) return if ( n == 1 ) "0" else "-1"
	if ( sum > 9*n ) return "-1"

	val firstDigit = Math.min(9, sum)
	var left = sum - firstDigit

	val r = StringBuilder()
	r.append(firstDigit)
	for ( i in n-2 downTo 0 ) {
		val d = Math.min( 9, left )
		r.append(d)
		left -= d
	}

	return r.toString()
}

fun main(args : Array<String>) {
	val scan = Scanner (System.`in`)
	val n = scan.nextInt()
	val sum = scan.nextInt()

	val minSum = if ( n == 1 ) 0 else n
	val maxSum = n*9

	if ( sum < minSum || sum > maxSum ) {
		println("-1 -1")
		return
	}

	println ( findMin(n,sum) + " " + findMax(n, sum) )
}


import java.util.*

fun main(args: Array<String>){
    val s = Scanner(System.`in`)
    val m = s.nextInt()
    val n = s.nextInt()-2
    val k = s.nextInt()-1
    val mn = 2*m+2*n
    var c = 0
    for (i in 0..k) c+=mn-(4*(i))
    print(c)
}


fun main(args: Array<String>) {

	val Xarr = readLine()!!.split(' ').map { it.toInt() }
var answer = 0
	for(i in 1 until Xarr[2]+1){
		answer += ((Xarr[0]/i-1)+(Xarr[1]/i-1))*2
	}
	if(Xarr[2]>1) answer += Xarr[2]
	println(answer)
}


import java.util.Scanner
fun main(args : Array<String>){
    val reader = Scanner(System.`in`)
    var n: Int = reader.nextInt()
    var k: Int = reader.nextInt()
    var list1: MutableList<Int> = mutableListOf()
    var b = 0
    for(i in 2..n){
        if(checkPrime(i) == 1) {
            for (j in 2..i) {
                if (checkPrime(j) == 1) {
                    list1.add(j)
                }
            }
            for (x in 1..list1.size - 1) {
                if (list1[x - 1] + list1[x] + 1 == i) {
                    b++
                }
            }
            list1.clear()
        }
    }

    if(b>=k){ println("YES")}
    else { println("NO")}

}

 fun Prime(n: Int):Int{
    var a = 0
    for(i in 2..n/2) {
        if (n % i==0) {
            a++
        }
    }
    if(a==0) return 1
    else return 0
 }


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

class InputReader(val stream: InputStream) {
    val buf = ByteArray(1024)
    var curChar: Int = 0
    var numChars: Int = 0

    fun read(): Char {
        if (numChars == -1)
            throw InputMismatchException()
        if (curChar >= numChars) {
            curChar = 0
            try {
                numChars = stream.read(buf)
            } catch (e: IOException) {
                throw InputMismatchException()
            }
            if (numChars <= 0)
                return '\uFFFF'
        }
        return buf[curChar++].toChar()
    }

    fun nextInt(): Int {
        var c = read()
        while (isSpaceChar(c))
            c = read()
        var sgn = 1
        if (c == '-') {
            sgn = -1
            c = read()
        }
        var res = 0
        do {
            if (c < '0' || c > '9')
                throw InputMismatchException()
            res *= 10
            res += c.toInt() and 15
            c = read()
        } while (!isSpaceChar(c))
        return res * sgn
    }

    fun nextLong(): Long {
        var c = read()
        while (isSpaceChar(c))
            c = read()
        var sgn = 1
        if (c == '-') {
            sgn = -1
            c = read()
        }
        var res = 0L
        do {
            if (c < '0' || c > '9')
                throw InputMismatchException()
            res *= 10
            res += c.toInt() and 15
            c = read()
        } while (!isSpaceChar(c))
        return res * sgn
    }

    fun nextString(): String {
        var c = read()
        while (isSpaceChar(c))
            c = read()
        val res = StringBuilder()
        do {
            res.append(c)
            c = read()
        } while (!isSpaceChar(c))
        return res.toString()
    }

    fun isSpaceChar(c: Char): Boolean {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == '\uFFFF'
    }
}

class OutputWriter(val stream: OutputStream) {
    val buf = ByteArray(65536)
    var curPos: Int = 0

    fun write(c: Char) {
        if (buf.size - curPos < 1) flush()
        buf[curPos++] = c.toByte()
    }

    fun write(s: String) {
        if (buf.size - curPos < s.length) flush()
        var idx = 0
        if (s.length > buf.size) {
            var remaining = s.length
            while (remaining > buf.size) {
                while (curPos < buf.size) buf[curPos++] = s[idx++].toByte()
                flush()
                remaining -= buf.size
            }
        }
        while (idx < s.length) buf[curPos++] = s[idx++].toByte()
    }

    fun flush() {
        stream.write(buf, 0, curPos)
        curPos = 0
    }
}

fun isprime(n: Int): Boolean {
    if (n == 2 || n == 3)
        return true
    if (n % 2 == 0 || n % 3 == 0 || n == 1)
        return false
    var i = 5
    var w = 2
    while (i * i <= n) {
        if (n % i == 0)
            return false
        i += w
        w = 6 - w
    }
    return true
}

fun main(args: Array<String>) {
    if (args.isNotEmpty()) System.setIn(FileInputStream(args[0]))
    val ir = InputReader(System.`in`)
    val ow = OutputWriter(System.out)

    var answer = 0
    val n = ir.nextInt()
    val k = ir.nextInt()
    for (i in 2 .. n / 2) {
        if (!isprime(i)) continue
        for (j in i + 1 .. n / 2) {
            if (!isprime(j)) continue
            if (isprime(i + j + 1) && (i + j + 1) <= n) ++answer
            break
        }
    }

    if (answer >= k) ow.write("YES\n")
    else ow.write("NO\n")
    ow.flush()
}


fun main() {
    var (n, k) = readLine()!!.split(' ').map { it.toInt() }
    var prime = Array<Boolean>(n + 1, { true })
    var primenumbers = mutableListOf<Int>()

    var p = 2
    var count = 0
    while (p * p <= n) {
        if (prime[p] == true) {

            for (i in p * 2..n step p) {
                prime[i] = false
            }
        }
        p++
    }

    for (i in 2..n) {
        if (prime[i]) {
            primenumbers.add(i)
        }
    }

    var i = 0
    while (i < primenumbers.size - 1) {
        var flag = false
        for (j in i + 1 until primenumbers.size) {
            if (primenumbers.contains(primenumbers[i] + primenumbers[j] + 1)) {
                count++
                primenumbers.removeAt(i)
                primenumbers.removeAt(j)
                flag = true
                break
            }
        }
        if (!flag) i++

    }
    println(if (count >= k) "YES" else "NO")

}


import java.io.PrintWriter
import java.util.StringTokenizer
import kotlin.math.ceil
import kotlin.math.pow
import kotlin.math.sqrt

//private val INPUT = File("input.txt").inputStream()
//private val OUTPUT = File("output.txt").outputStream()
private val INPUT = System.`in`
private val OUTPUT = System.out

private val bufferedReader = INPUT.bufferedReader()
private val outputWriter = PrintWriter(OUTPUT, false)
private fun readLn() = bufferedReader.readLine()!!

private fun readList() = readLn().split(' ')
private var tokenizer = StringTokenizer("")
private fun read(): String {
    while (tokenizer.hasMoreTokens().not()) tokenizer = StringTokenizer(readLn(), " ")
    return tokenizer.nextToken()
}

private fun readInt() = read().toInt()
private fun readLong() = read().toLong()
private fun readDouble() = read().toDouble()

private fun readIntList() = readList().map { it.toInt() }
private fun readLongList() = readList().map { it.toLong() }
private fun readDoubleList() = readList().map { it.toDouble() }

private fun readIntArray(n: Int = 0) =
    if (n == 0) readList().run { IntArray(size) { get(it).toInt() } } else IntArray(n) { readInt() }

private fun readLongArray(n: Int = 0) =
    if (n == 0) readList().run { LongArray(size) { get(it).toLong() } } else LongArray(n) { readLong() }

private fun readDoubleArray(n: Int = 0) =
    if (n == 0) readList().run { DoubleArray(size) { get(it).toDouble() } } else DoubleArray(n) { readDouble() }

private fun Int.modPositive(other: Int): Int = if (this % other < 0) ((this % other) + other) else (this % other)

private class `CF799-D2-A` {
    fun solveTestCase(): String {
        val n = readInt()
        val t = readInt()
        val k = readInt()
        val d = readInt()

        val countWithoutBuilding = ceil(n.toDouble()/k)
        val countBakeBeforeBuilt = ceil(t.toDouble()/d)

        return when ((countBakeBeforeBuilt+1) >= countWithoutBuilding) {
            true -> "NO"
            false -> "YES"
        }
    }
}

fun main(args: Array<String>) {

    outputWriter.println(
        `CF799-D2-A`()
            .solveTestCase()
    )

    outputWriter.flush()
}


import java.util.Scanner;
import java.util.Arrays;
import java.util.*;
import java.math.*;
import java.io.*;

fun main(args: Array<String>) {
    var s = Scanner(System.`in`)
    var cakes = s.nextInt()
    var oven1 = s.nextInt()
    var nocake = s.nextInt()
    var oven2 = s.nextInt()
    Carrotscake(cakes ,oven1 , nocake,oven2)

}

fun Carrotscake(cakes:Int,oven1:Int,nocake:Int,oven2:Int){
    var timeforoven1 = (cakes/nocake)*oven1
    var timeforoven2 =oven1 +oven2

    if(timeforoven1<=timeforoven2){
        println("NO")
    }else{
      println("YES")
    }

}


import java.util.*

fun main() {
    val input = Scanner(System.`in`)
    val n = input.nextFloat()
    val t = input.nextFloat()
    val k = input.nextFloat()
    val d = input.nextFloat()
    val timeOneOven= ((n.div(k)).times(t)).minus(t)
    if (timeOneOven > d)
        println("YES")
    else
        println("NO")
}


  val input = Scanner(System.`in`)
    val n = input.nextFloat()
    val t = input.nextFloat()
    val k = input.nextFloat()
    val d = input.nextFloat()
    val timeOneOven= (ceil(n.div(k))).times(t).minus(t)
    if (timeOneOven > d)
        println("YES")
    else
        println("NO")


fun main() {
    var (n, t, k, d) = readLine()!!.split(" ").map{ it.toInt() }
    var time_A = n / k * t
    var time_B = 0
    var oven1 = false
    var oven2 = false
    while(true) {
        if(time_B % t == 0){
            oven1 = false
            if(n > 0) {
                n -= k
                oven1 = true
            }
        }
        if(time_B >= d && (time_B - d) % t == 0) {
            oven2 = false
            if(n > 0) {
                n -= k
                oven2 = true
            }
        }
        if(!oven1 && !oven2) break
        time_B++
    }
    if(time_A <= time_B) println("NO")
    else println("YES")
}


import java.util.*
fun main(){
    val s=Scanner(System.`in`)
    var r=s.next()
    var n=r.length
    var x:Int = -1
    var answer:String=""
    for( i in 0..n-1){
        if(r[i]=='p'){
            answer += r[i]
            x=i
            break
        }
        else
            answer += r[i]
    }
    x++
    answer += "://"
    for (i in x..n-1){
       if(r[i]=='r' && r[i+1]=='u'){
           answer+='.'
           answer+="ru"
           x=i+1
           break
       }
        else
           answer+=r[i]
    }

    if(x!=n-1){
        x++
        answer+='/'
        for(i in x..n-1){
            answer+=r[i]
        }
    }
    print(answer)
}


fun main() {
    val s = readLine()!!
    val sb = StringBuilder()
    val startDomain = if (s.first() == 'h') {
        sb.append("http://")
        4
    } else {
        sb.append("ftp://")
        3
    }
    val domainEnd = s.indexOf("ru")
    sb.append(s.substring(startDomain, domainEnd))
    sb.append(".ru")
    if (domainEnd + 2 != s.length) sb.append("/${s.substring(domainEnd + 2)}")
    print(sb.toString())
}


fun main() {
    var p:List<Int> = readLine().split(" ").map {x -> x.toInt()}
    var n = p[0]
    var a = p[1]
    var b = p[2]
    var c = p[3]
    var d = p[4]
    var A = 0
    var B = a - d
    var C = (B + b) - (c)
    var D = (d + C) - (a)
    var mn = listOf(A, B, C, D).min()!!.toInt()
    if(mn < 1) {
        mn -= 1
        A -= mn
        B -= mn
        C -= mn
        D -= mn
    }
    var mx = listOf(A, B, C, D).max()!!.toInt()
    var res = (n - mx + 1)*(n)
    println(res)
}


fun main() {
    var p:List<Int> = readLine()!!.split(" ").map {x -> x.toInt()}
    var n = p[0]
    var a = p[1]
    var b = p[2]
    var c = p[3]
    var d = p[4]
    var A = 0
    var B = a - d
    var C = (B + b) - (c)
    var D = (d + C) - (a)
    var mn = listOf(A, B, C, D).min()!!.toInt()
    if(mn < 1) {
        mn -= 1
        A -= mn
        B -= mn
        C -= mn
        D -= mn
    }
    var mx = listOf(A, B, C, D).max()!!.toInt()
    var res = (n - mx + 1)*(n)
    if(res <= 0) {
        res = 0
    }
    println(res)
}


fun main() {
    val r = System.`in`.bufferedReader()
    val s1 = StringBuilder()
    val n = r.readLine()!!.toInt()
    val v = r.readLine()!!.split(" ").map { it.toInt() }.toSet().toList().sorted()
    when(v.size){
        1 -> println(0)
        2 -> println(if ((v[1]-v[0])%2==0) (v[1]-v[0])/2 else (v[1]-v[0]))
        3 -> println(if (v[2]-v[1]==v[1]-v[0]) v[2]-v[1] else -1)
    }
}


import java.util.*

fun main(args: Array<String>) {

    val sc = Scanner(System.`in`)

    val m = HashSet<Int>()
    val n = sc.nextInt()
    for (i in 1..n) {
        m.add(sc.nextInt())
    }
    val values = m.toList().sorted()
    when (values.size) {
        1 -> println(0)
        2 -> println((values[1] - values[0]) / 2)
        3 -> {
            if (values[2] - values[1] == values[1] - values[0]) {
                println(values[2] - values[1])
            } else {
                println(-1)
            }
        }
        else -> println(-1)
    }
}


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

fun main(args : Array<String>) {
    val In = BufferedReader(InputStreamReader(System.`in`))
    In.readLine()
    val ints = In.readLine()!!.split(" ").map { x -> x.toInt() }
    val dif = ints.toSortedSet().toList()
    System.out.println(dif)
    val abs = mutableListOf<Int>()
    var min = 100
    for(x in dif) {
        loop@ for(y in dif) {
            if(x != y) {
                if(Math.abs(y-x) % 2 == 0)
                    abs.add(Math.abs(y-x)/2)
            }
        }

    }
    val res = abs.filter { x -> x != abs.first() }
    if(res.isEmpty())
        System.out.println(abs.first())
    else
        System.out.println(-1)
}


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

fun main(args : Array<String>) {
    val In = BufferedReader(InputStreamReader(System.`in`))
    In.readLine()
    val ints = In.readLine()!!.split(" ").map { x -> x.toInt() }
    val dif = ints.toSortedSet().toList()
    val abs = mutableListOf<Int>()
    var min = 100
    for(x in dif) {
        loop@ for(y in dif) {
            if(x != y) {
                if(Math.abs(y-x) % 2 == 0)
                    abs.add(Math.abs(y-x)/2)
            }
        }

    }
    val res = abs.filter { x -> x != abs.first() }
    if(res.isEmpty())
        System.out.println(abs.first())
    else
        System.out.println(-1)
}


import java.util.Scanner

//ndiff <= 3
//1 win

//2 one shift

//3 middle shift, without mod
fun main() {
  val scan = Scanner(System.`in`)
  scan.nextLine()
  val intArray = scan.nextLine()
      .split(" ")
      .map {
        it.trim()
            .toInt()
      }
      .toIntArray()

  val set = intArray.toSet()

  val size = set.size
  when (size) {
    0 -> println(0)
    1 -> println(0)
    2 -> println(set.max()!! - set.min()!!)
    3 -> {
      val max = set.max()!!
      val min = set.min()!!
      val diff = max - min
      if ((diff) % 2 == 0) {
        val result = set.find { it != max && it != min }!!
        if (result == (diff / 2) + min) {
          println(diff / 2)
          return
        }
      }
      println("-1")
    }
    else -> println("-1")
  }
}


import  java.util.Scanner

fun main(args: Array<String>) {
    val inp = Scanner(System.`in`)
    val Len: Int = inp.nextInt()
    var NumsArr = HashSet<Int>()
    for(i in 0 until Len) {
       val valueOFINT = inp.nextInt()
        NumsArr.add(valueOFINT)
    }

    NumsArr.sortedWith(compareBy {it})

    if(NumsArr.size==1) {
        println(0)
    }else if(NumsArr.size == 2) {
        var getMid = NumsArr.last()-NumsArr.first()
        getMid = if(getMid< 0) getMid*(-1) else getMid
        if(getMid %2 == 0) {
            println(getMid/2)
        }else {
            println(getMid)
        }
    } else if(NumsArr.size > 3) {
        println(-1)
    } else if(NumsArr.size == 3) {
        var middle = NumsArr.last() - NumsArr.first()
        if(middle%2 != 0) {
            println(-1)
        }else {
            middle /= 2
            if(NumsArr.contains(NumsArr.first() + middle)) {
                println(middle)
            } else {
                println(-1)
            }
        }

    }
}


import java.util.*

fun main(args: Array<String>): Unit = with(Scanner(System.`in`)) {
    val array: Array<Int> = arrayOf(nextInt(), nextInt(), nextInt())
    array.sort()
    when {
        (array[0] == 1).toInt() + (array[1] == 1).toInt() + (array[2] == 1).toInt() == 1 -> println("YES")
        (array[0] == 2).toInt() + (array[1] == 2).toInt() + (array[2] == 2).toInt() >= 2 -> println("YES")
        (array[0] == 3).toInt() + (array[1] == 3).toInt() + (array[2] == 3).toInt() == 3 -> println("YES")
        array[0] ==  2 && array[1] == 4 && array[2] == 4 -> println("YES")
        else -> println("NO")

    }
}

fun Boolean.toInt() = if (this) 1 else 0


import java.io.BufferedReader
import java.io.IOException
import java.io.InputStreamReader
import java.util.*

fun main(args: Array<String>) {
    val reader = Reader()
    val firstString = reader.next()
    val secondString = reader.next()
    var count = 0
    for (i in 0 until firstString.length) {
        val firstStringChar = firstString.elementAt(i).toLowerCase()
        val secondStringChar = secondString.elementAt(i).toLowerCase()
        count += firstStringChar - secondStringChar
    }
    println(when {
        count > 0 -> 1
        count < 0 -> -1
        else -> 0
    })
}

internal class Reader {
    var br: BufferedReader
    var st: StringTokenizer? = null

    init {
        br = BufferedReader(InputStreamReader(System.`in`))
    }

    operator fun next(): String {
        while (st == null || !st!!.hasMoreElements()) {
            try {
                st = StringTokenizer(br.readLine())
            } catch (e: IOException) {
                e.printStackTrace()
            }

        }
        return st!!.nextToken()
    }

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

    fun nextLong(): Long {
        return java.lang.Long.parseLong(next())
    }

    fun nextDouble(): Double {
        return java.lang.Double.parseDouble(next())
    }

    fun nextLine(): String {
        var str = ""
        try {
            str = br.readLine()
        } catch (e: IOException) {
            e.printStackTrace()
        }

        return str
    }
}


import java.io.BufferedReader
import java.io.IOException
import java.io.InputStreamReader
import java.util.*

fun main(args: Array<String>) {
    val reader = Reader()
    val firstString = reader.next()
    val secondString = reader.next()
    for (i in 0..firstString.length) {
        val firstStringChar = firstString.elementAt(i).toLowerCase()
        val secondStringChar = secondString.elementAt(i).toLowerCase()
        if (firstStringChar - secondStringChar > 0) {
            println(1)
            return
        }
        if (firstStringChar - secondStringChar < 0) {
            println(-1)
            return
        }
    }
    println(0)
}

internal class Reader {
    var br: BufferedReader
    var st: StringTokenizer? = null

    init {
        br = BufferedReader(InputStreamReader(System.`in`))
    }

    operator fun next(): String {
        while (st == null || !st!!.hasMoreElements()) {
            try {
                st = StringTokenizer(br.readLine())
            } catch (e: IOException) {
                e.printStackTrace()
            }

        }
        return st!!.nextToken()
    }

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

    fun nextLong(): Long {
        return java.lang.Long.parseLong(next())
    }

    fun nextDouble(): Double {
        return java.lang.Double.parseDouble(next())
    }

    fun nextLine(): String {
        var str = ""
        try {
            str = br.readLine()
        } catch (e: IOException) {
            e.printStackTrace()
        }

        return str
    }
}


fun main() {

    val firstString = readLine()?.toLowerCase()
    val secondString = readLine()?.toLowerCase()
    var firstCount =0
    var secondCount=0
    for(i in firstString?.indices!!) {
        firstCount += firstString[i].toInt()
        secondCount += secondString?.get(i)?.toInt()!!
    }

    when {
        firstCount > secondCount -> print("1")
        firstCount < secondCount -> print("-1")
        firstCount == secondCount -> print("0")
    }
}


import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    var s1 = sc.next().toLowerCase()
    var s2 = sc.next().toLowerCase()
    if (s1.equals(s2)) {
        print(0)
        return
    }
    var n1 = 0;
    var n2 = 0;
    for (i in 0..s1.length - 1) {
        n1 += s1[i].toInt()
        n2 += s2[i].toInt()
    }
    if (n1 > n2) print(1)
    else print(-1)
}


fun main() {
var s:String=readLine()!!.toString()
var se:String=readLine()!!.toString()

    var f =true
    s=s.substring(0,s.length).toLowerCase()
    se=se.substring(0,se.length).toLowerCase()

if(s==se)print(0)

else {
    for(i in 0..s.length-1)
    {
        if(s[i].toLowerCase()<se[i].toLowerCase())
            f=false
    }
print(if(f==false) "-1" else "1")
}
}


//package c913

import java.util.*

fun main(a:Array<String>){
    val input = Scanner(System.`in`)

    val n=input.nextInt()
    val l=input.nextLong()
    val c=Array(n){ input.nextInt() }

    val ans = Array(n) {if (it==0) l else 0L}
    (1 until n).forEach {
        var remVal = 0L
        var remNum = 0L
        (0 until it).forEach { i ->
            if (c[it] <= c[i]) {
                ans[it] = ans[i] + 1 shr it - i
                ans[i] = 0
            } else if (c[it] <= c[i] shl it - i) {
                ans[it] += ans[i] shr it - i
                ans[i] = ans[i] % (1L shl it - i)

                remNum += ans[i] shl i
                remVal += ans[i] * c[i]
            }
        }
        if (remVal > c[it]) {
            (0 until it).filter { i -> c[it] <= c[i] shl it - i && c[it] > c[i] }.forEach {
                ans[it] = 0
            }
            ans[it]+=1L
        }
    }
    println(ans.mapIndexed { index, ac -> ac*c[index] }.sum())
}


//package c913

import java.util.*
import kotlin.math.max

fun main(a:Array<String>){
    val input = Scanner(System.`in`)

    val n=input.nextInt()
    val l=input.nextInt()
    val c=Array(n){ input.nextInt() }

    println(find(c,l))
}

fun find (c:Array<Int>,W:Int):Long {
    if (W == 0) return 0
    val amount = Array(c.size){ max(1,W shr it) }
    val rem = amount.mapIndexed { index, m -> max(0,W - (m shl index)) }
    val ans = rem.mapIndexed { index,remain -> find(c,remain) + c[index]*amount[index].toLong() }
    return ans.min()!!
}


//package cf913.c

import java.util.*
import kotlin.math.max

fun main(a:Array<String>){
    val input = Scanner(System.`in`)

    val n=input.nextInt()
    val l=input.nextInt()
    val c=Array(n){ input.nextInt() }

    val ans = hashMapOf<Int,Long>()
    println(find(c,l,ans))
}

fun find (c:Array<Int>,W:Int,map:MutableMap<Int,Long>):Long =
    map[W] ?: Array(c.size) {
        val single = 1 shl it //单位价值
        c[it] * max(1, W / single).toLong() +
                if (single >= W) 0
                else find(c, W % single, map)
    }.min()!!
    .also { map.put(W, it) }


import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val m = sc.nextInt()
    val a = sc.nextInt()
    val b = sc.nextInt()

    val o = b*(n%m)
    val u = a*(m-n%m)
    println(if (o < u) o else u)
}