import scala.math.{min,max}

object Main {
  val sc = new java.util.Scanner(System.in)
  def main(args: Array[String]) {
    while(true) {
      val s = sc.nextInt
      if(s == 0) return
      println(s - (1 to 9).map(_ => sc.nextInt).sum)
    }
  }
}