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 <bits/stdc++.h>
using namespace std;

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

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

int main() {
	int all, b1, b2, b3, b4, b5, b6, b7, b8, b9;
	while (cin >> all >> b1 >> b2 >> b3 >> b4 >> b5 >> b6 >> b7 >> b8 >> b9) {
		if (all == 0) {
			break;
		}
		cout << all - b1 - b2 - b3 - b4 - b5 - b6 - b7 - b8 - b9 << endl;
	}
}

C++: #include<stdio.h>
int main(void)
{
	int x,a,b,c,d,e,f,g,h,i,j;
	scanf("%d %d %d %d %d %d %d %d %d %d",&x,&a,&b,&c,&d,&e,&f,&g,&h,&i);
	j=x-(a+b+c+d+e+f+g+h+i);
	printf("%d\n",j);
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std ;
int main()
{
    int total = 0 ;
    int money = 0 ;
    while(1)
    {
        cin >> total ;
        if (!total) break ;
        for ( int i = 0 ; i < 9 ; i++ )
        {
            cin >> money ;
            total -= money ;
        }
        cout << total << endl ;
    }
    return 0 ;
}

C++: #include <iostream>
using namespace std;
int main() {
	int a,b;

		if(a=0){
			break;
		}
	cin>>a;
	for(int i=0;i<9;i++){
		cin>>b;
		a=a-b;
	}
	cout<<a<<endl;
	return 0;
}

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){
           count<<total<<'\n';
         }
	}
	return 0;
}

C++: #include <iostream>
#include <stdio.h>
using namespace std;
int main() {
	while(true){
		int total;
		int hon;
		int booktotal=0;
		int book[9];
		int i=0;
		scanf("%d", &total);
		if(total==0) break;
		while(i<9){
			scanf("%d", &book[i]);
			booktotal = booktotal + book[i];
			i++;
		}
		hon = total - booktotal;
		printf("%d\n", hon);
	}
	return 0;
}

C++: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"
int main() {
	while (1) {
		int a; cin >> a;
		if (!a)break;

		for (int i = 0; i <9; ++i) {
			int b; cin >> b; a -= b;
		}
		cout << a << endl;
	}
	return 0;
}

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

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

int main(){
	int total;
	int books;

	for(int i=0;i<10;i++){
		if(i==0){
                   cin>>total;
                   if(total>10000){
                      break;
                   }
                }else{
                   cin>>books;
                   total-=books;
                }
	}
	cout>>total>>'\n';
	return 0;
}

C++: #include <iostream>
using namespace std;
int main() {
	int total;
	int hon;
	int booktotal=0;
	int book[9];
	int i=0;
	scanf("%d", &total);
	while(i<9){
		scanf("%d", &book[i]);
		booktotal = booktotal + book[i];
		i++;
	}
	hon = total - booktotal;
	printf("%d", hon);
	return 0;
}

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

C++: #include<iostream>

using namespace std;

int main(void){
  int val,input;
  while(cin>>val && val){
    for(int i=0;i<9;i++){
      cin>>input;
      val-=input;
    }
    cout<<val<<endl;
  }
  return 0;
}

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

int main(){
	int i,sou,ou,c;
	
	ou=0;
	scanf("%d",&sou);
	for(i=0;i<9;i++){
		scanf("%d",&c);
		ou+=c;
	}
	printf("%d\n",sou-ou);
}

C++: #include <bits/stdc++.h>  

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; --i)
#define INF (1 << 30)
#define MOD 1e9 + 7

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

int main() {
	int total;
	while(scanf("%d", &total), total) {
		int re[9];
		int tmp = 0;
		rep(i, 9) {
			scanf("%d", &re[i]);
			tmp += re[i];
		}
		printf("%d\n", total - tmp);
	}
	return 0;
}

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


return 0;
}