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>
#define Iset int i,j,l;
#define Fi for (i = 0; i < 9; i++)
using namespace std;

int main() {
	int a, b[11], c=0;
	
	Iset;
	cin >> a;
	start:
	Fi {
		cin >> b[i];
			c += b[i];
	}
	cout << a-c << endl;

	cin >> a ;
	if (a == 0) {
		goto end;
	}
	else {
		c = 0;
		goto start;
	}
	end:
	return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<cstring>
#include<set>
#include<map>
#include<vector>
#include<cmath>
#include<queue>
#include<cstdio>
#include<cstdlib>
#define reep(n1,n2,n3) for(int n1=n3;n1<n2;n1++)
#define rep(n1,n2) reep(n1,n2,0)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define INF 1e9
using namespace std;
typedef long long int lint;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<pair<int,int> > vp;
typedef pair<int,int> pi;
typedef pair<int,pair<int,int> > pii;
typedef vector<string> vs;
const double PI  = acos(-1.0);
int c[]={500,100,50,10,5,1};
int main(){
    int n;
    while(cin>>n,n){
        rep(i,9){
            int a;
            cin>>a;
            n-=a;
        }
        cout<<n<<endl;
    }
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
	int t,x,sum=0;
	while(1){
cin>>t;
	if(t==0)break;
	
for(int i=0;i<9;i++){
	cin>>x;
	sum=sum+x;
}

	cout<<t-sum<<endl;
}
return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  
  int money[9],all,sum;

  
  while(1){

    cin >>all;
    
    if(all == 0)break;

    sum=0;
    
    for(int i=0 ; i < 9 ; i++){
      cin >>money[i];
      sum+=money[i];
    }
    
    cout <<all-sum<<endl;
  }
  
  return 0;
}

C++: #include <stdio.h>

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

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

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

C++: #include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	while(cin>>n,n){
		rep(i,9){
			ll t; cin>>t;
			n-=t;
		}
		puta(n);
	}
	return 0;
}

C++: // 2012/12/10 Tazoe

#include <iostream>
using namespace std;

int main()
{
while(true){
	int T;
	cin >> T;

if(T==0)
break;

	int P[10];
	for(int i=0; i<9; i++){
		cin >> P[i];
	}

	P[9] = T;
	for(int i=0; i<9; i++){
		P[9] -= P[i];
	}

	cout << P[9] << '\n';
}

	return 0;
}

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

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

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

int main(){

  int books[10];
  int cnt=0,res;

  cin >> res;

  for(int i = 0; i < 9; i++){
    cin >> books[i];
    cnt+=books[i];
  }

  cout << res - cnt << endl;

  return 0;
}

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

int main()
{
	int n1,n2,n3,n4,n5,n6,n7,n8,n9,Kei;

	cin >> Kei;
	cin >> n1;
	cin >> n2;
	cin >> n3;
	cin >> n4;
	cin >> n5;
	cin >> n6;
	cin >> n7;
	cin >> n8;
	cin >> n9;
	cout << Kei-(n1+n2+n3+n4+n5+n6+n7+n8+n9) << endl;

	return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	int n, a;
	while (true) {
		int sum = 0;
		cin >> n;
		if (n == 0) {
			cin >> n; return 0;
		}
		for (int h = 0; h < 9; h++) {
			cin >> a;
			sum += a;
		}
		cout << n - sum << endl;
	}
	cin >> n;
}

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


int main(){
  
  int x1,x2,x3,x4,x5,x6,x7,x8,x9,x10;
  cin>>x1>>x2>>x3>>x4>>x5>>x6>>x7>>x8>>x9>>x10;


 cout<<x1-(x2+x3+x4+x5+x6+x7+x8+x9+x10)<<endl;



  return 0;
}