let () =
  let id x = x in
  let calc_9 () =
    let rec read_m n =
      if n == 0 then [] else (Scanf.scanf "%d\n" id)::(read_m (n-1))
    in
    let l = read_m 9 in
    List.fold_left (+) 0 l
  in
  let rec loop () =
    let total = Scanf.scanf "%d\n" id in
    if total == 0 then
      ()
    else
      let t9 = calc_9 () in
      Printf.printf "%d\n" (total - t9);
      loop ()
  in
  loop ()