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() {
	int dai, a;
	while (1) {
		cin >> dai;
		if (dai == 0) {
			goto a;
		}
		for (int i = 1; i <= 9; i++) {
			cin >> a;
			dai = dai - a;
		}
		cout << dai << endl;
	}
a:;
}

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

int main(){
  int all,a9;
  int a[9];
  while(1) {
    cin >> all;
    if(all == 0){
      break;
    }
    
    a9=0;
    for(int i=0;i<9;i++){
      cin >> a[i];
      cout << endl;
      a9+=a[i];
    }

    cout << all-a9 << endl;
  }
  return 0;
}

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

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

	return 0;
}

C++: #include <iostream>
using namespace std;
int main() {
	int total;
	int hon;
	int booktotal=0;
	int book[9];
	int i=0;
	scanf("%d", &total);
	while(i<9){
		scanf("%d", &book[i]);
		booktotal = booktotal + book[i];
		i++;
	}
	hon = total - booktotal;
	printf("%d\n", hon);
	return 0;
}

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

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

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

template <class T> void max_swap(T& a, const T b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T b) { a = min(a, b); }

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;


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

C++: #include <bits/stdc++.h>
using namespace std;
#define Rep(i,N) for(int i = 0;i < N;i++)
int main()
{
  int sum;
  int data;
  cin >> sum;
  Rep(i,9) {
    cin >> data;
    sum -= data;
  }
  cout << sum << endl;
  return 0;
}

C++: include<iostream>
#include<algorithm>
#include<functional>
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<cmath>
using namespace std;
int main(){
	
	int s;
	int n;
	while(cin>>s,s!=0){
	for(int i=0;i<9;i++){
		cin>>n;
		s-=n;
	}
	
	cout<<s<<endl;
	}
}

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

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

	return EXIT_SUCCESS;
}

C++: #include <iostream>

using namespace std;

int main(){
  int count=0;
  
  while(1){
    int book[10]={0};

    cin>>book[0];

    if(book[0]==0)
      break;
    
    for(int i=1;i<10;i++){
      cin>>book[i];
      book[0]-=book[i];
    }

    cout<<book[0]<<endl;

    count++;
    if(count==5)
      break;
  }

  return 0;
}

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

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

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

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

int main() {
  int n, input;
  int i, j;
  for (i = 0; i < 5; i++) {
    cin >> n;
    if (n == 0) {
      return 0;
    }
    for (j = 0; j < 9; j++) {
      cin >> input;
      n -= input;
    }
    cout << n << endl;
  }
  return 0;
}

C++: #include<bits/stdc++.h>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;

int main(){
	int a[10];
	for(int i=0;i<10;i++)scanf("%d",&a[i]);
	int sum=0;
	for(int i=1;i<10;i++)sum+=a[i];
	printf("%d\n",a[0]-sum);
}

C++: #include <iostream>
#include <cstdlib>
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 EXIT_SUCCESS;
}

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

C++: //https://onlinejudge.u-aizu.ac.jp/challenges/sources/JOI/Prelim/0543?year=2010

#include <bits/stdc++.h>

using namespace std;

int main() {
    int tot;

    while (cin >> tot, tot) {
        for (int i = 0; i < 9; ++i) {
            int a;
            cin >> a;
            tot -= a;
        }
        cout << tot << endl;
    }

    return 0;
}

/*
 *
 */

C++: #include<stdio.h>

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