#include<iostream>
using namespace std;

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