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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int main() {
	int sum;
	
	while (cin >> sum, sum) {
		for_(i,0,9) {
			int sub;
			cin >> sub;
			sum -= sub;
		}
		
		cout << sum << endl;
	}
}