
fun main(args:Array<String>):Unit {
    while (true) {
        val n = readLine()!!.trim().toInt()
        if (n == 0) return
        val others = Array(9){readLine()!!.trim().toInt()}.sum()
        println(n - others)
    }
}
