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 t,x,sum=0;
	cin>>t;
	while(1){
	if(x==0)break;
	cin>>x;
	sum=sum+x;
}
	cout<<t-sum<<endl;

return 0;
}

C++: //============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;
int N,A[9];
int main() {
	cin>>N;
	for(int i=0;i<9;i++){
		cin>>A[i];
		N-=A[i];
	}
	cout<<N<<endl;

	return 0;
}

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

using namespace std;

int main(){

  int sum,b,all=0,cou=0;
  vector<int> val;

  while(true){
    cin>>sum;
    if(sum==0) break;
    all=0;

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

    val.push_back(sum-all);
    ++cou;
  }

  for(int i=0; i<cou; ++i){
    cout << val[i] << endl;
  }

  
  return 0;
}

C++: #include <stdio.h>


int main(void){
	int sum, p;

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


	return 0;
}

C++: #include<iostream>
using namespace std;	
 
	int main(){
		int goke;
		int hon;
		int count=0;

	while(true){
		if(count==0){
		cin>>goke;
		if(goke==0){
		break };
	count++; }
	else{
		cin>>hon;
		goke-=hon;
		count++;
		}
		if(count==10){
		cout<<goke<<'\n';
		count=0;
		}
	}
	return0;
}

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

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

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

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

C++: #include <cstdio>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main() {
	while(1) {
		int s;
		scanf(" %d", &s);
		if(s == 0) break;
		rep(i,9) {
			int t;
			scanf(" %d", &t);
			s -= t;
		}
		printf("%d\n", s);
	}
	return 0;
}

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

int main(){
	int sum;
	int hon[9];
	cin>>sum;
	for(int i=0;i<9;i++){
		cin>>hon[i];
	}
	for(int i=0;i<9;i++){
		sum-=hon[i];
	}
	cout<<sum;
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	
	for(int i=0; i<5; i++){
		int N,A,B,C,D,E,F,G,H,I;
		cin >> N >> A >> B >> C >> D >> E >> F >> G >> H >> I;

		if(N == 0)break;

		cout << N-A-B-C-D-E-F-G-H-I << endl;
}
	
	return 0;
}

C++: #include <iostream>

using namespace std;

int main() {
  int sum, sum9 = 0;

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

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

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  while(1){
    int sum,a,total=0;
    cin >> sum;
    if(sum == 0) break;
    for(int i=0;i<9;i++){
      cin >> a;
      total+=a;
    }
    cout << sum-total << endl;
    total=0;
  }
  return 0;
}