#include<iostream>
using namespace std;

int main() {
	int a;
	int b[9];
	while (cin >> a&&a != 0) {
		for (int i = 0; i < 9; i++) {
			cin >> b[i];
		}
		for (int i = 0; i < 9; i++) {
			a -= b[i];
		}
		cout << a << endl;
	}
	return 0;
}