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>
using namespace std;

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

C++: #include <stdio.h>
#include <algorithm>
using namespace std;

int main(){
	while (1){
		int total;
		int num;
		scanf("%d", &total);
		if (total == 0) return 0;
		for (int a = 0; a < 9; a++){
			scanf("%d", &num);
			total -= num;
		}
		printf("%d", total);
	}
	return 0;
}

C++: #include <iostream>
#define Iset int i,j,l;
using namespace std;

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

C++: #include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main (){
    int n;
    while(cin>>n&&n){
        int b=0;
        rep(i,0,9){
            int t;cin>>t;b+=t;
        }
        cout<<n-b<<endl;
    }
}


/*
abcdea

/root
a.txt
bunp.html
/desktop
r.txt
fsharp.cs
dp.cpp
/users
bison.txt

root r.txt
users r.txt
users a.txt

desktop/r.txt
../r.txt
../../a.txt
*/

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

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

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

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

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

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

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

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

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

int main(){
  int a ,c,sum,ans;
  int b[9] ={};
  sum =0;
while(1){
  cin >> a;

if(a == 0)break;

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


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

  ans = a -sum;

  cout << ans << endl;

sum = 0;

}

}

C++: #include <stdio.h>

int total, a[10];
int i = 0;

int main(void) {
	while (true) {
		scanf("%d", &total);
		if (total == 0) { break; }
		for (int i = 0; i < 9; ++i) { scanf("%d", &a[i]); }
		for (int i = 0; i < 9; ++i) { total -= a[i]; }
		printf("%d\n", total);
	}
	return 0;
}

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

C++: #include <iostream>
#include <utility>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
using namespace std;
int main()
{
	while(true){
		int ans,tmp;cin>>ans;
		if(ans==0)break;
		for(int i=0;i<9;i++){
			cin>>tmp;ans-=tmp;
		}
		cout<<ans<<endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
     int a,b,i=0;
     cin>>a;
do{
    if(a>10000)
        break;
     cin>>b;
     a=a-b;i++;
}while(i<=8);
if(i==9){
     cout <<a<<endl;
}


return 0;
}