#include <iostream>

using namespace std;

int main(){
    int p,t;
    while(cin>>p,p){
        int sum=0;
        for(int i=0;i<9;++i){
            cin>>t;
            sum += t;
        }
        cout<<p-sum<<endl;
    }
    return 0;
}