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 <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <queue>

using namespace std;

int main(){

	int sum,minus_sum,tmp;

	while(true){
		scanf("%d",&sum);
		if(sum == 0)break;

		minus_sum = 0;

		for(int i = 0; i < 9; i++){
			scanf("%d",&tmp);
			minus_sum += tmp;
		}

		printf("%d\n",sum-minus_sum);

	}

	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int ans[10];
	int sum=0;
	int other=0;
	int a=0;
	int i=0;
	int j=0;
	
	while(1){
		cin>>sum;
		if(sum==0)break;
		for(i=0;i<9;i++){
			cin>>a;
			other+=a;
		}
		ans[j]=sum-other;
		sum=0;
		other=0;
		a=0;
		j++;
	}
	
	for(i=0;i<j;i++){
		cout<<ans[i]<<endl;
	}
}

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

int main() {
	int sum,x=1;
	while(x!=0){
		int price=0;	
		cin>>sum;
		for(int i=0;i<9;i++){
			int a=0;
			cin>>a;
			price=price+a;
			x=a;
		}
		cout<<sum-price<<endl;
	}
	
	
	return 0;
}

C++: //============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;
int N,A[9];
int main() {

	for(int j=0;j<5;j++){
		cin>>N;
		for(int i=0;i<9;i++){
			cin>>A[i];
			N-=A[i];
		}
		cout<<N<<endl;

	}

	return 0;
}

C++: #include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
    int a,sum = 0,memo = 0;
    
    while(1){
       cin >> sum;
       if(!sum) return 0;
       memo = 0;
        
        rep(i,0,9){
            cin >> a;
            memo += a;
        }
        
    cout << sum - memo << endl; 
    }
    
    
    
    return 0;
}

C++: #include <stdio.h>

main()
{
	int S,a,b,i;
	a=0;
	scanf("%d",&S);
	for(i=1;i<11;i++){
		scanf("%d",&b);
		a+=b;
	}
	printf("%d",S-a);
}

C++: #include<iostream>

int main(){
  int aa[10] = {0};
  int ans = 0, sum = 0;
  for(int i = 0; i < 10; i++)
    cin >> aa[i];
  for(int i = 1; i < 10; I++)
    sum += aa[i];
  ans = aa[0] - sum;
  cout << ans << endl;
  return 0;
}

C++: #include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
#define ENDL cout<<endl

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};



int main(){
    int s = 0;
    int ins = 0;
    int sum = 0;
    while(cin >> ins){
        if(s%10 == 0){
            if(s!= 0)COUT(sum);
            sum = ins;
        }else{
            sum -= ins;
        }
        s++;
        if(ins == 0)rt 0;
    }
    COUT(sum);
    return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

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

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

		cout << all << endl;
	}





}

C++: #include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  while(cin>>n,n){
    for(int i=0,k;i<9;i++){
      cin>>k;
      n-=k;
    }
    cout<<n<<endl;
  }
  return 0;
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int total,i,j;
	int books[9], res[10];
	
	j = 0;

	while(1){

		cin >> total;
		if(total == 0) break;
		for(i=0; i<9; i++) cin >> books[i];
		for(i=0; i<9; i++) total -= books[i];
		res[j] = total;
		j++;
	}
	
	j = 0;

	while(1){
		if(res[j] == 0) break;
		else	printf("%d\n", res[j]);
		j++;
	}

	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll sum;;
	while(cin>>sum, sum>0){
		rep(i, 9){
			ll temp; cin>>temp;
			sum-=temp;
		}
		cout << sum << endl;
	}
	return 0;
}

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

int main(){
  int total=0,book,totala=0,mach;
  while(true){
  cin>>total;
  if(total==0){
    break;
  }
  for(int i=1;i<=9;i++){
    cin>>book;
    totala=totala+book;
  }
  mach=total-totala;
  cout<<mach<<endl;
  }
  return 0;
}