#include<iostream>
using namespace std;
	int main(){
	int a,b;int sum=0;
	int sums[5000];int k=0;
	while(cin>>sum){
	if(sum==0)break;
	for(int i=0;i<9;i++){
		cin>>b;
		sum-=b;
	}
	cout<<sum<<endl;
	}
}