#include <iostream>

using namespace std;

int main(){

	int book , sum;

	while(1){
		cin >> sum;
		if(sum == 0) break;

	for(int i = 0; i < 9; i++){
		cin >> book;
		sum -= book;
	}
	cout << sum << endl;
	}

	return 0;
}