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 <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	int n;
	while(cin>>n,n){
		rep(i,9){
			int t;
			cin>>t;
			n-=t;
		}
		cout<<n<<endl;
	}
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

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

int main()
{
 int a; int b; int c; int d; int e; int f; int g; int h; int i; int j;
 cin >>a;
 cin >>b;
 cin >>c;
 cin >>d;
 cin >>e;
 cin >>f;
 cin >>g;
 cin >>h;
 cin >>i;
 cin >>j;
 cout<<a-b-c-d-e-f-g-h-i-j; 
 return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int n,t,count=1,ans=0;
  cin >> t;
  while(1){
	cin >> n;
	ans += n;
	if(ans==0) break;
	if(count == 10) break;
	count++;
  }
  cout << t-ans << endl;
  return 0;
}

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

C++: #include <iostream>
using namespace std;
int main(void)
{
	for (;;)
	{
		int a,b,c,d;
		cin>>a;
		if (a==0)
		{
			break;
		}
		d=0;
		for (b=0;b<9;b++)
		{
			cin>>c;
			d=d+c;
		}
		b=a-d;
		cout<<b<<endl;
	}
	return 0;
}

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

int main() {

	for (int i = 0; i < 5; i++) {
		int x, a, b, c, d, e, f, g, h, I, j;
		cin >> x >> a >> b >> c >> d >> e >> f >> g >> h >> I >> j;
		if (x = 0)return 0;
		cout << x - a - b - c - d - e - f - g - h - I - j << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <functional>
#include <algorithm>
#include <climits>
#include <string>
#include <vector>
#include <map>
#include <cmath>

using namespace std;

namespace _{struct _{_(){ // initialize
  cin.tie(0); ios::sync_with_stdio(false);
}}_;}
template <typename T, size_t size>
inline size_t len(const T (&)[size]) { return size; }
#define println(s) cout << s << '\n';
#define str to_string
#define rep(i, n) for (int i=0; i<int(n); i++)
#define all(c) (c).begin(), (c).end()


int main() {
  int n; cin >> n;

  int t = 0;
  rep(i, 9) {
    int k;
    cin >> k;
    t += k;
  }
  cout << n - t << endl;
  return 0;
}

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

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

C++: #include <iostream>

using namespace std;

int main()
{
     int x,a[9];
     while(true){cin>>x;
     if(x==0)break;
     for(int i=0;i<9;++i){
        cin>>a[i];
        x-=a[i];

     }
     cout<<x<<endl;}
    return 0;
}

C++: #include <cstdio>

int main(){
	int a,b,i;
	for(i=0;b=0,scanf("%d",i%10?&b:&a),a;++i,printf(i%10?"":"%d\n",a))a-=b;
}

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

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

int main(){
	while(1){
	int R0,W0,R,noudo,omosa,cnt=0;
	double C;
	cin>>R0>>W0>>C>>R;
	if(R0==0 && W0==0 && C==0 && R==0) break;
	omosa=R0;
	noudo=R0/W0;
	if(R0/W0>C) cnt=0;
	else{
	while(noudo!=C){
		omosa=omosa+R;
		noudo=omosa/W0;
		cnt++;
	}
	}
	cout<<cnt<<endl;
	}
    return 0;
}

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

using namespace std;

int main(void) {
    int n;
    while (cin >> n, n) {
        int m, M = 0;
        for (int i = 0; i < 9; i++) {
            cin >> m;
            M += m;
        }
        cout << n - M << endl;
    }

    return 0;
}

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

int main(){
	int t,c;
	while(1){
		cin>>t;
		if(t==0) break;
		for(int i=0;i<9;i++){
			cin>>c;
			t-=c;
		}
		cout<<t<<endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int main(void)
{
	for (;;)
	{
		int a,b,c,d;
		cin>>a;
		if (a==0)
		{
			break;
		}
		d=0;
		for (b=0;b<10;b++)
		{
			cin>>c;
			d=d+c;
		}
		b=a-d;
		cout<<b<<endl;
	}
	return 0;
}