Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	io := NewIo()
	defer io.Flush()
	for {
		sum := io.NextInt();
		if sum == 0 {
			break
		}
		for i := 0; i < 9; i++ {
			sum -= io.NextInt()
		}
		io.Println(sum)
	}
}

// I/O template
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buff []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buff = append(buff, line...)
		if !isPrefix {
			break
		}
	}
	return string(buff)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	s := io.tokens[io.nextToken]
	io.nextToken++
	return s
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntSlice(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func (io *Io) PrintStringSlice(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func ExampleIo() {
	io := NewIo()
	defer io.Flush()
	a := make([]int, 0, 3)
	a[0], a[1], a[2] = io.NextInt(), io.NextInt(), io.NextInt()
	io.Println(a)
	io.PrintIntSlice(a)
	Log("io", a)
}

Python: #A問題
ans = 0
for i in range(50):
    a = int(input())
    if i%10 == 0 and a!=0:
        ans+=a
    elif a != 0:
        ans-=a
        if i%10 == 9:
            print(ans)
            ans = 0
    else:
        break

Python: def solve(sum_val):
    tmp = 0
    for x in range(9):
        tmp += int(input())
    print(sum_val - tmp)


ipt = int(input())
while ipt != 0:
    solve(ipt)
    ipt = int(input())

Python: n=int(input())
l=[]
for i in range(9):
	tmp=int(input())
	l.append(tmp)
	ans=0
for i in range(9):
	ans+=l[i]
	a=n-ans
print(a)

Python: while True:
    total = int(input())
    if total == 0:
        break
    prices = [int(input()) for _ in range(9)]
    print(total - sum(prices))

Python: def main():
    while True:
        c = int(input())
        if c == 0:
            return
        print(c - sum([int(input()) for _ in range(9)]))


if __name__ == '__main__':
    main()

Python: while True:
    k = int(input())
    if k == 0:
        exit()
    else:
        for i in range(9):
            k -= int(input())
        print(k)

Python: while True :
    n = int(input())
    if n == 0 :
        break
    
    S = 0
    for i in range(9) :
        S += int(input())
    print(n - S)

Python: N=0
for i in range(7):
  N=int(input())
  if N==0:
    break
  for j in range(9):
    N=N-int(input())
  print(N)

Python: while 1:
    total = int(input())
    if total == 0:
        break

    tmp = 0
    for _ in range(9):
        tmp += int(input())

    print(total - tmp)

Python: while 1:
    l = []
    sm = int(input())
    if sm == 0:
        break
    for i in range(9):
        l.append(int(input()))
    print(sm - sum(l))

Python: while 1:
    ans=int(input())
    if ans==0:break
    for i in range(9):
        ans-=int(input())
    print(ans)

Python: N=int(input())
l=[]
for i in range(9):
	tmp=int(input())
	l.append(tmp)
ans=0
for i in range(9):
	ans+=l[i]
	a=N-ans
print(a)

Python: while True:
  n = int(input())
  if not n: break
  print(n - sum([int(input()) for _ in range(9)]))

Python: n=int(input())
l=[]
for i in range(9):
	tmp=int(input())
	l.append(tmp)
	ans=0
for i in range(9):
	ans+=l[i]
print(n-ans)

Python: # AOJ 0543: Receipt
# Python3 2018.7.1 bal4u

import sys
from sys import stdin
input = stdin.readline

while True:
	s = int(input())
	if s == 0: break
	print(s-sum([int(input()) for i in range(9)]))

Python: while True:
    s = int(input())
    if s == 0: break
    for _ in range(9):
        s -= int(input())
    print(s)

Python: n=int(input())
l=[]
for i in range(9):
	tmp=int(input())
	l.append(tmp)
ans=0
for i in range(9):
	ans+=l[i]
	a=n-ans
print(a)

Python: while True:
    t = int(input())
    if t == 0:
        break
    b = [int(input()) for i in range(9)]
    print(t-sum(b))

Python: while True:
    s = int(input())
    if (s == 0):
        break

    price = [int(input()) for i in range(9)]
    print(s - sum(price))

Python: while True:
    kei = int(input())
    if kei == 0:
        break
    else:
        for num in range(9):
            i = int(input())
            kei -= i
        print(kei)

Python: for e in iter(input,'0'):
 print(int(e)-sum(int(input())for _ in[0]*9))

Python: n=int(input())
l=[]
for i in range(9):
	tmp=int(input())
	l.append(tmp)
	ans=0
for i in range(9):
	ans+=l[i]
	print(n-ans)

Python: J=[]
while True:
    sum=int(input())
    if sum==0:
        for k in range(len(J)):
            print(J[k])
        break
    else:
        a=int(input())
        b=int(input())
        c=int(input())
        d=int(input())
        e=int(input())
        f=int(input())
        g=int(input())
        h=int(input())
        i=int(input())
        J.append(sum-a-b-c-d-e-f-g-h-i)

Python: while True:
	total=int(input())
	if total==0:exit(0)
	print(total-sum([int(input()) for _ in range(9)]))

Python: while 1:
    n=int(input())
    if n==0:break
    print(n-sum([int(input()) for _ in range(9)]))

Python: while True:
    s = int(input())
    li = []
    if s == 0:
        break
    for i in range(9):
        s -= int(input())
    print(s)

Python: while(1):
	N=int(input())
	if(N==0):
 	  exit()
	l=[]
	for i in range(9):
		tmp=int(input())
		l.append(tmp)
	ans=0
	for i in range(9):
		ans+=l[i]
		a=N-ans
	print(a)

Python: while True:
    sum_ = int(input())
    if not sum_:
        break
    ans = sum_ - sum([int(input())for _ in range(9)])
    print(ans)

Python: # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0543

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    while True:
        total = int(input())
        if total == 0:
            break
        books = [int(input()) for _ in range(9)]
        print(total - sum(books))


if __name__ == '__main__':
    main(sys.argv[1:])

Python: 


while True:

    a = int(input())

    if a == 0:
        break
    for i in range(9):

        b = int(input())

        a -= b

    print (a)

Python: while (True):

  total = int(input())

  if (total == 0):
    break

  others = 0
  for i in range(9):
    others += int(input())

  print(total-others)

Python: N=int(input())
l=[]
for i in range(9):
	tmp=int(input())
	l.append(tmp)
ans=0
for i in range(9):
	ans+=l[i]
	a=N-ans
print(a)

Python: su = int(input())
for i in range(9):
    n = int(input())
    su -= n
print(su)

Python: while True:
    su = int(input())
    if su == 0:
        break
    for i in range(9):
        n = int(input())
        su -= n
    print(su)

Python: b=True
while b:
	n=int(input())
	if n==0:
		break
	for i in range(9):
		n-=int(input())
	print(n)

Python: while True:
    p_sum=int(input())
    if p_sum==0:break
    price=[int(input())for i in range(9)]
    for p in price:
        p_sum-=p
    print(p_sum)

Python: while True:
    try:
        print(int(input())-sum([int(input()) for i in range(9)]))
    except:
        break

Python: while True:
    x = int(input())
    if x == 0:
        break
    for i in range(9):
        x -= int(input())
    print(x)