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 a[11], i = 1;
	while (1){
		cin >> a[0];
		if(a[0] == 0){break;}
		while (1){
			cin >> a[i];
			if (a[i] == 0){break;}
			a[0] = a[0] - a[i];
			if (a[0] == 0){break;}
			i++;		
		}
		cout << a[0] << endl;
		i = 1;
	}
}

C++: #include <iostream>

using namespace std;

int main() {
  for (;;) {
    int sum;
    cin >> sum;
    if (!sum) return 0;
    for (int i = 0; i < 9; i++) {
      int p;
      cin >> p;
      sum -= p;
    }
    cout << sum << endl;
  }
}

C++: #include<stdio.h>

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

C++: #include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n;
    while(cin>>n,n){
        int t;
        rep(i,9){cin>>t;n-=t;}
        cout<<n<<endl;
    }
}

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

C++: #include <bits/stdc++.h>
#define rep(i,n) for (int i =0; i < (n); ++i)
using namespace std;

int main() {
        int T;
        int s;

        while(1) {
                cin >> T;
                if (T == 0) break;
                rep(i, 9) {
                        cin >> s;
                        T -= s;
                }
                cout << T << endl;
        }
        return 0;
}

C++: //2009年　情報オリンピック予選　1問目
#include<iostream>
using namespace std;
int main(){

	int a,sum=0,b;
	cin>>a;
	for(int i=0;i<9;i++){
	cin>>b;
	sum+=b;
	}

	cout<<a-sum<<endl;


	return 0;
}

C++: #include<iostream>

using namespace std;

 int main(){
    int sam,p[9];
    cin >> sam;
    for(int i = 0; i < 9; i++){
        cin >> p[i];
    }
    
    for(int i = 0; i < 9; i++){
        sam -= p[i];
    }
    
    cout << sam << endl;
}

C++: #include <cstdio>

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

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

int main() 
{ 
 int num; 
 int a;
 while(1){
  cin >>num; 
  if(num==0){
   break;}
  else
  {
  for(int i=1;i<10;i++)
    {
    cin>>a;
    num=num-a;
    }
  }
  cout<<num<<"\n";
 }
 return 0; 
}

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

C++: #include<iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <math.h>
using namespace std;
int tot,a;
	int main(){
		while(cin>>tot){
			if(tot==0){
			break;}
		for(int i=0;i<9;i++){
		cin>>a;tot-=a;}
		cout<<tot<<endl;}
		return 0;}

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

int main() {
  int total, price[10];
  while (1) {
    cin >> total;
    if (total == 0) break;

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

    cout << total - sum << endl;
  }

  return 0;
}

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

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

return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);++i)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int MOD=1e9+7;
const long long INF = 1LL << 60;
int gcd(int a,int b) { return b ? gcd(b,a%b) : a;}
int lcm(int a,int b) { return a/gcd(a,b)*b;}
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
void printb(unsigned int v) {
  unsigned int mask = (int)1 << (sizeof(v) * CHAR_BIT - 1);
  do putchar(mask & v ? '1' : '0');
  while (mask >>= 1);
}
void putb(unsigned int v) {putchar('0'), putchar('b'), printb(v), putchar('\n');}
#define ALL(W) (W).begin(),(W).end()

signed main(){
  int sum,res=0;
  while(cin >> sum && sum!=0){
    res=0;
    rep(i,9){
      int tmp;
      cin >> tmp;
      res+=tmp;
    }
    cout << sum-res << endl;
  }

  return 0;
}