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