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)
}

C++: #include<iostream>
using namespace std;	
 
	int main(){
		int goke;
		int hon;
		int count=0;

	while(true){
		if(count==0){
		cin>>goke;
		if(goke==0){
		break;
		}
	count++; 
		}else{
		cin>>hon;
		goke-=hon;
		count++;
		}
		if(count==10){
		cout<<goke<<'\n';
		count=0;
		}
	}
	return 0;
}

C++: #include<stdio.h>
int main()
{
	int i,n,c,s=0;
	scanf("%d",&n);
	for(i=0;i<9;i++){
		scanf("%d",&c);
		s+=c;
	}
	printf("%d\n",n-s);
	return 0;
}

C++: #include<stdio.h>
int main()
{
  int sum,one,i;
  scanf("%d",&sum);
  for(i=0;i<9;i++){
    scanf("%d",&one);
    sum-=one;
  }
  printf("%d\n",sum);
  return 0;
}

C++: #include<iostream>
using namespace std;

int main () {
    int n,m,i;
    while (cin >> n,n)
    for (i=0;i<9;i++) {
        cin >> m;
        n-=m;
    }
    cout << n << endl;
}

C++: 
#include <iostream>
using namespace std;

int main(int argc, const char * argv[]) {
    
    int nyuuryoku[6][10];
    int print[6];
    int a=0;
    int sum=0;
    
    for(int i=0;i<6;i++){
        for(int j=0;j<10;j++){
            cin >> nyuuryoku[i][j];
            if(j==0){
                if(nyuuryoku[i][j]==0){
                    a=1;
                    break;
                }
            }
        }
        if(a==1){
            break;
        }
    }
    
    a=0;
    
    for(int i=0;i<6;i++){
        
        if(nyuuryoku[i][0]==0){
            a=i;
            break;
        }
        
        sum=0;
        for(int j=1;j<10;j++){
            sum=sum+nyuuryoku[i][j];
        }
        print[i]=nyuuryoku[i][0]-sum;
        
        
    }
    
    for(int i=0;i<a;i++){
        cout << print[i] << endl;
        
    }
    
    return 0;
}

C++: #include <bits/stdc++.h>
#define fo(i,a) for(i = 0;i < a;i++)
using namespace std;
int main(void)
{
	int n,o[9]={0},t=0,i;
	
	cin >> n ;
	while(n != 0){
		fo(i,9) cin >> o[i] ;
		t = accumulate(o,o + 9,0) ;
		cout << n - t << endl ;
		cin >> n ;
	}
	
	return 0 ;
}

C++: #include <iostream>
using namespace std;
int main()
{
	while(1)
	{
		int n,tmp; cin >> n;
		if(!n) break;
		for(int i=0;i<9;i++) {cin >> tmp; n-=tmp;}
		cout << n << endl;
	}
}

C++: 
#include <stdio.h>
#include <algorithm>

using namespace std;

int main() {

	for (;;) {
		int Sum;

		scanf("%d", &Sum);
		if (!Sum) break;

		for (int i = 0; i < 9; i++) {
			int t;
			scanf("%d", &t);
			Sum -= t;
		}

		printf("%d\n", Sum);
	}

	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;

int main(){
  int s,a;
  while(cin >> s){
    if(s==0)break;
    cin >> s;
    for(int i=0;i<9;i++){
      cin >> a;
      s -= a;
    }
    cout << s << endl;
  }
}

C++: #include<iostream>
using namespace std;
int main(){
while(1){
int a,b;
cin>>a;
if(a==0){break;}
for(int i = 0;i<9;i++){
cin>>b;
a-=b;
}
cout<<a<<endl;
}
return 0;
}

C++: // 2011/09/27 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int sum;
		cin >> sum;
		if(sum==0)
			break;

		for(int i=0; i<9; i++){
			int n;
			cin >> n;
			sum -= n;
		}

		cout << sum << endl;
	}

	return 0;
}

C++: #include<stdio.h>
int main()
{
  int sum,one,i;
  scanf("%d",&sum);
sum=0;
  for(i=0;i<9;i++){
    scanf("%d",&one);
    sum-=one;
  }
  printf("%d\n",sum);
  return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
    int p,t;
    while(cin>>p,p){
        int sum=0;
        for(int i=0;i<9;++i){
            cin>>t;
            sum += t;
        }
        cout<<p-sum<<endl;
    }
    return 0;
}

C++: #include <iostream>
using namespace std;

int main(void){
  int ans;
  while(cin>>ans){
    if (ans==0) break;
    for (int i=0; i<9; i++){
      int t;
      cin >> t;
      ans -= t;
    }
    cout << ans << endl;
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int sum,a;
  while(cin>>sum&&sum){
    for(int i=0;i<9;i++)cin>>a,sum-=a;
    cout<<sum<<endl;
  }
  return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int ans,a;
	while(1){
		cin>>ans;
		if(ans==0)
		break;
		for(int i=0;i<9;i++){
		cin>>a;
		ans-=a;
		}
		cout<<ans<<endl;
	}
return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  unsigned long long int s,book,books;
  while(cin>>s){
    if(s==0) break;
    books = 0;
    for(int i=0;i<9;i++){
      cin >> book;
      books += book;
    }
    cout << s - books << endl;
  }
  return 0;
}

C++: #include<cstdio>
int main(){
    int ins;
    int sum;
    scanf("%d",&sum);
    for(;;){
        scanf("%d",&ins);
        if(ins==0)break;
        sum-=ins;
    }
    printf("%d\n",sum);
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int amount,sum=0,a;
	while(1){
	cin>>amount;
	if(amount==0){
		break;
	}
	for(int i=0;i<9;++i){
		cin>>a;
		sum+=a;
	}
	cout<<amount-sum<<endl;
	
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main() {
    vector<int> a(60);
    for(int i=0;;i++){ 
       
        cin>>a[i];
        if(a[i]==0) break;
    } 
    int n;
    for(int i=0;i<a.size();i++){
        if(a[i]==0) break;
        if(i%10==0) n=a[i];
        else n-=a[i];
        if(i%10==9){
            cout<<n<<endl;
        }
    }
}

C++: #include <iostream>
using namespace std;
int main() {
	int a;
	cin >> a;
	while (a) {
		if (a == 0) break;
		int b = 0;
		for (int i = 0; i < 9; ++i) {
			int j;
			cin >> j;
			b = b + j;
		}
		cout << a - b << endl;
	}
	return 0;
}

C++: #include <stdio.h>

int main(void){
	int i,j,k;
	while(scanf("%d",&i),i){
		for(k=0;k<10;k++)
			scanf("%d",&j),i-=j;
		printf("%d\n",i);
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int main(){
 int h,e;
 while(1){
    cin>>h;
    if(h==0) break;
    for(int i=0;i<9;i++){
       cin>>e;
       h-=e;
    }
      cout<<h<<endl;
 }
   return 0;
}

C++: #include <iostream>
using namespace std;
int main() {
	int a[9],b;
	cin>>b;
	for(int i=0;i<9;i++){
		cin>>a[i];
		b=b-a[i];
	}
	cout<<b<<endl;
	return 0;
}