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;

#define llong long long
#define inf 999999999
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef pair<int, int> P;
typedef pair<P, int> PP;
typedef pair<PP, int> PPP;
typedef struct data{
	int now;
	int cost;
}data;
int nh[4] = {1, 0, -1, 0};
int nw[4] = {0, 1, 0, -1};





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

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

int main(){
  int n,i,j,s;

  while(1){
    cin >> n;
    if(n==0)break;
    for(i=0;i<9;i++){
      cin >> s;
      n-=s;
    }
    cout << n << endl;

  }




}

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<<e<<endl;
 }
   return 0;
}

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

int main(){
    int N, x[10];
    int X = 0;

    for(int j=0;j < 5;j++){
      cin>>N;
      if(N == 0) break;
      
      for(int i=1;i < 10;i++){
        cin>>x[i];
        X += x[i];
      }
      cout<<N - X<<endl;
    }
    return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define EQ(a,b) (abs((a)-(b))<EPS)
int main()
{
	while(1)
	{
		int num;
		cin >> num;
		if(num==0)break;
		for(int i=0;i<9;i++)
		{
			int n;
			cin >> n;
			num-=n;
		}
		cout << num << endl;
	}
	return 0;
}

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

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

    return 0;
}

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

C++: #include<stdio.h>

int main(){
	int k;
	int x;
	int i;
while(1){	
        scanf("%d",&k);
        if(k==0)return 0;
	for(i=0;i<9;i++){
		scanf("%d",&x);
		k-=x;
	}
	printf("%d\n",k);
	return 0;
}
}

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

/** Problem0543 : Receipt **/
int main()
{
	int sum, tmp=0;
	cin>>sum;
	rep(i, 9) {
		int t; cin>>t;
		tmp += t;
	}
	cout << sum-tmp << endl;
}

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

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

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

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

        int total;
        int books[9];

        cin >> total;

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

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

        printf("%d\n", total);

        return 0;
}

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

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

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

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>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    rep(i,9){
      int in;
      cin>>in;
      n-=in;
    }
    cout<<n<<endl;;
  }
}