Yura is a mathematician, and his cognition of the world is so absolute as if he have been solving formal problems a hundred of trillions of billions of years. This problem is just that!Consider all non-negative integers from the interval $$$[0, 10^{n})$$$. For convenience we complement all numbers with leading zeros in such way that each number from the given interval consists of exactly $$$n$$$ decimal digits.You are given a set of pairs $$$(u_i, v_i)$$$, where $$$u_i$$$ and $$$v_i$$$ are distinct decimal digits from $$$0$$$ to $$$9$$$.Consider a number $$$x$$$ consisting of $$$n$$$ digits. We will enumerate all digits from left to right and denote them as $$$d_1, d_2, \ldots, d_n$$$. In one operation you can swap digits $$$d_i$$$ and $$$d_{i + 1}$$$ if and only if there is a pair $$$(u_j, v_j)$$$ in the set such that at least one of the following conditions is satisfied:  $$$d_i = u_j$$$ and $$$d_{i + 1} = v_j$$$,  $$$d_i = v_j$$$ and $$$d_{i + 1} = u_j$$$. We will call the numbers $$$x$$$ and $$$y$$$, consisting of $$$n$$$ digits, equivalent if the number $$$x$$$ can be transformed into the number $$$y$$$ using some number of operations described above. In particular, every number is considered equivalent to itself.You are given an integer $$$n$$$ and a set of $$$m$$$ pairs of digits $$$(u_i, v_i)$$$. You have to find the maximum integer $$$k$$$ such that there exists a set of integers $$$x_1, x_2, \ldots, x_k$$$ ($$$0 \le x_i < 10^{n}$$$) such that for each $$$1 \le i < j \le k$$$ the number $$$x_i$$$ is not equivalent to the number $$$x_j$$$.

The first line contains an integer $$$n$$$ ($$$1 \le n \le 50\,000$$$) — the number of digits in considered numbers. The second line contains an integer $$$m$$$ ($$$0 \le m \le 45$$$) — the number of pairs of digits in the set. Each of the following $$$m$$$ lines contains two digits $$$u_i$$$ and $$$v_i$$$, separated with a space ($$$0 \le u_i < v_i \le 9$$$). It's guaranteed that all described pairs are pairwise distinct.

Print one integer — the maximum value $$$k$$$ such that there exists a set of integers $$$x_1, x_2, \ldots, x_k$$$ ($$$0 \le x_i < 10^{n}$$$) such that for each $$$1 \le i < j \le k$$$ the number $$$x_i$$$ is not equivalent to the number $$$x_j$$$. As the answer can be big enough, print the number $$$k$$$ modulo $$$998\,244\,353$$$.

NoteIn the first example we can construct a set that contains all integers from $$$0$$$ to $$$9$$$. It's easy to see that there are no two equivalent numbers in the set.In the second example there exists a unique pair of equivalent numbers: $$$01$$$ and $$$10$$$. We can construct a set that contains all integers from $$$0$$$ to $$$99$$$ despite number $$$1$$$.

// $time$
import java.io.BufferedInputStream
import java.io.File
import java.io.PrintWriter
import kotlin.system.measureTimeMillis

// 1. Modded
const val p = 998244353L
const val pI = p.toInt()
fun Int.adjust():Int{ if(this >= pI){ return this  - pI }else if (this < 0){ return this + pI };return this }
fun Int.snap():Int{ if(this >= pI){return this - pI} else return this}
infix fun Int.modM(b:Int):Int{ return ((this.toLong() * b) % pI).toInt() }
infix fun Int.modPlus(b:Int):Int{ val ans = this + b;return if(ans >= pI) ans - pI else ans }
fun intPow(x:Int,e:Int,m:Int):Int{
    var X = x ; var E =e ; var Y = 1
    while(E > 0){
        if(E and 1 == 0){
            X = ((1L * X * X) % m).toInt()
            E = E shr 1
        }else{
            Y = ((1L * X * Y) % m).toInt()
            E -= 1
        }
    }
    return Y
}
// 2. DP initial values
const val plarge = 1_000_000_727
const val nlarge = -plarge
const val phuge = 2_727_000_000_000_000_000L
const val nhuge = -phuge
// 3. conveniecen conversions
val Boolean.chi:Int get() = if(this) 1 else 0 //characteristic function
val Char.code :Int get() = this.toInt() -  'a'.toInt()
//3. hard to write stuff
fun IntArray.put(i:Int,v:Int){ this[i] = (this[i] + v).adjust() }
val mint:MutableList<Int> get() = mutableListOf<Int>()
val mong:MutableList<Long> get() = mutableListOf<Long>()
//4. more outputs
fun List<Char>.conca():String = this.joinToString("")
val CharArray.conca :String get() = this.joinToString("")
val IntArray.conca :String get() = this.joinToString(" ")
@JvmName("concaInt")
fun List<Int>.conca():String = this.joinToString(" ")
val LongArray.conca:String get() = this.joinToString(" ")
@JvmName("concaLong")
fun List<Long>.conca():String = this.joinToString(" ")
//5. Pair of ints
const val longmask = (1L shl 32) - 1
fun makepair(a:Int, b:Int):Long = (a.toLong() shl 32) xor (longmask and b.toLong()) // remember positev sonly
val Long.first get() = (this ushr 32).toInt()
val Long.second get() = this.toInt()
//6. strings
val String.size get() = this.length
const val randCount = 100
//7. bits
fun Int.has(i:Int):Boolean = (this and (1 shl i) != 0)
//8 TIME
inline fun TIME(f:()->Unit){
    val t = measureTimeMillis(){
        f()
    }
    println("$t ms")
}
object Reader{
    private const val BS = 1 shl 16
    private const val NC = 0.toChar()
    private val buf = ByteArray(BS)
    private var bId = 0
    private var size = 0
    private var c = NC

    var warningActive = true
    var fakein = StringBuilder()

    private var IN: BufferedInputStream = BufferedInputStream(System.`in`, BS)
    val OUT: PrintWriter = PrintWriter(System.out)

    private val char: Char
        get() {
            while (bId == size) {
                size = IN.read(buf) // no need for checked exceptions
                if (size == -1) return NC
                bId = 0
            }
            return buf[bId++].toChar()
        }

    fun nextInt(): Int {
        var neg = false
        if (c == NC) c = char
        while (c < '0' || c > '9') {
            if (c == '-') neg = true
            c = char
        }
        var res = 0
        while (c in '0'..'9') {
            res = (res shl 3) + (res shl 1) + (c - '0')
            c = char
        }
        return if (neg) -res else res
    }
    fun nextLong(): Long {
        var neg = false
        if (c == NC) c = char
        while (c < '0' || c > '9') {
            if (c == '-') neg = true
            c = char
        }
        var res = 0L
        while (c in '0'..'9') {
            res = (res shl 3) + (res shl 1) + (c - '0')
            c = char
        }
        return if (neg) -res else res
    }
    fun nextString():String{
        val ret = StringBuilder()
        while (true){
            c = char
            if(!isWhitespace(c)){ break}
        }
        ret.append(c)
        while (true){
            c = char
            if(isWhitespace(c)){ break}
            ret.append(c)
        }
        return ret.toString()
    }
    fun isWhitespace(c:Char):Boolean{
        return c == ' ' || c == '\n' || c == '\r' || c == '\t'
    }
    fun rerouteInput(){
        if(warningActive){
            put("Custom test enabled")
            println("Custom test enabled")
            warningActive = false
        }
        val S = fakein.toString()
        println("New Case ")
        println(S.take(80))
        println("...")
        fakein.clear()
        IN = BufferedInputStream(S.byteInputStream(),BS)
    }
    fun takeFile(name:String){
        IN = BufferedInputStream(File(name).inputStream(),BS)
    }
}
fun put(aa:Any){ Reader.OUT.println(aa)}
fun done(){ Reader.OUT.close() }
fun share(aa:Any){
    if(aa is IntArray){Reader.fakein.append(aa.joinToString(" "))}
    else if(aa is LongArray){Reader.fakein.append(aa.joinToString(" "))}
    else if(aa is List<*>){Reader.fakein.append(aa.toString())}
    else{Reader.fakein.append(aa.toString())}
    Reader.fakein.append("\n")
}

val getintfast:Int get() = Reader.nextInt()
val getint:Int get(){ val ans = getlong ; if(ans > Int.MAX_VALUE) IntArray(1000000000); return ans.toInt() }
val getlong:Long get() = Reader.nextLong()
val getstr:String get() = Reader.nextString()
fun getline(n:Int):IntArray{
    return IntArray(n){getint}
}
fun getlineL(n:Int):LongArray{
    return LongArray(n){getlong}
}
var dmark = -1
infix fun Any.dei(a:Any){
    dmark++
    var str = "<${dmark}>   "
    debug()
    if(this is String){ str += this
    }else if(this is Int){ str += this.toString()
    }else if(this is Long){ str += this.toString()
    }else{ str += this.toString()}
    if(a is List<*>){ println("$str : ${a.joinToString(" ")}")
    }else if(a is IntArray){ println("$str : ${a.joinToString(" ")}")
    }else if(a is LongArray){ println("$str : ${a.joinToString(" ")}")
    }else if(a is BooleanArray){ println("$str :${a.map{if(it)'1' else '0'}.joinToString(" ")}")
    }else if(a is Array<*>){
        println("$str : ")
        for(c in a){if(c is IntArray){println(c.joinToString(" "))}
        else if(c is LongArray){println(c.joinToString(" "))}
        else if(c is BooleanArray){println(c.map { if(it) '1' else '0' }.joinToString(""))
        }
        }
        println()
    }else{ println("$str : $a")
    }
}
val just = " "
fun crash(){
    throw Exception("Bad programme")}
fun assert(a:Boolean){
    if(!a){
        throw Exception("Failed Assertion")
    }}
enum class solveMode {
    real, rand, tc
}
object solve{
    var mode:solveMode = solveMode.real
    var tcNum:Int = 0
    var rand:()->Unit = {}
    var TC:MutableMap<Int,()->Unit> = mutableMapOf()
    var tn:Long = 0
    fun cases(onecase:()->Unit){
        val t = if(mode == solveMode.real){if(singleCase) 1 else getint} else if(mode == solveMode.tc){1 } else randCount
        if(pI != 998_244_353 && pI != 1_000_000_007){
            throw Exception("Not usual primes!")
        }
        if(t == 1 && mode != solveMode.real){
            tn = System.currentTimeMillis()
        }
        repeat(t){
            if(mode == solveMode.tc){
                TC[tcNum]?.let { it() }
                Reader.rerouteInput()
            }else if(mode == solveMode.rand){
                rand()
                Reader.rerouteInput()
            }
            onecase()
        }
        if(t == 1 && mode != solveMode.real){
            val dt = System.currentTimeMillis() - tn
            println("Time $dt ms ")
        }
    }
    inline fun singleCase(a:solve.()->Unit){
        val t = if(mode != solveMode.rand){1} else randCount
        repeat(t) { a() }
    }
    fun rand(a:()->Unit){
        this.rand = a
    }
    fun tc(id:Int = 0,a:()->Unit){
        TC[id] = a
    }
    fun usetc(a:Int = 0 ){
        this.tcNum = a
        this.mode = solveMode.tc
    }
    fun userand(){
        this.mode = solveMode.rand
    }
}
fun debug(){}
const val m = 10
const val singleCase = true
fun main(){
    solve.cases{
        val n = getint
        val t = getint

        val can = Array(m){BooleanArray(m){false} }

        val enables = Array(m){BooleanArray(m){false} }
        val banned = Array(m){BooleanArray(m) }
        for(i in 0 until m) {
            for(j in i+1 until m) {
                banned[i][j] = true
            }
        }
        repeat(t){
            val a = getint
            val b = getint
            can[b][a] = true
            can[a][b] = true
        }
        for(i in 0 until m) {
            for(j in 0 until m) {
                if(!can[i][j]) {
                    enables[i][j] = true
                }
            }
        }
        val enablemask = IntArray(m)
        val bannedmask = IntArray(m)

        for(i in 0 until m){
            for(j in 0 until m){
                if(enables[i][j]) {
                    enablemask[i] += 1 shl j
                }
                if(banned[i][j]){
                    bannedmask[i] += 1 shl j
                }
            }
        }

        var DP = IntArray(1 shl m)
        DP[(1 shl m) - 1 ] = 1
        repeat(n){
            val new = IntArray(1 shl m)
            for(left in 0 until (1 shl m)) {
                for(adding in 0 until m) {
                    if(!left.has(adding)) continue
                    val newmask = (left and ( bannedmask[adding]).inv()) or enablemask[adding]
                    new[newmask] = new[newmask] modPlus DP[left]
                }
            }
            DP = new
        }
        var ret = 0
        for(a in DP) {
            ret = ret modPlus a
        }
        put(ret)
        /*
        how many classes

         */

    }
    done()
}
/*
3
3
0 1
0 2
1 2
 */

// $time$
import java.io.BufferedInputStream
import java.io.File
import java.io.PrintWriter
import kotlin.system.measureTimeMillis

// 1. Modded
const val p = 998244353L
const val pI = p.toInt()
fun Int.adjust():Int{ if(this >= pI){ return this  - pI }else if (this < 0){ return this + pI };return this }
fun Int.snap():Int{ if(this >= pI){return this - pI} else return this}
infix fun Int.modM(b:Int):Int{ return ((this.toLong() * b) % pI).toInt() }
infix fun Int.modPlus(b:Int):Int{ val ans = this + b;return if(ans >= pI) ans - pI else ans }
fun intPow(x:Int,e:Int,m:Int):Int{
    var X = x ; var E =e ; var Y = 1
    while(E > 0){
        if(E and 1 == 0){
            X = ((1L * X * X) % m).toInt()
            E = E shr 1
        }else{
            Y = ((1L * X * Y) % m).toInt()
            E -= 1
        }
    }
    return Y
}
// 2. DP initial values
const val plarge = 1_000_000_727
const val nlarge = -plarge
const val phuge = 2_727_000_000_000_000_000L
const val nhuge = -phuge
// 3. conveniecen conversions
val Boolean.chi:Int get() = if(this) 1 else 0 //characteristic function
val Char.code :Int get() = this.toInt() -  'a'.toInt()
//3. hard to write stuff
fun IntArray.put(i:Int,v:Int){ this[i] = (this[i] + v).adjust() }
val mint:MutableList<Int> get() = mutableListOf<Int>()
val mong:MutableList<Long> get() = mutableListOf<Long>()
//4. more outputs
fun List<Char>.conca():String = this.joinToString("")
val CharArray.conca :String get() = this.joinToString("")
val IntArray.conca :String get() = this.joinToString(" ")
@JvmName("concaInt")
fun List<Int>.conca():String = this.joinToString(" ")
val LongArray.conca:String get() = this.joinToString(" ")
@JvmName("concaLong")
fun List<Long>.conca():String = this.joinToString(" ")
//5. Pair of ints
const val longmask = (1L shl 32) - 1
fun makepair(a:Int, b:Int):Long = (a.toLong() shl 32) xor (longmask and b.toLong()) // remember positev sonly
val Long.first get() = (this ushr 32).toInt()
val Long.second get() = this.toInt()
//6. strings
val String.size get() = this.length
const val randCount = 100
//7. bits
fun Int.has(i:Int):Boolean = (this and (1 shl i) != 0)
//8 TIME
inline fun TIME(f:()->Unit){
    val t = measureTimeMillis(){
        f()
    }
    println("$t ms")
}
object Reader{
    private const val BS = 1 shl 16
    private const val NC = 0.toChar()
    private val buf = ByteArray(BS)
    private var bId = 0
    private var size = 0
    private var c = NC

    var warningActive = true
    var fakein = StringBuilder()

    private var IN: BufferedInputStream = BufferedInputStream(System.`in`, BS)
    val OUT: PrintWriter = PrintWriter(System.out)

    private val char: Char
        get() {
            while (bId == size) {
                size = IN.read(buf) // no need for checked exceptions
                if (size == -1) return NC
                bId = 0
            }
            return buf[bId++].toChar()
        }

    fun nextInt(): Int {
        var neg = false
        if (c == NC) c = char
        while (c < '0' || c > '9') {
            if (c == '-') neg = true
            c = char
        }
        var res = 0
        while (c in '0'..'9') {
            res = (res shl 3) + (res shl 1) + (c - '0')
            c = char
        }
        return if (neg) -res else res
    }
    fun nextLong(): Long {
        var neg = false
        if (c == NC) c = char
        while (c < '0' || c > '9') {
            if (c == '-') neg = true
            c = char
        }
        var res = 0L
        while (c in '0'..'9') {
            res = (res shl 3) + (res shl 1) + (c - '0')
            c = char
        }
        return if (neg) -res else res
    }
    fun nextString():String{
        val ret = StringBuilder()
        while (true){
            c = char
            if(!isWhitespace(c)){ break}
        }
        ret.append(c)
        while (true){
            c = char
            if(isWhitespace(c)){ break}
            ret.append(c)
        }
        return ret.toString()
    }
    fun isWhitespace(c:Char):Boolean{
        return c == ' ' || c == '\n' || c == '\r' || c == '\t'
    }
    fun rerouteInput(){
        if(warningActive){
            put("Custom test enabled")
            println("Custom test enabled")
            warningActive = false
        }
        val S = fakein.toString()
        println("New Case ")
        println(S.take(80))
        println("...")
        fakein.clear()
        IN = BufferedInputStream(S.byteInputStream(),BS)
    }
    fun takeFile(name:String){
        IN = BufferedInputStream(File(name).inputStream(),BS)
    }
}
fun put(aa:Any){ Reader.OUT.println(aa)}
fun done(){ Reader.OUT.close() }
fun share(aa:Any){
    if(aa is IntArray){Reader.fakein.append(aa.joinToString(" "))}
    else if(aa is LongArray){Reader.fakein.append(aa.joinToString(" "))}
    else if(aa is List<*>){Reader.fakein.append(aa.toString())}
    else{Reader.fakein.append(aa.toString())}
    Reader.fakein.append("\n")
}

val getintfast:Int get() = Reader.nextInt()
val getint:Int get(){ val ans = getlong ; if(ans > Int.MAX_VALUE) IntArray(1000000000); return ans.toInt() }
val getlong:Long get() = Reader.nextLong()
val getstr:String get() = Reader.nextString()
fun getline(n:Int):IntArray{
    return IntArray(n){getint}
}
fun getlineL(n:Int):LongArray{
    return LongArray(n){getlong}
}
var dmark = -1
infix fun Any.dei(a:Any){
    dmark++
    var str = "<${dmark}>   "
    debug()
    if(this is String){ str += this
    }else if(this is Int){ str += this.toString()
    }else if(this is Long){ str += this.toString()
    }else{ str += this.toString()}
    if(a is List<*>){ println("$str : ${a.joinToString(" ")}")
    }else if(a is IntArray){ println("$str : ${a.joinToString(" ")}")
    }else if(a is LongArray){ println("$str : ${a.joinToString(" ")}")
    }else if(a is BooleanArray){ println("$str :${a.map{if(it)'1' else '0'}.joinToString(" ")}")
    }else if(a is Array<*>){
        println("$str : ")
        for(c in a){if(c is IntArray){println(c.joinToString(" "))}
        else if(c is LongArray){println(c.joinToString(" "))}
        else if(c is BooleanArray){println(c.map { if(it) '1' else '0' }.joinToString(""))
        }
        }
        println()
    }else{ println("$str : $a")
    }
}
val just = " "
fun crash(){
    throw Exception("Bad programme")}
fun assert(a:Boolean){
    if(!a){
        throw Exception("Failed Assertion")
    }}
enum class solveMode {
    real, rand, tc
}
object solve{
    var mode:solveMode = solveMode.real
    var tcNum:Int = 0
    var rand:()->Unit = {}
    var TC:MutableMap<Int,()->Unit> = mutableMapOf()
    var tn:Long = 0
    fun cases(onecase:()->Unit){
        val t = if(mode == solveMode.real){if(singleCase) 1 else getint} else if(mode == solveMode.tc){1 } else randCount
        if(pI != 998_244_353 && pI != 1_000_000_007){
            throw Exception("Not usual primes!")
        }
        if(t == 1 && mode != solveMode.real){
            tn = System.currentTimeMillis()
        }
        repeat(t){
            if(mode == solveMode.tc){
                TC[tcNum]?.let { it() }
                Reader.rerouteInput()
            }else if(mode == solveMode.rand){
                rand()
                Reader.rerouteInput()
            }
            onecase()
        }
        if(t == 1 && mode != solveMode.real){
            val dt = System.currentTimeMillis() - tn
            println("Time $dt ms ")
        }
    }
    inline fun singleCase(a:solve.()->Unit){
        val t = if(mode != solveMode.rand){1} else randCount
        repeat(t) { a() }
    }
    fun rand(a:()->Unit){
        this.rand = a
    }
    fun tc(id:Int = 0,a:()->Unit){
        TC[id] = a
    }
    fun usetc(a:Int = 0 ){
        this.tcNum = a
        this.mode = solveMode.tc
    }
    fun userand(){
        this.mode = solveMode.rand
    }
}
fun debug(){}
const val singleCase = true
fun main(){
    solve.cases{
        val n = getint
        val t = getint

        val can = Array(10){BooleanArray(10){true} }
//        for(i in 0 until 10) {
//            for(j in i until 10){
//                can[i][j] = true
//            }
//        }

        repeat(t){
            val a = getint
            val b = getint
            can[b][a] = false
        }
        var DP = IntArray(10){1}
        repeat(n-1){
            val new = IntArray(10)
            for(i in 0 until 10){
                for(j in 0 until 10){
                    if(can[i][j]) {
                        new[j] = new[j] modPlus DP[i]
                    }
                }
            }
            DP = new
        }
        var ret = 0
        for(a in DP) {
            ret = ret modPlus a
        }
        put(ret)
        /*
        how many classes

         */

    }
    done()
}


A few years ago, Hitagi encountered a giant crab, who stole the whole of her body weight. Ever since, she tried to avoid contact with others, for fear that this secret might be noticed.To get rid of the oddity and recover her weight, a special integer sequence is needed. Hitagi's sequence has been broken for a long time, but now Kaiki provides an opportunity.Hitagi's sequence a has a length of n. Lost elements in it are denoted by zeros. Kaiki provides another sequence b, whose length k equals the number of lost elements in a (i.e. the number of zeros). Hitagi is to replace each zero in a with an element from b so that each element in b should be used exactly once. Hitagi knows, however, that, apart from 0, no integer occurs in a and b more than once in total.If the resulting sequence is not an increasing sequence, then it has the power to recover Hitagi from the oddity. You are to determine whether this is possible, or Kaiki's sequence is just another fake. In other words, you should detect whether it is possible to replace each zero in a with an integer from b so that each integer from b is used exactly once, and the resulting sequence is not increasing.

The first line of input contains two space-separated positive integers n (2 ≤ n ≤ 100) and k (1 ≤ k ≤ n) — the lengths of sequence a and b respectively. The second line contains n space-separated integers a1, a2, ..., an (0 ≤ ai ≤ 200) — Hitagi's broken sequence with exactly k zero elements. The third line contains k space-separated integers b1, b2, ..., bk (1 ≤ bi ≤ 200) — the elements to fill into Hitagi's sequence. Input guarantees that apart from 0, no integer occurs in a and b more than once in total.

Output "Yes" if it's possible to replace zeros in a with elements in b and make the resulting sequence not increasing, and "No" otherwise.

NoteIn the first sample:   Sequence a is 11, 0, 0, 14.  Two of the elements are lost, and the candidates in b are 5 and 4.  There are two possible resulting sequences: 11, 5, 4, 14 and 11, 4, 5, 14, both of which fulfill the requirements. Thus the answer is "Yes". In the second sample, the only possible resulting sequence is 2, 3, 5, 8, 9, 10, which is an increasing sequence and therefore invalid.

import java.io.InputStream
import java.math.BigDecimal
import java.math.BigInteger

fun main(args: Array<String>) = input.run {
    val n = nextInt()
    val k = nextInt()
    val a = nextInts(n)
    val b = nextInts(k)
    b.sort()
    b.reverse()
    val ans = solve(a, b)
    println(if (ans) "Yes" else "No")
}

fun solve(a: IntArray, b: IntArray): Boolean {
    var i = 0
    a.indices.forEach {
        if (a[it] == 0) {
            a[it] = b[i++]
        }
    }
    return (1 until a.size).any {
        a[it] < a[it - 1]
    }
}

val input = FastScanner()

fun String.toBigInteger() = BigInteger(this)
fun String.toBigDecimal() = BigDecimal(this)

class FastScanner(private val input: InputStream = System.`in`) {
    private val sb = StringBuilder()
    private val buffer = ByteArray(4096)
    private var pos = 0
    private var size = 0

    fun nextString(): String? {
        var c = skipWhitespace()
        if (c < 0) return null

        return sb.run {
            setLength(0)

            do {
                append(c.toChar())
                c = read()
            } while (c > ' '.toInt())

            toString()
        }
    }

    fun nextLine(): String? {
        var c = read()
        if (c < 0) return null

        return sb.run {
            setLength(0)

            while (c >= 0 && c != '\n'.toInt()) {
                append(c.toChar())
                c = read()
            }

            toString()
        }
    }

    fun nextLong(): Long {
        var c = skipWhitespace()

        val sign = if (c == '-'.toInt()) {
            c = read()
            -1
        } else 1

        var ans = 0L

        while (c > ' '.toInt()) {
            ans = ans * 10 + c - '0'.toInt()
            c = read()
        }

        return sign * ans
    }

    fun nextInt() = nextLong().toInt()
    fun nextDouble() = nextString()?.toDouble() ?: 0.0
    fun nextBigInteger(): BigInteger = nextString()?.toBigInteger() ?: BigInteger.ZERO
    fun nextBigDecimal(): BigDecimal = nextString()?.toBigDecimal() ?: BigDecimal.ZERO

    fun nextStrings(n: Int) = Array<String>(n) { nextString() ?: "" }
    fun nextInts(n: Int) = IntArray(n) { nextInt() }
    fun nextLongs(n: Int) = LongArray(n) { nextLong() }
    fun nextDoubles(n: Int) = DoubleArray(n) { nextDouble() }
    fun nextBigIntegers(n: Int) = Array<BigInteger>(n) { nextBigInteger() }
    fun nextBigDecimals(n: Int) = Array<BigDecimal>(n) { nextBigDecimal() }

    fun nextStrings(n: Int, m: Int) = Array(n) { nextStrings(m) }
    fun nextInts(n: Int, m: Int) = Array(n) { nextInts(m) }
    fun nextLongs(n: Int, m: Int) = Array(n) { nextLongs(m) }
    fun nextDoubles(n: Int, m: Int) = Array(n) { nextDoubles(m) }
    fun nextBigIntegers(n: Int, m: Int) = Array(n) { nextBigIntegers(m) }
    fun nextBigDecimals(n: Int, m: Int) = Array(n) { nextBigDecimals(m) }

    private fun skipWhitespace(): Int {
        while (true) {
            val c = read()
            if (c > ' '.toInt() || c < 0) return c
        }
    }

    private fun read(): Int {
        while (pos >= size) {
            if (size < 0) return -1
            size = input.read(buffer, 0, buffer.size)
            pos = 0
        }
        return buffer[pos++].toInt()
    }
}

import java.io.File
import java.io.InputStream
import java.util.*

fun solve(inp: InputReader) {
    val (n, k) = readLine()!!.split(" ").map(String::toInt)
    val seqA = readLine()!!.split(" ").map(String::toInt).toMutableList()
    val seqB = readLine()!!.split(" ").map(String::toInt).toMutableList()

    if (k > 1) {
        println("Yes")
    } else {
        seqA[seqA.indexOf(0)] = seqB[0]
        val isAscending = (1..n-1).all { i -> seqA[i] > seqA[i - 1] }
        println(if (isAscending) "No" else "Yes")
    }
}

fun main(args: Array<String>) = solve(initIO("Mine" in args))

fun initIO(isLocal: Boolean) = when (isLocal) {
    true -> InputReader(File("input.txt").inputStream())
    false -> InputReader(System.`in`)
}

class InputReader(inputStream: InputStream) {
    val reader = inputStream.bufferedReader()
    var tokenizer = StringTokenizer("")

    fun nextLine(): String = when {
        tokenizer.hasMoreTokens() -> tokenizer.nextToken("")!!
        else -> reader.readLine()!!
    }

    fun nextWord(): String {
        while (!tokenizer.hasMoreTokens()) {
            tokenizer = StringTokenizer(nextLine())
        }
        return tokenizer.nextToken()!!
    }

    fun nextInt() = nextWord().toInt()

    fun nextLong() = nextWord().toLong()
}

import java.util.*

/**
 * Created by Administrator on 2017/6/8.
 */
fun isSort(a: Array<Int>, b: Int): Boolean {

    var last = 0
    for (i in 0..a.size-1){
        if(a[i]==0)
            a[i] = b
        if (0 == i){
            last = a[i]
        }else {

            if (a[i]<last)
                return false
            else last = a[i]
        }
    }
    return true
}
fun main(args: Array<String>) {

    var out = Scanner(System.`in`)
    var aLen = out.nextInt()
    var bLen = out.nextInt()
    var a  = Array(aLen,{out.nextInt()})
    var b  = Array(bLen,{out.nextInt()})
    //  println(b[0])
    if (bLen>=2){
        println("Yes")
    }else if (isSort(a,b[0])){
        println("No")
    }else{
        println("Yes")
    }

}

import java.util.*

fun main(vararg args: String) {

    // TODO: KEEP
//    naturalOrder<Int>()
    fun IntArray.isOrdered() = if (size <= 1) true else (1 until size).all { this[it - 1] <= this[it] }

    with(Scanner(System.`in`)) {
        val n = nextInt()
        val k = nextInt()
        val a = IntArray(n) { nextInt() }
        val b = IntArray(k) { nextInt() }
        var r = k > 1
        if (!r) {
            a[a.indices.find { a[it] == 0 }!!] = b[0]
            r = !a.isOrdered()
        }
        println(if (r) "Yes" else "No")
    }
}

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

val LOCAL_MODE = true

fun main(args: Array<String>) {
  val input: InputReader
  val output: PrintWriter
  if (false) {
    input = InputReader(FileInputStream("input.txt"))
    output = PrintWriter(FileOutputStream("output.txt"))
  } else {
    input = InputReader(System.`in`)
    output = PrintWriter(System.out)
  }
  Solver(input, output).run()
  input.close()
  output.close()
}

fun debug(x: Any) {
  if (LOCAL_MODE) {
    System.err.println(x)
  }
}

class Solver(val input: InputReader, val output: PrintWriter) {

  companion object {
    val MOD = (1e9 + 7).toInt()
  }

  fun run() {
    if (true) {
      read()
//      output.println(solve())
    } else {
      for (stress in generateSequence({ 1 }, { it + 1 })) {
        debug("Stress #$stress")
        generateStress()
        printStress()
        val my = solve()
        val slow = slow()
//        require(my == slow, { "$my != $slow" })
      }
    }

  }

  private fun printStress() {
  }

  private fun generateStress() {
  }

  private var n: Int = 0
  private var k: Int = 0

  private fun read() {
    n = input.nextInt()
    k = input.nextInt()
    val a = (1..n).map { input.nextInt() }.toMutableList()
    val b = (1..k).map { input.nextInt() }.sortedDescending()
    var j = 0
    for (i in 0..n - 1) {
      if (a[i] == 0) {
        a[i] = b[j++]
      }
    }
    val sorted = a.sorted()
    if (a == sorted) {
      output.println("No")
    } else {
      output.println("Yes")
    }

  }

  private fun slow(): Int = 0

  private fun solve() {
  }

}

class InputReader(val stream: InputStream) : Closeable {

  var reader: BufferedReader = BufferedReader(InputStreamReader(stream), 32768)

  var tokenizer: StringTokenizer? = null

  override fun close() {
    stream.close()
  }

  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 = next().toInt()

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

}

fun main() {
    var (n, m) = readInts()
    var numbers = readInts().toMutableList()
    var toPut = readInts().sorted()
    if (toPut.size > 1 || n == m) {
        println("YES")
    } else {
        for (i in 0 until numbers.size) {
            if (numbers[i] == 0) {
                numbers[i] = toPut[0]
            }
        }
        checkIsIcreasing(numbers)
    }
}

private fun checkIsIcreasing(a: List<Int>) {
    for (i in 1 until a.size) {
        if (a[i] < a[i - 1]) {
            println("YES")
            return
        }
    }
    println("NO")
}

private fun readInts(): List<Int> = readLine()!!.split(' ').map { it.toInt() }
private fun readLongs(): List<Long> = readLine()!!.split(' ').map { it.toLong() }
private fun readInt(): Int = readLine()!!.toInt()
private fun readLong(): Long = readLine()!!.toLong()
private fun readStr(): String? = readLine()!!

fun main() {
    fun readInt() = readLine()!!.toInt()
    fun readInts() = readLine()!!.split(" ").map(String::toInt)

    val (n, k) = readInts()
    if (k > 1) return print("Yes")
    val a = readInts().toIntArray()
    for (pos in 0 until n)
        if (a[pos] == 0) {
            a[pos] = readInt()
            break
        }
    if (a.first() == a.last()) return print("Yes")
    for (pos in 0 until n - 1)
        if (a[pos + 1] < a[pos]) return print("Yes")
    print("No")
}

fun main() {
    fun readInt() = readLine()!!.toInt()
    fun readInts() = readLine()!!.split(" ").map(String::toInt)

    val (n, k) = readInts()
    if (k > 1) return print("Yes")
    val a = mutableListOf(-1)
    a.addAll(readInts())
    val aArr = a.toIntArray()
    for (pos in 1..n) {
        if (aArr[pos] == 0) aArr[pos] = readInt()
        if (aArr[pos] < aArr[pos - 1]) return print("Yes")
    }
    print("No")
}

import java.io.BufferedReader
import java.io.PrintWriter
import java.util.*

class Solver {

    fun input(inp: FastInputReader) {
        val n = inp.readInt()
        val k = inp.readInt()

        val a = inp.readIntArray(n)
        val b = inp.readIntArray(k)
        b.sortDescending()

        var j = 0
        for (i in a.indices)
            if (a[i] == 0)
            {
                a[i] = b[j]
                j++
            }
        for (i in 1..a.size - 1)
            if (a[i-1] >= a[i]) {
                println("Yes")
                return
            }
        println("No")
    }

    fun solve() {

    }

}

object Algorithms {

    tailrec fun gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b)
    tailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b)

    fun lcm(a: Int, b: Int): Int = a / gcd(a, b) * b
    fun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b

}

class FastInputReader {

    private val bufferedReader: BufferedReader = System.`in`.bufferedReader()
    private var stringTokenizer: StringTokenizer = StringTokenizer("")

    fun nextLine(): String = bufferedReader.readLine()
    fun next(): String {
        while (!stringTokenizer.hasMoreTokens())
            stringTokenizer = StringTokenizer(nextLine())
        return stringTokenizer.nextToken()
    }

    fun readInt(): Int = next().toInt()
    fun readLong(): Long = next().toLong()
    fun readDouble(): Double = next().toDouble()

    fun readIntArray(size: Int) = IntArray(size, { readInt() })
    fun readLongArray(size: Int) = LongArray(size, { readLong() })
    fun readStringArray(size: Int) = Array(size, { next() })
    inline fun <reified T> readTArray(size: Int, convert: (Int, String) -> T) = Array(size, { convert(it, next()) })

    fun readIntTable(rows: Int, cols: Int) = Array(rows, { readIntArray(cols) })
    fun readLongTable(rows: Int, cols: Int) = Array(rows, { readLongArray(cols) })
    fun readStringTable(rows: Int, cols: Int) = Array(rows, { readStringArray(cols) })
    inline fun <reified T> readTTable(rows: Int, cols: Int, convert: (Int, Int, String) -> T) = Array(rows, { row -> readTArray(cols, { col, s -> convert(row, col, s) }) })

}

fun main(args: Array<String>) {

//    val millis = measureTimeMillis(Solver()::solve)
//    System.err.println("Time spent: $millis")
    val solver = Solver()
    solver.input(FastInputReader())
    solver.solve()

}

fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(" ").map(String::toInt)
    val a = readLine()!!.split(" ").map(String::toInt).toIntArray()
    val b = readLine()!!.split(" ").map(String::toInt)

    if (k > 1) {
        println("YES")
    } else {
        (0..a.lastIndex)
                .filter { a[it] == 0 }
                .forEach { a[it] = b[0] }
        val yes = (1..a.lastIndex).any { a[it] < a[it - 1] }
        println(if (yes) "YES" else "NO")
    }

}

import java.util.*

/**
 * Created by Administrator on 2017/6/8.
 */
fun isSort(a: Array<Int>): Boolean {

    var last = 0;
    for (i in 0..a.size){
        if (0 == i){
            last = a[i]
        }else if(a[i]!=0){
            if (a[i]>last)
                return false
            else last = a[i]
        }
    }
    return true
}
    fun main(args: Array<String>) {

    var out = Scanner(System.`in`)
    var aLen = out.nextInt()
    var bLen = out.nextInt()
    var a  = Array(aLen,{out.nextInt()})
    var b  = Array(bLen,{out.nextInt()})
    if (bLen>=2){
        println("Yes")
    }else if (isSort(a)){
        println("No")
    }else{
        println("Yes")
    }

}

import java.util.*

/**
 * Created by Administrator on 2017/6/8.
 */
fun isSort(a: Array<Int>, b: Int): Boolean {

    var last = 0
    for (i in 0..a.size-1){
        if (0 == i){
            last = a[i]
        }else if(a[i]!=0){
            if (a[i]<last)
                return false
            else last = a[i]
        }else if (b < last){
            return false
        }
    }
    return true
}
    fun main(args: Array<String>) {

    var out = Scanner(System.`in`)
    var aLen = out.nextInt()
    var bLen = out.nextInt()
    var a  = Array(aLen,{out.nextInt()})
    var b  = Array(bLen,{out.nextInt()})
      //  println(b[0])
    if (bLen>=2){
        println("Yes")
    }else if (isSort(a,b[0])){
        println("No")
    }else{
        println("Yes")
    }

}

import java.util.*

fun isSort(a: Array<Int>): Boolean {

    var last = 0;
    for (i in 0..a.size){
        if (0 == i){
            last = a[i]
        }else if(a[i]!=0){
            if (a[i]>last)
                return false
            else last = a[i]
        }
    }
    return true
}
    fun main(args: Array<String>) {

    var out = Scanner(System.`in`)
    var aLen = out.nextInt()
    var bLen = out.nextInt()
    var a  = Array(aLen,{out.nextInt()})
    var b  = Array(bLen,{out.nextInt()})
    if (bLen>=2){
        println("Yes")
    }else if (isSort(a)){
        println("Yes")
    }else{
        println("No")
    }

}

import java.util.*

/**
 * Created by Administrator on 2017/6/8.
 */
fun isSort(a: Array<Int>, i: Int): Boolean {

    var last = 0;
    for (i in 0..a.size-1){
        if (0 == i){
            last = a[i]
        }else if(a[i]!=0){
            if (a[i]<last)
                return false
            else last = a[i]
        }else if (i < last){
            return false
        }
    }
    return true
}
    fun main(args: Array<String>) {

    var out = Scanner(System.`in`)
    var aLen = out.nextInt()
    var bLen = out.nextInt()
    var a  = Array(aLen,{out.nextInt()})
    var b  = Array(bLen,{out.nextInt()})
    if (bLen>=2){
        println("Yes")
    }else if (isSort(a,b[0])){
        println("No")
    }else{
        println("Yes")
    }

}

import java.util.*

/**
 * Created by Administrator on 2017/6/8.
 */
fun isSort(a: Array<Int>, b: Int): Boolean {

    var last = 0
    for (i in 0..a.size-1){
        if (0 == i){
            last = a[i]
        }else {
            if(a[i]==0)
                a[i] = b
            if (a[i]<last)
                return false
            else last = a[i]
        }
    }
    return true
}
fun main(args: Array<String>) {

    var out = Scanner(System.`in`)
    var aLen = out.nextInt()
    var bLen = out.nextInt()
    var a  = Array(aLen,{out.nextInt()})
    var b  = Array(bLen,{out.nextInt()})
    //  println(b[0])
    if (bLen>=2){
        println("Yes")
    }else if (isSort(a,b[0])){
        println("No")
    }else{
        println("Yes")
    }

}

import java.util.*

fun isSort(a: Array<Int>): Boolean {

    var last = 0;
    for (i in 0..a.size){
        if (0 == i){
            last = a[i]
        }else if(a[i]!=0){
            if (a[i]>last)
                return false
            else last = a[i]
        }
    }
    return true
}
    fun main(args: Array<String>) {

    var out = Scanner(System.`in`)
    var aLen = out.nextInt()
    var bLen = out.nextInt()
    var a  = Array(aLen,{out.nextInt()})
    var b  = Array(bLen,{out.nextInt()})
    if (bLen>=2){
        println("Yse")
    }else if (isSort(a)){
        println("Yse")
    }else{
        println("No")
    }

}

import java.util.*

/**
 * Created by Administrator on 2017/6/8.
 */
fun isSort(a: Array<Int>): Boolean {

    var last = 0;
    for (i in 0..a.size-1){
        if (0 == i){
            last = a[i]
        }else if(a[i]!=0){
            if (a[i]<last)
                return false
            else last = a[i]
        }
    }
    return true
}
    fun main(args: Array<String>) {

    var out = Scanner(System.`in`)
    var aLen = out.nextInt()
    var bLen = out.nextInt()
    var a  = Array(aLen,{out.nextInt()})
    var b  = Array(bLen,{out.nextInt()})
    if (bLen>=2){
        println("Yes")
    }else if (isSort(a)){
        println("No")
    }else{
        println("Yes")
    }

}

fun main() {
    var (n, m) = readInts()
    var numbers = readInts()
    var toPut = readInts().sorted()
    if (toPut.size > 1) {
        println("YES")
    } else {
        for (i in 0 until numbers.size) {
            if (numbers[i] == 0) {
                if (i != 0 && i != n - 1) {
                    if (toPut[0] < numbers[i - 1] || toPut[0] > numbers[i + 1]) {
                        println("YES")
                    } else {
                        println("NO")
                    }
                } else {
                    if (i == 0) {
                        if (toPut[0] > numbers[i + 1]) {
                            println("YES")
                        } else {
                            checkIsIcreasing(numbers)
                        }
                    } else {
                        if (toPut[0] < numbers[n - 1]) {
                            println("YES")
                        } else {
                            checkIsIcreasing(numbers)
                        }
                    }
                }
            }
        }
    }
}

private fun checkIsIcreasing(a: List<Int>) {
    for (i in 1 until a.size) {
        if (a[i] < a[i - 1]) {
            println("YES")
            return
        }
        println("NO")
    }
}

private fun readInts(): List<Int> = readLine()!!.split(' ').map { it.toInt() }
private fun readLongs(): List<Long> = readLine()!!.split(' ').map { it.toLong() }
private fun readInt(): Int = readLine()!!.toInt()
private fun readLong(): Long = readLine()!!.toLong()
private fun readStr(): String? = readLine()!!

fun main() {
    var (n, m) = readInts()
    var numbers = readInts().toMutableList()
    var toPut = readInts().sorted()
    if (toPut.size > 1) {
        println("YES")
    } else {
        for (i in 0 until numbers.size) {
            if (numbers[i] == 0) {
                if (i != 0 && i != n - 1) {
                    if (toPut[0] < numbers[i - 1] || toPut[0] > numbers[i + 1]) {
                        println("YES")
                    } else {
                        numbers.set(i, toPut[0])
                        checkIsIcreasing(numbers)
                    }
                } else {
                    if (i == 0) {
                        if (toPut[0] > numbers[i + 1]) {
                            println("YES")
                        } else {
                            checkIsIcreasing(numbers)
                        }
                    } else {
                        if (toPut[0] < numbers[n - 1]) {
                            println("YES")
                        } else {
                            checkIsIcreasing(numbers)
                        }
                    }
                }
            }
        }
    }
}

private fun checkIsIcreasing(a: List<Int>) {
    for (i in 1 until a.size) {
        if (a[i] < a[i - 1]) {
            println("YES")
            return
        }
        println("NO")
    }
}

private fun readInts(): List<Int> = readLine()!!.split(' ').map { it.toInt() }
private fun readLongs(): List<Long> = readLine()!!.split(' ').map { it.toLong() }
private fun readInt(): Int = readLine()!!.toInt()
private fun readLong(): Long = readLine()!!.toLong()
private fun readStr(): String? = readLine()!!

fun main() {
    var (n, m) = readInts()
    var numbers = readInts().toMutableList()
    var toPut = readInts().sorted()
    if (toPut.size > 1) {
        println("YES")
    } else {
        for (i in 0 until numbers.size) {
            if (numbers[i] == 0) {
                if (i != 0 && i != n - 1) {
                    if (toPut[0] < numbers[i - 1] || toPut[0] > numbers[i + 1]) {
                        println("YES")
                    } else {
                        numbers.set(i, toPut[0])
                        checkIsIcreasing(numbers)
                    }
                } else {
                    if (i == 0) {
                        if (toPut[0] > numbers[i + 1]) {
                            println("YES")
                        } else {
                            checkIsIcreasing(numbers)
                        }
                    } else {
                        if (toPut[0] < numbers[n - 1]) {
                            println("YES")
                        } else {
                            checkIsIcreasing(numbers)
                        }
                    }
                }
            }
        }
    }
}

private fun checkIsIcreasing(a: List<Int>) {
    for (i in 1 until a.size) {
        if (a[i] < a[i - 1]) {
            println("YES")
            return
        }
        println("NO")
        return
    }
}

private fun readInts(): List<Int> = readLine()!!.split(' ').map { it.toInt() }
private fun readLongs(): List<Long> = readLine()!!.split(' ').map { it.toLong() }
private fun readInt(): Int = readLine()!!.toInt()
private fun readLong(): Long = readLine()!!.toLong()
private fun readStr(): String? = readLine()!!

fun main() {
    fun readInt() = readLine()!!.toInt()
    fun readInts() = readLine()!!.split(" ").map(String::toInt)

    val (n, k) = readInts()
    if (k > 1) return print("Yes")
    val a = mutableListOf(-1)
    a.addAll(readInts())
    for (pos in 1..n)
        if (a[pos] == 0) {
            if (readInt() < a[pos - 1]) return print("Yes")
        } else if (a[pos] < a[pos - 1]) return print("Yes")
    print("No")
}

fun main() {
    fun readInt() = readLine()!!.toInt()
    fun readInts() = readLine()!!.split(" ").map(String::toInt)

    val (n, k) = readInts()
    if (k > 1) return print("Yes")
    val a = mutableListOf(-1)
    a.addAll(readInts())
    for (pos in 1 until n)
        if (a[pos] == 0) {
            if (readInt() < a[pos - 1]) return print("Yes")
        } else if (a[pos] < a[pos - 1]) return print("Yes")
    print("No")
}


Luba has a ticket consisting of 6 digits. In one move she can choose digit in any position and replace it with arbitrary digit. She wants to know the minimum number of digits she needs to replace in order to make the ticket lucky.The ticket is considered lucky if the sum of first three digits equals to the sum of last three digits.

You are given a string consisting of 6 characters (all characters are digits from 0 to 9) — this string denotes Luba's ticket. The ticket can start with the digit 0.

Print one number — the minimum possible number of digits Luba needs to replace to make the ticket lucky.

NoteIn the first example the ticket is already lucky, so the answer is 0.In the second example Luba can replace 4 and 5 with zeroes, and the ticket will become lucky. It's easy to see that at least two replacements are required.In the third example Luba can replace any zero with 3. It's easy to see that at least one replacement is required.

import java.io.PrintWriter
import java.lang.StringBuilder
import kotlin.math.*

fun main() {
    io.apply {

        val x = str(6).map { it - '0' }.toIntArray()
        var left = x.sliceArray(0..2).sortedArray()
        var right = x.sliceArray(3..5).sortedArray()

        var delta = right.sum() - left.sum()
        if (delta < 0) {
            val tmp = left
            left = right
            right = tmp
            delta = - delta
        }
        // left < right
        val deltas = ArrayList<Int>()
        left.forEach { deltas.add(9 - it) }
        right.forEach { deltas.add(it) }
        deltas.sortDescending()
        val ans = when {
            delta == 0 -> 0
            delta <= deltas[0] -> 1
            delta <= deltas[0] + deltas[1] -> 2
            else -> 3
        }

        cout .. ans .. nl

    }.cout.flush()
}

// @formatter:off
private val io = object {
    private val `in` = System.`in`
    private fun ll(): Long {
        var x: Int; var q = false; var n = 0L; do x = `in`.read() while (x < 33); if (x == 45) { q = true; x = `in`.read() }
        do { n = n * 10 - x + 48; x = `in`.read() } while (x > 32); return if (q) n else -n
    }
    val int get() = ll().toInt(); val long get() = ll()
    fun ints(n: Int = int): IntArray { return IntArray(n) { int } }
    fun ints1(n: Int = int): IntArray { return IntArray(n) { int - 1 } }
    val cout = PrintWriter(System.out); val nl = "\n"
    private var buf = CharArray(32)
    private var bufSize = 32
    fun str(expect: Int = 32): String {
        var ix = 0
        var x: Int
        if (bufSize < expect)
            buf = CharArray(expect)
        do x = `in`.read() while (x < 33)
        do {
            if (ix == bufSize) { bufSize *= 2; buf = buf.copyOf(bufSize) }
            buf[ix++] = x.toChar()
            x = `in`.read()
        } while (x > 32)
        return java.lang.String.copyValueOf(buf, 0, ix)
    }
    operator fun PrintWriter.rangeTo(a: Int): PrintWriter { print(a); print(" "); return this }
    operator fun PrintWriter.rangeTo(a: Long): PrintWriter { print(a); print(" "); return this }
    operator fun PrintWriter.rangeTo(a: IntArray): PrintWriter { a.forEach { print(it); print(" ") }; return this }
    operator fun PrintWriter.rangeTo(a: String): PrintWriter { write(a); return this }
} // @formatter:on

/* ----------- */

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

fun main(){
	val f = BufferedReader(InputStreamReader(System.`in`))

	val a = f.readLine().map{Character.getNumericValue(it)}.toIntArray()

	val sum1 = a[0] + a[1] + a[2]
	val sum2 = a[3] + a[4] + a[5]

	if(sum1 == sum2) println(0)
	else{

		val a1 = IntArray(3){a[it]}.sorted()
		val a2 = IntArray(3){a[it+3]}.sorted()

		val changes = IntArray(6)
		//check 1
		if(sum1 > sum2){
			//get max 3
			for(k in 0 until 3){
				changes[k] = a1[k]
				changes[k+3] = 9-a2[k]
			}
		} else {
			for(k in 0 until 3){
				changes[k] = a2[k]
				changes[k+3] = 9-a1[k]
			}
		}

		changes.sort()

		val dif = Math.abs(sum1-sum2)

		var sumdif = 0
		var answer = 0
		var i = 5
		while(sumdif < dif){
			sumdif += changes[i]
			i--
			answer++
		}

		println(answer)
	}
}

import kotlin.math.*

val sc = java.util.Scanner(System.`in`)
fun main(args: Array<String>) {
	val n = sc.nextInt()
	var ans = 6
	for (i in 0..999999)
		if (islucky(i))
			ans = min(ans, different(n, i))
	println(ans)
}

fun islucky(x: Int) =
		x % 10 + x / 10 % 10 + x / 100 % 10 ==
				x / 1000 % 10 + x / 10000 % 10 + x / 100000

fun different(x: Int, y: Int): Int {
	var ans = 0
	var a = x
	var b = y
	for (i in 1..6) {
		if (a % 10 != b % 10)
			ans++
		a /= 10
		b /= 10
	}
	return ans;
}

import java.util.*
fun main(args: Array<String>) {
    val digits = readLine()!!.toCharArray().map { Character.getNumericValue(it) }

    val left = digits.take(3).toMutableList()
    val right = digits.takeLast(3).toMutableList()

    println(solve(left, right))
}

tailrec fun solve(left: MutableList<Int>, right: MutableList<Int>, steps: Int = 0): Int {
    val leftSum = left.sum()
    val rightSum = right.sum()
    if (leftSum == rightSum) return steps

    val delta = leftSum - rightSum
    var larger = if (delta>0) left else right
    val smaller = if (delta>0) right else left

    val largerDecreases = larger.sortedDescending()
    val smallerIncreases = smaller.map { 9-it }

    val maxDecrease = largerDecreases.max()!!
    val maxIncrease = smallerIncreases.max()!!

    if(Math.max(maxDecrease, maxIncrease) >= Math.abs(delta)) {
        return steps+1
    }

    fun getIndex(list: List<Int>, number: Int?): Int = if (number == null) 0 else list.indexOf(number)

    if (maxIncrease>maxDecrease) {
        smaller[getIndex(smaller, smaller.min())] = 9
        return solve(smaller, larger, steps+1)
    }
    larger[getIndex(larger, larger.max())] = 0
    return solve(smaller, larger, steps+1)
}

import kotlin.math.*

val sc = java.util.Scanner(System.`in`)
fun main(args: Array<String>) {
	val n = sc.nextInt()
	var ans = 6
	for (i in 0..999999)
		if (islucky(i))
			ans = min(ans, different(n, i))
	println(ans)
}

fun islucky(x: Int) =
		x % 1000 == x / 1000 % 10 + x / 10000 % 10 + x / 100000

fun different(x: Int, y: Int): Int {
	var ans = 0
	var a = x
	var b = y
	for (i in 1..6) {
		if (a % 10 != b % 10)
			ans++
		a /= 10
		b /= 10
	}
	return ans;
}


Limak and Radewoosh are going to compete against each other in the upcoming algorithmic contest. They are equally skilled but they won't solve problems in the same order.There will be n problems. The i-th problem has initial score pi and it takes exactly ti minutes to solve it. Problems are sorted by difficulty — it's guaranteed that pi < pi + 1 and ti < ti + 1.A constant c is given too, representing the speed of loosing points. Then, submitting the i-th problem at time x (x minutes after the start of the contest) gives max(0,  pi - c·x) points.Limak is going to solve problems in order 1, 2, ..., n (sorted increasingly by pi). Radewoosh is going to solve them in order n, n - 1, ..., 1 (sorted decreasingly by pi). Your task is to predict the outcome — print the name of the winner (person who gets more points at the end) or a word "Tie" in case of a tie.You may assume that the duration of the competition is greater or equal than the sum of all ti. That means both Limak and Radewoosh will accept all n problems.

The first line contains two integers n and c (1 ≤ n ≤ 50, 1 ≤ c ≤ 1000) — the number of problems and the constant representing the speed of loosing points. The second line contains n integers p1, p2, ..., pn (1 ≤ pi ≤ 1000, pi < pi + 1) — initial scores. The third line contains n integers t1, t2, ..., tn (1 ≤ ti ≤ 1000, ti < ti + 1) where ti denotes the number of minutes one needs to solve the i-th problem.

Print "Limak" (without quotes) if Limak will get more points in total. Print "Radewoosh" (without quotes) if Radewoosh will get more points in total. Print "Tie" (without quotes) if Limak and Radewoosh will get the same total number of points.

NoteIn the first sample, there are 3 problems. Limak solves them as follows:  Limak spends 10 minutes on the 1-st problem and he gets 50 - c·10 = 50 - 2·10 = 30 points.  Limak spends 15 minutes on the 2-nd problem so he submits it 10 + 15 = 25 minutes after the start of the contest. For the 2-nd problem he gets 85 - 2·25 = 35 points.  He spends 25 minutes on the 3-rd problem so he submits it 10 + 15 + 25 = 50 minutes after the start. For this problem he gets 250 - 2·50 = 150 points. So, Limak got 30 + 35 + 150 = 215 points.Radewoosh solves problem in the reversed order:  Radewoosh solves 3-rd problem after 25 minutes so he gets 250 - 2·25 = 200 points.  He spends 15 minutes on the 2-nd problem so he submits it 25 + 15 = 40 minutes after the start. He gets 85 - 2·40 = 5 points for this problem.  He spends 10 minutes on the 1-st problem so he submits it 25 + 15 + 10 = 50 minutes after the start. He gets max(0, 50 - 2·50) = max(0,  - 50) = 0 points. Radewoosh got 200 + 5 + 0 = 205 points in total. Limak has 215 points so Limak wins.In the second sample, Limak will get 0 points for each problem and Radewoosh will first solve the hardest problem and he will get 250 - 6·25 = 100 points for that. Radewoosh will get 0 points for other two problems but he is the winner anyway.In the third sample, Limak will get 2 points for the 1-st problem and 2 points for the 2-nd problem. Radewoosh will get 4 points for the 8-th problem. They won't get points for other problems and thus there is a tie because 2 + 2 = 4.

import kotlin.math.max

/* http://codeforces.com/problemset/problem/658/A */

fun main() {
    val (_, losingRate) = readLine()!!.split(" ").map { it.toInt() }
    val scores = readLine()!!.split(" ").map { it.toInt() }
    val times = readLine()!!.split(" ").map { it.toInt() }
    val timesPassed = times.sumPrefixes()
    val scoresReversed = scores.asReversed()
    val timesReversed = times.asReversed()
    val timesReversedPassed = timesReversed.sumPrefixes()
    val limakScore = scores.mapIndexed { index, score -> max(0, score - losingRate * timesPassed[index]) }.sum()
    val radewooshScore = scoresReversed.mapIndexed { index, score -> max(0, score - losingRate * timesReversedPassed[index]) }.sum()
    when {
        limakScore > radewooshScore -> println("Limak")
        radewooshScore > limakScore -> println("Radewoosh")
        else -> println("Tie")
    }
}

private fun List<Int>.sumPrefixes(): List<Int> {
    if (this.isEmpty()) {
        return emptyList()
    }
    val resultList = ArrayList<Int>(this.size)
    resultList.add(this[0])
    for (i in 1 until this.size) {
        resultList.add(resultList[i - 1] + this[i])
    }
    return resultList
}

fun main(args: Array<String>) {
    val reader = java.util.Scanner(System.`in`)
    val n = reader.nextInt()
    val c = reader.nextInt()
    val ps = ArrayList<Int>(n)
    val pssum = ArrayList<Int>(n)
    val pssumrev = ArrayList<Int>(n)

    val ts = ArrayList<Int>(n)
    for (i in 1..n) {
        ps.add(reader.nextInt())
        pssum.add(0)
        pssumrev.add(0)
    }

    for (i in 1..n)
        ts.add(reader.nextInt())

    var sum : Int=0
    var sumrev : Int = 0
    for (i in ts.indices) {
        sum += ts[i]
        sumrev += ts[n-i-1]
        pssum[i]=sum
        pssumrev[n-i-1]=sumrev
    }

    val a= ps.zip(pssum){a, b -> if (a<c*b) 0 else a-c*b}.sum()
    val b= ps.zip(pssumrev){a, b -> if (a<c*b) 0 else a-c*b}.sum()
    val r = if (a == b) "Tie" else if (a>b) "Limak" else "Radewoosh"
    println(r)
    //println("Limak=$a Radewoosh=$b")

}

import kotlin.math.max

fun main() {
    fun readInts() = readLine()!!.split(" ").map(String::toInt)

    val (_, constant) = readInts()
    val scores = readInts()
    val minutes = readInts()
    var limak = 0
    var radewoosh = 0
    var spentMinutes = 0
    for (pos in scores.indices) {
        spentMinutes += minutes[pos]
        limak += max(0, scores[pos] - constant * spentMinutes)
    }
    spentMinutes = 0
    for (pos in scores.indices.reversed()) {
        spentMinutes += minutes[pos]
        radewoosh += max(0, scores[pos] - constant * spentMinutes)
    }
    print(
        when {
            limak > radewoosh -> "Limak"
            limak == radewoosh -> "Tie"
            else -> "Radewoosh"
        }
    )
}

fun main(args: Array<String>){
	var tmpTime = 0
	var Limak = 0
	var Radewoosh = 0

	val (N,c) = readLine()!!.split(' ')

	val points = readLine()!!.split(' ').map { it.toInt() }
	val time = readLine()!!.split(' ').map { it.toInt() }

	for(i in 0 until N.toInt()){
		tmpTime += time[i]
		if(points[i]-tmpTime*c.toInt() < 0){
			continue
		}else{
			Limak += points[i]-tmpTime*c.toInt()
		}
	}
	tmpTime = 0
	for(i in N.toInt()-1 downTo 0){
		tmpTime += time[i]
		if(points[i]-tmpTime*c.toInt() < 0){
			continue
		}else{
			Radewoosh += points[i]-tmpTime*c.toInt()
		}
	}
	when {
		Limak > Radewoosh -> println("Limak")
		Limak < Radewoosh -> println("Radewoosh")
		else -> println("Tie")
	}

}

import kotlin.math.max

fun score(p: Int, c: Int, x: Int) : Int {
  return max(0, p-c*x)
}

fun main(args: Array<String>) {
  val (n, c) = readLine()!!.split(" ").map(String::toInt)
  val p = readLine()!!.split(" ").map(String::toInt)
  val t = readLine()!!.split(" ").map(String::toInt)
  var (score_limak, score_radewoosh) = listOf(0, 0)
  var (time_limak, time_radewoosh) = listOf(0, 0)
  for(i in 0..n-1) {
    time_limak += t[i]
    score_limak += score(p[i], c, time_limak)
  }
  for(i in n-1 downTo 0) {
    time_radewoosh += t[i]
    score_radewoosh += score(p[i], c, time_radewoosh)
  }
  if(score_radewoosh == score_limak) println("Tie")
  else if(score_radewoosh > score_limak) println("Radewoosh")
  else println("Limak")
}

fun main(args: Array<String>) {
    val reader = java.util.Scanner(System.`in`)
    val n = reader.nextInt()
    val c = reader.nextInt()
    val ps = ArrayList<Int>(n)
    val pssum = ArrayList<Int>(n)
    val pssumrev = ArrayList<Int>(n)

    val ts = ArrayList<Int>(n)
    for (i in 1..n) {
        ps.add(reader.nextInt())
        pssum.add(0)
        pssumrev.add(0)
    }

    for (i in 1..n)
        ts.add(reader.nextInt())

    var sum : Int=0
    var sumrev : Int = 0
    for (i in ts.indices) {
        sum += ts[i]
        sumrev += ts[n-i-1]
        pssum[i]=sum
        pssumrev[n-i-1]=sumrev
    }

    val a= ps.zip(pssum){a, b -> if (a<c*b) 0 else a-c*b}.sum()
    val b= ps.zip(pssumrev){a, b -> if (a<c*b) 0 else a-c*b}.sum()
    val r = if (a == b) "Tie" else if (a<b) "Limak" else "Radewoosh"
    println(r)

}


Every summer Vitya comes to visit his grandmother in the countryside. This summer, he got a huge wart. Every grandma knows that one should treat warts when the moon goes down. Thus, Vitya has to catch the moment when the moon is down.Moon cycle lasts 30 days. The size of the visible part of the moon (in Vitya's units) for each day is 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, and then cycle repeats, thus after the second 1 again goes 0.As there is no internet in the countryside, Vitya has been watching the moon for n consecutive days and for each of these days he wrote down the size of the visible part of the moon. Help him find out whether the moon will be up or down next day, or this cannot be determined by the data he has.

The first line of the input contains a single integer n (1 ≤ n ≤ 92) — the number of consecutive days Vitya was watching the size of the visible part of the moon.  The second line contains n integers ai (0 ≤ ai ≤ 15) — Vitya's records. It's guaranteed that the input data is consistent.

If Vitya can be sure that the size of visible part of the moon on day n + 1 will be less than the size of the visible part on day n, then print "DOWN" at the only line of the output. If he might be sure that the size of the visible part will increase, then print "UP". If it's impossible to determine what exactly will happen with the moon, print -1.

NoteIn the first sample, the size of the moon on the next day will be equal to 8, thus the answer is "UP".In the second sample, the size of the moon on the next day will be 11, thus the answer is "DOWN".In the third sample, there is no way to determine whether the size of the moon on the next day will be 7 or 9, thus the answer is -1.

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

class ProblemIO(val rd: BufferedReader, val wr: PrintWriter) {
    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)))
    }

    var tok = StringTokenizer("")

    fun close() { rd.close(); wr.close() }
    fun <T> print(v: T) = wr.print(v)
    fun <T> println(v: T) = wr.println(v)
    fun readToken(): String {
        while (!tok.hasMoreTokens()) tok = StringTokenizer(rd.readLine())
        return tok.nextToken()
    }
    fun readLine(): String {
        tok = StringTokenizer("")
        return rd.readLine()
    }
    fun readInt(): Int = readToken().toInt()
    fun readLong(): Long = readToken().toLong()
}

fun main(args: Array<String>) {
    Thread({ val io = ProblemIO.console(); solve(io); io.close() }).start()
}

fun solve(io: ProblemIO) {
    val n = io.readInt()
    val a = IntArray(n, { io.readInt() })
    val l = a.last()
    val res = when {
        l == 15 -> "DOWN"
        l == 0 -> "UP"
        else -> when {
            a.size == 1 -> "-1"
            l > a[a.lastIndex - 1] -> "UP"
            l < a[a.lastIndex - 1] -> "DOWN"
            else -> "-1"
        }
    }
    io.println(res)
}

fun main() {
    val r = System.`in`.bufferedReader()
    val s = StringBuilder()
    val n = r.readLine()!!.toInt()
    val v = r.readLine()!!.split(" ").map { it.toInt() }
    if (n == 1) {
        when {
            v[0] == 0 -> println("UP")
            v[0] == 15 -> println("DOWN")
            else -> println(-1)
        }
    } else {
        val before = v[n - 2]
        val mid = v[n - 1]
        when {
            mid == 15 -> println("DOWN")
            mid == 0 -> println("UP")
            mid > before -> println("UP")
            mid < before -> println("DOWN")
        }
    }
}

import java.io.*

val stdout = System.out;
val stdin = FastScanner(System.`in`);

fun solve() {
    val n = nextInt()
    val arr = nextIntArray(n)
    when {
        arr.last() == 15 -> print("DOWN")
        arr.last() == 0 -> print("UP")
        arr.size < 2 -> print("-1")
        else -> if (arr[n - 1] > arr[n - 2]) print("UP") else print("DOWN")
    }
}

inline fun print(message: Any?) = stdout.print(message)
inline fun print(message: Int) = stdout.print(message)
inline fun print(message: Long) = stdout.print(message)
inline fun print(message: Byte) = stdout.print(message)
inline fun print(message: Short) = stdout.print(message)
inline fun print(message: Char) = stdout.print(message)
inline fun print(message: Boolean) = stdout.print(message)
inline fun print(message: Float) = stdout.print(message)
inline fun print(message: Double) = stdout.print(message)
inline fun print(message: CharArray) = stdout.print(message)
inline fun println(message: Any?) = stdout.println(message)
inline fun println(message: Int) = stdout.println(message)
inline fun println(message: Long) = stdout.println(message)
inline fun println(message: Byte) = stdout.println(message)
inline fun println(message: Short) = stdout.println(message)
inline fun println(message: Char) = stdout.println(message)
inline fun println(message: Boolean) = stdout.println(message)
inline fun println(message: Float) = stdout.println(message)
inline fun println(message: Double) = stdout.println(message)
inline fun println(message: CharArray) = stdout.println(message)
inline fun println() = stdout.println()

inline fun nextInt() = stdin.nextInt()
inline fun nextLong() = stdin.nextLong()
inline fun nextChar() = stdin.nextChar()
inline fun next() = stdin.next()
inline fun nextLine() = stdin.nextLine()
inline fun nextIntArray(n: Int) = IntArray(n, { nextInt() })

class FastScanner(ins: InputStream): Closeable {
    val BUFFER_SIZE = 65536;
    val br: BufferedReader
    var end = false

    var len: Int = 0
    val buffer = CharArray(BUFFER_SIZE)
    var it: Int = 0

    init {
        br = BufferedReader(InputStreamReader(ins), BUFFER_SIZE)
    }

    constructor(file: String): this(FileInputStream(file))

    inline fun isLineBreaker(c: Char) = c == '\n'
    inline fun isDelimiter(c: Char) = c == ' ' || c == '\n' || c == '\r'

    inline fun ensureBuffer() {
        if (it == len) {
            it = 0
            len = br.read(buffer)
            if (len == -1) end = true
        }
    }

    inline fun moveNext() {
        while (!end) {
            ensureBuffer()
            if (!isDelimiter(buffer[it])) return
            while (it < len && isDelimiter(buffer[it])) it++;
        }
    }

    inline fun nextChar(): Char {
        moveNext()
        if (end) return (-1).toChar()
        return buffer[it++]
    }

    inline fun next(): String {
        moveNext()
        val sb = StringBuilder()
        while (!end) {
            val l = it
            while (++it < len && !isDelimiter(buffer[it]));
            sb.append(buffer, l, it - l)
            ensureBuffer()
            if (end || isDelimiter(buffer[it])) break;
        }
        return sb.toString()
    }

    inline fun nextInt(): Int {
        moveNext()
        var minus = true
        if (buffer[it] == '-') {
            it++
            minus = false
        }
        var result: Int = 0
        while (!end) {
            while (it < len && !isDelimiter(buffer[it])) {
                result *= 10
                result += (buffer[it] - '0').toInt()
                it++
            }
            ensureBuffer()
            if (end || isDelimiter(buffer[it])) break
        }
        return if (minus) result else -result
    }

    inline fun nextLong(): Long {
        moveNext()
        var minus = true
        if (buffer[it] == '-') {
            it++
            minus = false
        }
        var result: Long = 0
        while (!end) {
            while (it < len && !isDelimiter(buffer[it])) {
                result *= 10
                result += (buffer[it] - '0').toLong()
                it++
            }
            ensureBuffer()
            if (end || isDelimiter(buffer[it])) break
        }
        return if (minus) result else -result
    }

    inline fun nextLine(): String {
        moveNext()
        val sb = StringBuilder()
        while (!end) {
            val l = it
            while (++it < len && !isLineBreaker(buffer[it]));
            sb.append(buffer, l, it - l)
            ensureBuffer()
            if (end || isLineBreaker(buffer[it])) break;
        }
        return sb.toString()
    }

    override fun close() {
        br.close()
    }
}

fun main(args: Array<String>) {
    solve()
    stdin.close()
    stdout.close();
}

fun main() {
    fun readInts() = readLine()!!.split(" ").map(String::toInt)

    readLine()
    val sizes = readInts()
    print(
        when {
            sizes.last() == 0 -> "UP"
            sizes.last() == 15 -> "DOWN"
            sizes.size == 1 -> "-1"
            sizes.last() > sizes[sizes.lastIndex - 1] -> "UP"
            else -> "DOWN"
        }
    )
}

fun main() {
    val r = System.`in`.bufferedReader()
    val s = StringBuilder()
    val n = r.readLine()!!.toInt()
    val v = r.readLine()!!.split(" ").map { it.toInt() }
    if (n == 1) {
        println(-1)
    } else {
        val before = v[n - 2]
        val mid = v[n - 1]
        when {
            mid in (before + 1)..14 -> println("UP")
            mid > before && mid == 15 -> println("DOWN")
            mid in 1 until before -> println("DOWN")
            mid < before && mid == 0 -> println("UP")
        }
    }
}

fun main() {
    val r = System.`in`.bufferedReader()
    val s = StringBuilder()
    val n = r.readLine()!!.toInt()
    val v = r.readLine()!!.split(" ").map { it.toInt() }
    if (n==1) {
        println(-1)
    } else{
        val before = v[n-2]
        val mid = v[n-1]
        when{
            mid in (before + 1)..14 -> println("UP")
            mid<before&&mid==15 -> println("DOWN")
            mid in 1 until before -> println("DOWN")
            mid<before &&mid==0 -> println("UP")
        }
    }
}


Mancala is a game famous in the Middle East. It is played on a board that consists of 14 holes.   Initially, each hole has $$$a_i$$$ stones. When a player makes a move, he chooses a hole which contains a positive number of stones. He takes all the stones inside it and then redistributes these stones one by one in the next holes in a counter-clockwise direction.Note that the counter-clockwise order means if the player takes the stones from hole $$$i$$$, he will put one stone in the $$$(i+1)$$$-th hole, then in the $$$(i+2)$$$-th, etc. If he puts a stone in the $$$14$$$-th hole, the next one will be put in the first hole.After the move, the player collects all the stones from holes that contain even number of stones. The number of stones collected by player is the score, according to Resli.Resli is a famous Mancala player. He wants to know the maximum score he can obtain after one move.

The only line contains 14 integers $$$a_1, a_2, \ldots, a_{14}$$$ ($$$0 \leq a_i \leq 10^9$$$) — the number of stones in each hole. It is guaranteed that for any $$$i$$$ ($$$1\leq i \leq 14$$$) $$$a_i$$$ is either zero or odd, and there is at least one stone in the board.

Output one integer, the maximum possible score after one move.

NoteIn the first test case the board after the move from the hole with $$$7$$$ stones will look like 1 2 2 0 0 0 0 0 0 0 1 1 1 1. Then the player collects the even numbers and ends up with a score equal to $$$4$$$.

fun main() {
    fun readInts() = readLine()!!.split(" ").map(String::toInt)

    val numStones = readInts()
    var bestSol = 0L
    for (hole in 0 until 14) {
        val initialStonesInHole = numStones[hole]
        val stonesEach = initialStonesInHole / 14
        val extraStones = initialStonesInHole % 14
        var sol = 0L
        for (otherHole in hole + 1..hole + extraStones) {
            val stonesInHole = numStones[otherHole % 14].toLong() + stonesEach + 1
            if (stonesInHole and 1 == 0L) sol += stonesInHole
        }
        for (otherHole in hole + extraStones + 1..hole + 13) {
            val stonesInHole = numStones[otherHole % 14].toLong() + stonesEach
            if (stonesInHole and 1 == 0L) sol += stonesInHole
        }
        if (stonesEach and 1 == 0) sol += stonesEach
        if (sol > bestSol) bestSol = sol
    }
    print(bestSol)
}

fun main(args: Array<String>) {
    val a = System.`in`.reader().readText().trim().split(' ').map(String::toLong)
    println(a.mapIndexed { i, l ->
        a.mapIndexed { j, m ->
            if (i == j) m / 14
            else m + (l + (i - j + 14).rem(14)) / 14
        }.filter { it.rem(2) == 0L }.sum()
    }.max())
}

fun main() {
    fun readInts() = readLine()!!.split(" ").map(String::toInt)

    val numStones = readInts()
    var bestSol = 0L
    for (hole in 0 until 14) {
        val initialStonesInHole = numStones[hole]
        val stonesEach = initialStonesInHole / 14
        val extraStones = initialStonesInHole % 14
        var sol = 0L
        for (otherHole in hole + 1..hole + extraStones) {
            val stonesInHole = numStones[otherHole % 14].toLong() + stonesEach + 1
            if (stonesInHole and 1 == 0L) sol += stonesInHole
        }
        for (otherHole in hole + extraStones..hole + 13) {
            val stonesInHole = numStones[otherHole % 14].toLong() + stonesEach
            if (stonesInHole and 1 == 0L) sol += stonesInHole
        }
        if (stonesEach and 1 == 0) sol += stonesEach
        if (sol > bestSol) bestSol = sol
    }
    print(bestSol)
}


You are at a water bowling training. There are l people who play with their left hand, r people, who play with their right hand, and a ambidexters, who can play with left or right hand.The coach decided to form a team of even number of players, exactly half of the players should play with their right hand, and exactly half of the players should play with their left hand. One player should use only on of his hands.Ambidexters play as well with their right hand as with their left hand. In the team, an ambidexter can play with their left hand, or with their right hand.Please find the maximum possible size of the team, where equal number of players use their left and right hands, respectively.

The only line contains three integers l, r and a (0 ≤ l, r, a ≤ 100) — the number of left-handers, the number of right-handers and the number of ambidexters at the training.

Print a single even integer — the maximum number of players in the team. It is possible that the team can only have zero number of players.

NoteIn the first example you can form a team of 6 players. You should take the only left-hander and two ambidexters to play with left hand, and three right-handers to play with right hand. The only person left can't be taken into the team.In the second example you can form a team of 14 people. You have to take all five left-handers, all five right-handers, two ambidexters to play with left hand and two ambidexters to play with right hand.

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

fun main(args: Array<String>) {
    val array: IntArray = readLine()!!.split(' ').map { it.toInt() }.toIntArray()
    val min = min(array[0], array[1])

    if(min + array[2] <= max(array[0], array[1])) println((min + array[2]).times(2))
    else println(max(array[0], array[1]).plus(array[2] - abs(array[0] - array[1]) shr 1).times(2))
}

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

fun main(args: Array<String>) {
    val array: IntArray = readLine()!!.split(' ').map { it.toInt() }.toIntArray()

    val min = min(array[0], array[1])
    val max = max(array[0], array[1])

    if(min + array[2] <= max){
        println((min + array[2]).times(2))
    } else {
        var ambOut = array[2] - abs(array[0] - array[1])
        println(if ((array[0] == 0 || array[1] == 0) && array[2] == 0) 0 else max(array[0], array[1]).plus(ambOut shr 1).times(2))
    }
}

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

fun main(args: Array<String>) {
    val array: IntArray = readLine()!!.split(' ').map { it.toInt() }.toIntArray()
    val min = min(array[0], array[1])

    if((array[0] == 0 || array[1] == 0) && array[2] == 0) println(0)
    else if(min + array[2] <= max(array[0], array[1])) println((min + array[2]).times(2))
    else println(max(array[0], array[1]).plus(array[2] - abs(array[0] - array[1]) shr 1).times(2))
}

import java.lang.Math.abs
import java.util.*

/**
 * Created by SitaoLiao on 3/11/18.
 */
fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`);

    val user_input = scanner.nextLine().split(" ").map{ it.toInt() };

    var diff = user_input[0] - user_input[1];

    val ans: Int

    if( diff > 0 ){
        if( diff >= user_input[2] ){
            ans = user_input[1] + user_input[2]
        } else {
            ans = user_input[0] + (user_input[2]-diff)/2
        }
    } else {
        diff = abs(diff)
        if( diff >= user_input[2] ){
            ans = user_input[0] + user_input[2]
        } else {
            ans = user_input[1] + (user_input[2]-diff)/2
        }
    }

    println(ans*2)
}

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

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 l = reader.nextInt()
    val r = reader.nextInt()
    val a = reader.nextInt()

    var ans = 0

    for (i in 0..a) {
        val t = min(l + i, r + a - i)
        ans = max(ans, t)
    }
    writer.println(2 * 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
    }
}

fun min(a: Int, b:Int): Int{
    return if (a > b) b else a
}
fun main(args: Array<String>){

    var (l,p,a) = readLine().toString().split(" ").map{x -> x.toInt()}

    while(l!=p&&a>0){

        if(l<p){
            l++
            a--
        } else {
            p++
            a--
        }
    }
    while(a>1){
        l++
        p++
        a-=2
    }

    print(min(l,p)*2)

}

fun main() {
    fun readInts() = readLine()!!.split(" ").map(String::toInt)

    var (l, r, a) = readInts()
    var (min, max) = if (l <= r) l to r else r to l
    if (min + a < max) {
        min += a
        a = 0
    } else {
        val diff = max - min
        min = max
        a -= diff
    }
    print((kotlin.math.min(min, max) + a / 2) * 2)
}

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

fun main(args: Array<String>) {
    val line = BufferedReader(InputStreamReader(System.`in`)).readLine().split(' ')

    var l = line[0].toInt()
    var r = line[1].toInt()
    var a = line[2].toInt()

    while (a > 0 && r != l) {
        a--
        when {
            r > l -> l++
            l > r -> r++
        }
    }

    if (r == l) {
        while (a > 0) {
            a--
            if (a % 2 == 0) r++ else l++
        }
    }
    if (l == 0 || r == 0) return println(0)

    while (l != r) {
        when {
            l > r -> l--
            l < r -> r--
        }
    }

    println(l + r)
}

fun main(arg: Array<String>){
	var (L, R, A) = readLine().toString().split(" ").map {x -> x.toInt()}
	var teamN = 0
	val pmaxL = L + A
	val pmaxR = R + A
	val maxTeam = if (pmaxR > pmaxL) pmaxL else pmaxR
	if (maxTeam == 0){
		println(0)
		return
	}
//	println("Max team is: $maxTeam")
	var teamL: Int = 0
	var teamR: Int = 0

	while((R+A>0) and (L+A>0)){
//		println("Before. R:$R, L:$L, A:$A, TL: $teamL, TR: $teamR")
		if(L>R){
			if (R>0){
				teamR+=1
				R-=1
			}else{
				teamR+=1
				A-=1
			}

			if (L>0){
				teamL+=1
				L-=1
			}else{
				teamL+=1
				A-=1
			}

		}else{
			if (L>0){
				teamL+=1
				L-=1
			}else{
				teamL+=1
				A-=1
			}

			if (R>0){
				teamR+=1
				R-=1
			}else{
				teamR+=1
				A-=1
			}

		}

		if(A < 0){
			teamR -= 1
			teamL -= 1
			break
		}

//		println("Before. R:$R, L:$L, A:$A, TL: $teamL, TR: $teamR")

	}

	println(teamL + teamR)
}

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

fun main(args: Array<String>) {

    val array: IntArray = readLine()!!.split(' ').map { it.toInt() }.toIntArray()
    val min = min(array[0], array[1])

    if(array[0] == 0 || array[1] == 0 && array[2] == 0) println(0)
    else if(min + array[2] <= max(array[0], array[1])) println((min + array[2]).times(2))
    else println(max(array[0], array[1]).plus(array[2] - abs(array[0] - array[1]) shr 1).times(2))

}

import kotlin.math.abs
import kotlin.math.max

fun main(args: Array<String>) {
    val array: IntArray = readLine()!!.split(' ').map { it.toInt() }.toIntArray()
    var ambOut = array[2] - abs(array[0] - array[1])
    println(if((array[0] == 0 || array[1] == 0) && array[2] == 0) 0 else max(array[0], array[1]).plus(ambOut shr 1).times(2))
}

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

fun main(args: Array<String>) {
    val line = BufferedReader(InputStreamReader(System.`in`)).readLine().split(' ')

    var l = line[0].toInt()
    var r = line[1].toInt()
    var a = line[2].toInt()

    while (a > 0 && r != l) {
        a--
        if (r > l) l++ else if (l > r) r++
    }

    if (r == l) {
        while (a > 0) {
            a--
            if (a % 2 == 0) r++ else l++
        }
    }
    if (l == 0 || r == 0) return println(0)

    var result = l + r
    if (result % 2 != 0) result--
    println(result)
}


You are given a sequence a consisting of n integers. You may partition this sequence into two sequences b and c in such a way that every element belongs exactly to one of these sequences. Let B be the sum of elements belonging to b, and C be the sum of elements belonging to c (if some of these sequences is empty, then its sum is 0). What is the maximum possible value of B - C?

The first line contains one integer n (1 ≤ n ≤ 100) — the number of elements in a. The second line contains n integers a1, a2, ..., an ( - 100 ≤ ai ≤ 100) — the elements of sequence a.

Print the maximum possible value of B - C, where B is the sum of elements of sequence b, and C is the sum of elements of sequence c.

NoteIn the first example we may choose b = {1, 0}, c = { - 2}. Then B = 1, C =  - 2, B - C = 3.In the second example we choose b = {16, 23, 16, 15, 42, 8}, c = {} (an empty sequence). Then B = 120, C = 0, B - C = 120.

fun main() {
    val r = System.`in`.bufferedReader()
    val s1 = StringBuilder()
    val n = r.readLine()!!.toInt()
    //val (m, n) = r.readLine()!!.split(" ").map { it.toInt() }
    val v = r.readLine()!!.split(" ").map { it.toInt() }.map { if (it<0) -it else it }.sum()
    println(v)

}

fun main(args: Array<String>) {
    var n = readLine()!!.toInt()
    var a = readLine()!!.split(' ')
    var B = 0
    var C = 0
    for (i in 0 until a.size){
        if (a[i].toInt() >= 0) {
            B += a[i].toInt()
        }
        else{
            C += a[i].toInt()
        }
    }
    print(B-C)
}

import java.io.PrintWriter
import kotlin.math.*

fun main() {
    io.apply {

        val n = int
        val d = ints(n)
        val ans = d.map { abs(it) }.sum()
        cout .. ans .. nl

    }.cout.flush()
}

// @formatter:off
private val io = object {
    private val `in` = System.`in`
    private fun ll(): Long {
        var x: Int; var q = false; var n = 0L; do x = `in`.read() while (x < 33); if (x == 45) { q = true; x = `in`.read() }
        do { n = n * 10 - x + 48; x = `in`.read() } while (x > 32); return if (q) n else -n
    }
    val int get() = ll().toInt(); val long get() = ll()
    fun ints(n: Int = int): IntArray { return IntArray(n) { int } }
    fun ints1(n: Int = int): IntArray { return IntArray(n) { int - 1 } }
    val cout = PrintWriter(System.out); val nl = "\n"
    private var buf = CharArray(32)
    private var bufSize = 32
    fun str(expect: Int = 32): String {
        var ix = 0
        var x: Int
        if (bufSize < expect)
            buf = CharArray(expect)
        do x = `in`.read() while (x < 33)
        do {
            if (ix == bufSize) { bufSize *= 2; buf = buf.copyOf(bufSize) }
            buf[ix++] = x.toChar()
            x = `in`.read()
        } while (x > 32)
        return java.lang.String.copyValueOf(buf, 0, ix)
    }
    operator fun PrintWriter.rangeTo(a: Int): PrintWriter { print(a); print(" "); return this }
    operator fun PrintWriter.rangeTo(a: Long): PrintWriter { print(a); print(" "); return this }
    operator fun PrintWriter.rangeTo(a: IntArray): PrintWriter { a.forEach { print(it); print(" ") }; return this }
    operator fun PrintWriter.rangeTo(a: String): PrintWriter { write(a); return this }
} // @formatter:on

/* ----------- */

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

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

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 a = reader.nextArrayInt(n)
    val ans = a.filter { it > 0 }.sum() - a.filter { it < 0 }.sum()
    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.*

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

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 a = reader.nextArrayInt(n)
    val ans = a.map {
        if (it < 0) {
            -it
        } else {
            it
        }
    }.sum()
//            a.filter { it > 0 }.sum() - a.filter { it < 0 }.sum()
    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 kotlin.math.abs

fun main(args: Array<String>) {
    val z = java.util.Scanner(System.`in`)
    val n = z.nextInt()
    var sum = 0
    var a = 0
    for (i in 1..n)
        sum+=abs(z.nextInt())
    println(sum)
}

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

fun PrintWriter.solve() {
    val n = nextInt()
    println((1..n).map { abs(nextInt()) }.sum())
}

fun main(args: Array<String>) {
    PrintWriter(System.out, false).use { it.solve() }
}

val br = BufferedReader(InputStreamReader(System.`in`))
var stok = StringTokenizer("")

fun nextToken(): String? {
    while (!stok.hasMoreTokens()) {
        val s = br.readLine() ?: return null
        stok = StringTokenizer(s)
    }
    return stok.nextToken()
}

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

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

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

fun main(args: Array<String>) {
    System.`in`.bufferedReader().use {
        val n = it.readLine().toInt()
        val parts = it.readLine().split(' ')
        val a = IntArray(n, { i -> parts[i].toInt() })

        a.sort()

        var b = 0
        var c = 0
        var i = 0
        while (i < n && a[i] < 0)
            c += a[i++]
        while (i < n)
            b += a[i++]

        println(b - c)
    }
}

fun main(args: Array<String>)
{
    val n = readLine()!!.toInt()
    val inp = readLine()!!.split(' ').map(String::toInt)
    val sneg = inp.filter({i -> i < 0}).sum()
    val spos = inp.filter({i -> i > 0}).sum()
    println(spos - sneg)
}

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

    var count  = readLine()!!.toInt()
    var arr = readLine()!!.split(' ')
    var B = 0
    var C = 0
    var i = 0
    repeat(count)
    {
        val X = arr[i].toInt()
        if(X > 0) B += X
        else C += X
        i++
    }
     println(B - C)

}

import kotlin.math.absoluteValue

fun main() {
    readLine()
    print(readLine()!!.split(" ").map { it.toInt().absoluteValue }.sum())
}

fun main(args:Array<String>) {
  val n = readLine()!!
  val (A,B) = (0..1).map { mutableListOf<Int>() }

  readLine()!!.split(" ").map(String::toInt).map {
    if( it > 0 ) A.add(it) else B.add(it)
  }
  println( A.sum() - B.sum() )
}

import java.util.*

class A {
    fun run(scan: Scanner) {
        val count = scan.nextInt()
        var sumB = 0
        var sumC = 0
        repeat(count){
            val cur = scan.nextInt()
            if(cur > 0)
                sumB += cur
            else sumC += cur
        }
        println(sumB - sumC)
    }
}

fun main(args: Array<String>) {
    A().run(Scanner(System.`in`))
}

import java.util.Scanner
import kotlin.math.abs
import kotlin.math.max

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

    val n = reader.nextInt()
    var arr = Array(n) {0}
    var sum = 0

    for(i in 0..n-1) {
        arr[i] = reader.nextInt()
        sum += abs(arr[i])
    }
    println(sum)
}

import java.io.PrintWriter
import kotlin.math.*

fun main() {
    io.apply {

        val n = int
        val d = ints(n)
        var cur = d.sum()
        var mx = abs(cur)
        for (i in n - 1 downTo 0) {
            cur -= d[i] * 2
            mx = max(abs(cur), mx)
        }

        cout .. mx .. nl

    }.cout.flush()
}

// @formatter:off
private val io = object {
    private val `in` = System.`in`
    private fun ll(): Long {
        var x: Int; var q = false; var n = 0L; do x = `in`.read() while (x < 33); if (x == 45) { q = true; x = `in`.read() }
        do { n = n * 10 - x + 48; x = `in`.read() } while (x > 32); return if (q) n else -n
    }
    val int get() = ll().toInt(); val long get() = ll()
    fun ints(n: Int = int): IntArray { return IntArray(n) { int } }
    fun ints1(n: Int = int): IntArray { return IntArray(n) { int - 1 } }
    val cout = PrintWriter(System.out); val nl = "\n"
    private var buf = CharArray(32)
    private var bufSize = 32
    fun str(expect: Int = 32): String {
        var ix = 0
        var x: Int
        if (bufSize < expect)
            buf = CharArray(expect)
        do x = `in`.read() while (x < 33)
        do {
            if (ix == bufSize) { bufSize *= 2; buf = buf.copyOf(bufSize) }
            buf[ix++] = x.toChar()
            x = `in`.read()
        } while (x > 32)
        return java.lang.String.copyValueOf(buf, 0, ix)
    }
    operator fun PrintWriter.rangeTo(a: Int): PrintWriter { print(a); print(" "); return this }
    operator fun PrintWriter.rangeTo(a: Long): PrintWriter { print(a); print(" "); return this }
    operator fun PrintWriter.rangeTo(a: IntArray): PrintWriter { a.forEach { print(it); print(" ") }; return this }
    operator fun PrintWriter.rangeTo(a: String): PrintWriter { write(a); return this }
} // @formatter:on

/* ----------- */

import java.io.PrintWriter
import kotlin.math.*

fun main() {
    io.apply {

        val n = int
        val d = ints(n)
        var cur = d.sum()
        var mx = cur
        for (i in n - 1 downTo 0) {
            cur -= d[i] * 2
            mx = max(cur, mx)
        }

        cout .. mx .. nl

    }.cout.flush()
}

// @formatter:off
private val io = object {
    private val `in` = System.`in`
    private fun ll(): Long {
        var x: Int; var q = false; var n = 0L; do x = `in`.read() while (x < 33); if (x == 45) { q = true; x = `in`.read() }
        do { n = n * 10 - x + 48; x = `in`.read() } while (x > 32); return if (q) n else -n
    }
    val int get() = ll().toInt(); val long get() = ll()
    fun ints(n: Int = int): IntArray { return IntArray(n) { int } }
    fun ints1(n: Int = int): IntArray { return IntArray(n) { int - 1 } }
    val cout = PrintWriter(System.out); val nl = "\n"
    private var buf = CharArray(32)
    private var bufSize = 32
    fun str(expect: Int = 32): String {
        var ix = 0
        var x: Int
        if (bufSize < expect)
            buf = CharArray(expect)
        do x = `in`.read() while (x < 33)
        do {
            if (ix == bufSize) { bufSize *= 2; buf = buf.copyOf(bufSize) }
            buf[ix++] = x.toChar()
            x = `in`.read()
        } while (x > 32)
        return java.lang.String.copyValueOf(buf, 0, ix)
    }
    operator fun PrintWriter.rangeTo(a: Int): PrintWriter { print(a); print(" "); return this }
    operator fun PrintWriter.rangeTo(a: Long): PrintWriter { print(a); print(" "); return this }
    operator fun PrintWriter.rangeTo(a: IntArray): PrintWriter { a.forEach { print(it); print(" ") }; return this }
    operator fun PrintWriter.rangeTo(a: String): PrintWriter { write(a); return this }
} // @formatter:on

/* ----------- */

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

fun PrintWriter.solve() {
    val n = nextInt()
    println((1..n).map { nextInt() }.sum())
}

fun main(args: Array<String>) {
    PrintWriter(System.out, false).use { it.solve() }
}

val br = BufferedReader(InputStreamReader(System.`in`))
var stok = StringTokenizer("")

fun nextToken(): String? {
    while (!stok.hasMoreTokens()) {
        val s = br.readLine() ?: return null
        stok = StringTokenizer(s)
    }
    return stok.nextToken()
}

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

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

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