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

}