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>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <sstream>
#include <functional>
#include <numeric>
#include <cmath>
#include <cstring>
#include <queue>

using namespace std;
int n;

const int INF = 1 << 29;

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

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

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

C++: #include <iostream>

using namespace std;

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

	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;

int main(){
	int sum,temp,subsum;
	
	while(scanf("%d",&sum)){
		if(sum==0)
		break;
		subsum = 0;
		for(int i=0;i<9;i++){
			scanf("%d",&temp);
			subsum+=temp;
		}
		printf("%d\n",sum-subsum);
	}
}

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

int main(){
int books=0;
int book=0;
int i=0;
cin>>books;
while(i<9){
cin>>book;
books-=book;
i++;
if(books==0){
break;
}
}
cout<<books<<'\n';

return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int sougaku=0, money=0, nazo=0;
	scanf_s("%d", &sougaku);
	nazo = sougaku;
	for (int i = 0; i < 9; i++){
		scanf_s("%d", &money);
		nazo = nazo - money;
	}
	printf("%d\n", nazo);
	return 0;
}

C++: #include <iostream>

using namespace std;

int main() {
	int sum;
	int a;
	cin >> sum;
/*	while (cin >> sum) {
		if (sum == 0) {
			break;
		}*/
		for (int i = 0; i < 10; i++) {
			cin >> a;
			sum -= a;
		}
		cout << sum << endl;
//	}
	return 0;
}

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

int main(){
  for(int j=0;j < 5;j++){
    int N, x[10];
    int X = 0;
    cin>>N;

    for(int i=0;i < 10;i++){
      cin>>x[i];
      X += x[i];
    }

    cout<<N - X<<endl;
    if(N == 0) break;
  }
  
  return 0;
}

C++: #include <stdio.h>

int main(void){
	int i,j,k;
	while(scanf("%d",&i),i){
		for(k=0;k<10;k++)
			scanf("%d",&j),i-=j;
		printf("%d\n",i);
	}
}

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

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

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

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

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

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

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

C++: #include <iostream>
 
using namespace std;
 
int main()
{
	int total,books;
	while(true){
		cin>>total;
		if(total==0){
			break;
		}
	for(int i=1;i<=9;i++){
	cin>>books;
	total-=books;
	}
	cout<<total<<"\n";
	}

    return 0;
}

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

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

  return (0);
}

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

return 0;
}

C++: #include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const double pi=acos(-1);
const double eps=1e-10;
const vi emp;

int sum;

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

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

C++: #include<iostream>

using namespace std;

int main(){

	int n, m;

	while (1){

		cin >> n;
		if (n == 0) break;

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

	return 0;
}