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;

#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
template<typename T> bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1;} return 0;}
template<typename T> bool chmin(T &a, const T &b){ if(a>b){ a=b; return 1;} return 0;}


/*FUNCs=================================================*/


/*MAIN==================================================*/
int main(){
    //cin.tie(nullptr);
    //ios::sync_with_stdio(false);   //cin cout 高速化
    while(true){
        int n; cin >> n;
        if(cin.eof()) break;
        if(n == 0) continue; 
        rep(i,9){
            int p; cin >> p;
            n-=p;
        }
        cout << n << '\n';
    }
}

C++: #include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

int main() {
	int cnt;
	while (scanf("%d", &cnt), cnt) {
		rep(i, 9) {
			int a; cin >> a;
			cnt -= a;
		}
		cout << cnt << endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main() {

  int sum;
  int price[10];

  int rest;


  cin >> sum;

  for(int i=0;i<9;i++) cin >> price[i];

  rest=sum;

  for(int i=0;i<9;i++) rest-=price[i];

  cout << rest << endl;

  return 0;

}

C++: #include <iostream>

using namespace std;

int main() {

    int s, a1, a2, a3, a4, a5, a6, a7, a8, a9;
    cin >> s >> a1 >> a2 >> a3 >> a4 >> a5 >> a6 >> a7 >> a8 >> a9;

    int ans = s - (a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8 + a9);
    cout << ans << endl;
    return 0;
}

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

int main(void){
  int sum = 0, price[10], pay;
  while(1){
    scanf("%d", &pay);
    if(pay == 0) break;
    for(int i = 0; i < 9; i++){
      scanf("%d", &price[i]);
      sum += price[i];
    }
    price[9] = pay - sum;
    printf("%d\n", price[9]);
  }
  return 0;
}

C++: #include <iostream>
using namespace std;
int main(void)
{
	for (;;)
	{
		int a,b,c,d;
		a=0;
		b=0;
		c=0;
		d=0;
		cin>>a;
		if (a==0)
		{
			break;
		}
		d=0;
		for (b=0;b<10;b++)
		{
			cin>>c;
			d=d+c;
		}
		b=a-d;
		cout<<b<<endl;
	}
	return 0;
}

C++: //2009年　情報オリンピック予選　1問目
#include<iostream>
using namespace std;
int main(){

	int a,sum=0,b;
	cin>>a;
	while(1){
	cin>>b;
	if(b==0)break;
	sum+=b;
	}

	cout<<a-sum<<endl;


	return 0;
}

C++: #include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	for(vi a(10);cin>>a[0],a[0];){
		repi(i,1,10)
			cin>>a[i];
		cout<<a[0]-accumulate(1+allof(a),0)<<endl;
	}
	
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){

	int a[10][1000], sum[10];
	int sum1[5];
	for(int j=0;j<5;j++){
		cin>>sum[j];
		sum1[j] = 0;
		if(sum == 0) break;
		for(int i=0;i<9;i++){
			cin>>a[j][i];
			sum1[j] += a[j][i];
		}
		cout<<sum[j] - sum1[j]<<endl;
	}
	return 0;
}

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

}
	cout<<sums[k-1];

return 0;
}

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

return 0;
}

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

int main(){
	int total;
	int cost;
	int totalCost;

	while(cin >> total, total){
		totalCost = 0;
		for(int i=0; i < 9; i++){
			cin >> cost;
			totalCost += cost;
		}
		total -= totalCost;

		cout << total << endl;
	}
}

C++: #include <iostream>

int main() {

	int sum = 0, book[9] = {};
	
	do{

		std::cin >> sum;
	
		for (int i = 0; i < 9; i++) {
			std::cin >> book[i];
		}
		for (int j = 0; j < 9; j++) {
			sum = sum - book[j];
		}
		std::cout << sum << std::endl;

	} while (sum == 0);

	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){

int total;
cin>>total;
int a=0;
int b=0;
int buy=0;

for(int i=1;i<=9;i++){
cin>>a;
b=total-a;
total=b;
}

cout<<total<<'\n';

return 0;
}

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

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