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 sum;
	while(cin >> sum){
		if(!sum)
			break;
		int price;
		for(int i=0;i<9;i++){
			cin >> price;
			sum -= price;
		}
		cout << sum << endl;
	}
	return 0;
}

C++: #include<cstdio>
#define rep(i,a) for( int i = 0; i != (a); ++i )

int s;

int main()
{
	while( scanf( "%d", &s ), s )
	{
		rep( i, 9 )
		{
			int a;
			scanf( "%d", &a );
			s -= a;
		}

		printf( "%d\n", s );
	}

	return 0;
}

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

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

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

int main(){
    int all,buy;
    cin >> all;
    while(1){
        cin >> buy;
        if(buy == 0){
            break;
        }
        all -= buy;
    }
    cout << all << endl;
}

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

C++: #include <iostream>
#include<stdio.h>
using namespace std;
 
int main(){
  int a,i;
  int hon[11];

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

  return 0;
}

C++: #include <cstdio>

int main(){
	int a,b;
	while(scanf("%d",&a),a != 0){
		for(int i = 1; i < 10; i++){
			scanf("%d",&b);
			a -= b;
		}
		printf("%d\n",a);
	}
	return 0;
}

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

C++: #include <stdio.h>

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

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

C++: #include <iostream>

using namespace std;

int main(void)
{
	int n,m;

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

	return 0;
}

C++: #include <iostream>
using namespace std;
int main( void )
{
	int total; // ツ堕債額
	while ( cin >> total && total )
	{
		int sum = 0;
		for ( int i = 0; i < 9; i++ )
		{
			int cost; cin >> cost; sum += cost;
		}
		cout << total - sum << endl;
	}
	return 0;
}

C++: #include <stdio.h>

int main (void){
	int total, price;
	scanf("%d", &total);
	while (1) {
		scanf("%d", &price);
		if (! price) {
			break;
		}
		total-=price;
	}
	printf("%d\n", total);
			
	return 0;
}

C++: #include <cstdio>

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

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

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

C++: #include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<cmath>
#include<ctime>
#include<complex>

using namespace std;

#define REP(i,s,e) for(int i=int(s);i<=int(e);i++)
#define rep(i,n) for(int i=0;i<int(n);i++)


int main(){

	int a,b;
	while(1){

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

		int x=a;
		for(int i=1;i<=9;i++){

			cin >> b;

			x-=b;

		}

		cout << x << endl;

	}

	return 0;
}

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>

using namespace std;

typedef complex<double> xy_t;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, string> Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF= 1 << 30;
const double EPS = 1e-9;
const double PI = 3.1415926535897932384626433832795;

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

C++: #include<stdio.h>

int main(void){
	int N,i,k;

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

C++: #include<bits/stdc++.h>
using namespace std;
int a,b,ans;

int main(){

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

return 0;
}

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

using namespace std;

    int main(){
        int price[11],allprice,Ans;
        for(int i=0;i<11;i++){
        price[i]=0;
        }
        while(1){
        cin>>allprice;
        if(allprice==0)break;

        for(int i=0;i<9;i++){
            cin>>price[i];
        }
        for(int i=0;i<9;i++){
            price[10]+=price[i];
        }
        Ans=allprice-price[10];
        cout<<Ans<<endl;
        }
     return 0;
    }

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

 
int main () 
{
  int i;
  int a;
  cin>>a;
  while(a>=0)
  {
   cin>>i;
   if(i==0)
      break;
  else
    a=a-i;
 }
  cout<<a<<'\n';

  return 0;
}