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<stdio.h>
int main()
{
	int a,b[9],i;
	while(1){
		scanf("%d",&a);
		if(a==0){
			break;
		}
		for(i=0;i<9;i++){
			scanf("%d",&b[i]);
			a-=b[i];
		}
		printf("%d\n",a);
	}
	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<bits/stdc++.h>
using namespace std;


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

  int sum = 0;
  while(1){
  int x;
  cin>>x;

 sum = sum + x;

 }
  
  cout<<n-sum<<endl;


  return 0;
}

C++: #import<cstdio>
int main(){int a,b;for(a=0;scanf("%d",&b),b;)a?a-=b:a=b;printf("%d\n",a);}

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 <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;
	cin >> a;
	for(int i = 0; i < 9; i++){
		cin >> in;
		a -= in;
	}
	cout << a << endl;
	return 0;
}

C++: #include<iostream>

using namespace std;

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

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 >> b >> c >> d >> e >> f >> g >> h >> i >> j;
    cout << a-(b+c+d+e+f+g+h+i+j) << '\n';

    return 0;
}

C++: #include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
	int n;
	int sum = 0;
	for (int i = 0; i < 10; i++) {
		int x;
		cin >> x;
		sum += x;
	}
	cout << n - sum << endl;
}

C++: 
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef vector<int> vint;
#define rep(i,n) for(int i = 0; i < n; i++)
#define MSG(a) cout << #a << " " << a << endl;

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

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
	int t,x,sum=0;
	for(int j=0;j<4;j++){
	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 total;
    int price[9];
    while (cin >> total, total != 0) {
        for (int i = 0; i < 9; i++) {
            cin >> price[i];
        }
        for (int i = 0; i < 9; i++) {
            total -= price[i];
        }
        cout << total << endl;
    }
    return 0;
}

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

#define rep_(v, f, l) for (int v = (f), v##_ = (l); v < v##_; ++v)
#define rep(v, n) rep_(v, 0, n)
#define lep(v, n) rep_(v, 1, n + 1)
#define rrep_(v, f, l) for (int v = (l), v##_ = (f); v >= v##_; --v)
#define rrep(v, n) rrep_(v, 0, n - 1)
#define rlep(v, n) rrep_(v, 1, n)
#define show_a(a, size) rep(a##_it, size) std::cout << a[a##_it] << " \n"[a##_it == a##_it_ - 1];
#define show_v(v) show_a(v, v.size())
#define eachv(v, i) rep(i, v.size())
#define reachv(v, i) rrep(i, v.size())
#define debug(x) std::cerr << #x << " = " << x << "\n";

using namespace std;

typedef long long int lint;

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline lint inl(){ lint x; scanf("%lld", &x); return x; }

int main()
{
    int n;
    while (n = in()){
        int sum = 0;
        rep(i, 9) sum += in();
        printf("%d\n", n - sum);
    }
    return (0);
}