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 total;
	int books;
        int count=0;
       
	while(true){
         if(count==0){
           cin>>total;
           if(total==0){
               break;
           }
           count++;
          }else{
           cin>>books;
           total-=books;
           count++;
          }
         if(count==10){
           cout<<total<<'\n';
           count=0;
         }
	}
	return 0;
}

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

int main(){
	int a;
	int b[9];
	scanf("%d", &a);
	for (int i = 0; i < 9; i++){
		scanf("%d", &b[i]);
		a -= b[i];
	}
	printf("%d\n", a);

	return 0;
}

C++: #include<cstdio>
using namespace std;
int main(void)
{
	int i,x=0,kin,gou;
	
	while(1){
		scanf("%d",&gou);
			for(i=0;i<9;i++){
				scanf("%d",&kin);
				x+=kin;
			}
			gou=gou-x;
			printf("%d\n",gou);
			break;
	}
	return 0;
}

C++: #include<iostream>

using namespace std;

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

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

int main(){
    int all,buy;
    cin >> all;
    while(1){
        cin >> buy;
        if(buy == 0){
            break;
        }
        all -= buy;
    }
    cout << all << endl;
}

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

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

int main(){
  int a[11]={};
  
  while(1)
    {
      cin >> a[0];
      if(a[0]==0)break;
      
  for(int i =1;i < 10;i++)
    {
      cin >> a[i];
    }
  for(int j =1;j < 11;j++)
    {
      a[0] -= a[j];
    }
  cout << a[0] << endl;
    }
}

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

C++: #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<set>
#include<vector>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define ALL(C)     (C).begin(),(C).end()

main(){
  int t;
  while(cin>>t && t){
    rep(i,9){
      int a;cin>>a;t-=a;
    }
    cout << t << endl;
  }
  return false;
}

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

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int n;cin>>n;
  while(n!=0)
  {
    vector<int> val(9,0);
    int i;
    rep(i,9)cin>>val[i];
    rep(i,9)n-=val[i];
    cout<<n<<endl;
    cin>>n;
  }
}

C++: #include<stdio.h>
int main()
{
	int sum, wa = 0, goukei[100] = { 0 }, i, r, cnt;
	while (1) {
		scanf("%d", &sum);
		if (sum == 0) {
			break;
		}
		for (i = 0; i < 9; i++) {
			scanf("%d", &r);
			wa = wa + r;
		}
		goukei[i] = sum - wa;
		cnt++;
	}
	for (i = 0; i < cnt; i++) {
		printf("%d\n", goukei[i]);
	}
}

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

int main(){

  int books;
  int cnt,res;

  while(1){
    cnt=0;
    cin >> res;
    if(res == 0) break;
    for(int i = 0; i < 9; i++){
      cin >> books;
      cnt+=books;
      //    if(i == 9) break;
    }
    
    books = res - cnt;
    cout << books << endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main(){
  int a,b;
  while(scanf("%d",&a)&&a){
    for(int i=0;i<9;i++){
      scanf("%d",&b);
      a-=b;
    }
    printf("%d\n",a);
  }
}

C++: #include<iostream>

using namespace std;
int main(){
	for(int i=0;i<5;i++){
		int B[10];
		for(int i=0;i<10;i++){
			cin >> B[i];
			if(B[i] == 0){
				return 0; //プログラムの強制終了
			}
		}

		int sum = 0;

		for(int i=1;i<10;i++){
			sum += B[i];
		}

		cout << B[0] - sum << endl;
	}
	return 0;

}

C++: #include<cstdio>
using namespace std;
int main(){

  int n,m;

  scanf("%d",&n);

  while(n != 0){
    
    for(int i=0;i<9;i++){
      scanf("%d",&m);
      n -= m;
    }

    printf("%d\n",n);
    
    scanf("%d",&n);
  }

  return (0);
}

C++: #include <stdio.h>

int main(){
	int sum, flg = 0, hiku;
	scanf("%d", &sum);
	while(flg == 0){
		scanf("%d", &hiku);
		if(hiku == 0) flg = 1;
		sum -= hiku;
	}
	printf("%d", sum);
	return 0;
}

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

int main(){
int books=1;
int book=0;
int i=0;
while(books!=0){
cin>>books;
if(books==0){
break;
}
while(i<=8){
cin>>book;
books-=book;
i++;
}
if(i==9){
cout<<books<<'\n';
i=0;
}

C++: #include<stdio.h>

int main()
{
	int total;
	int sum = 0;
	int a;
	
	for(;;){
		total = 0;
		scanf("%d",&total);
		if(total == 0){
			break;
		}
		
		for(int i = 0; i < 9; i++){
			scanf("%d",&a);
			sum += a;
		}
		
		printf("%d\n",total - sum);
	}
	return 0;
}

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

C++: #include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i;
  int a,b;
  while(cin>>a&&a){
    for(i=0;i<9;i++){
      cin>>b;
      a-=b;
    }
    cout<<a<<endl;
  }
  return 0;
}

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

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