#include <iostream>
using namespace std;

int main(){
	int n;
	while(cin >> n, n){
		int num, ans = 0;
		for(int i = 0;i < 9;i++){
			cin >> num;
			ans += num;
		}
		cout << n-ans << endl;
	}
	return 0;
}