#include<bits/stdc++.h>
#define lli long long int
#define ulli unsigned long long int
#define ldb long double
#define pb push_back
#define popb pop_back
#define ins insert
#define si size()
#define sof sizeof()
#define be begin()
#define en end()
#define all(v) v.be,v.en
#define le length()
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound 
#define ump unordered_map
#define forr(i,a,n) for(int i=a;i<n;i++)
#define rfor(i,n,a) for(int i=n;i>=a;i--)
#define fore(i,a,n) for(int i=a;i<=n;i++)
#define maxe *max_element
#define mine *min_element
#define JaiHindDosto ios::sync_with_stdio(0), cin.tie(0),cout.tie(0)
#define nl cout<<endl;
#define o(a) cout<<a<<" "
#define o1(a) cout<<a<<"\n"
#define o2(a,b) cout<<a<<" "<<b<<"\n"
#define o3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define o4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n"
#define vlli vector <lli> 
#define slli set<lli>
#define mlli map<lli,lli> 
#define grt greater<>()
#define mod 1000000007
#define inp(a,n) forr(i,0,n)cin>>a[i];
#define out(a,n) forr(i,0,n)o(a[i]);nl;
using namespace std;
//=========================================================================
lli modadd(lli n,lli m);
lli modsub(lli n,lli m);
lli modprod(lli n,lli m);
lli power(int x,int y);
lli powmod(lli x,lli y);
void dfs(lli s);
void bfs(lli s);
string DecToBin(lli n);
lli SolveBin(string s);
void makeset();
lli find(lli i);
void Union(lli i,lli j);
lli nc2(lli x);
lli countSubarrays(lli arr[], lli n, lli k);
bool sortbysec(const pair<lli,lli> &a,const pair<lli,lli> &b);
//=========================================================================
lli n,m, s;                      //graph and dsu
unordered_map<lli,lli> parent;   //dsu
unordered_map<lli,lli> Rank;     //dsu
unordered_map<lli,lli> Siz;      //dsu
vector<vector<lli>> adj;         //graphs
queue<lli> gqueue;               //bfs
vector<bool> visited;            //bfs and dfs
vector<lli> depth, prnt;         //bfs
//=========================================================================
int main() {
	JaiHindDosto;
	lli test=1;
    //cin>>test;
    lli wow = test;
	while(test--){
    //o2("Case : #",wow-test); 
    lli n,d;
    cin>>d>>n;
    vlli a(n);
    inp(a,n);
    lli s=0,x=-1;
    forr(i,0,n)s+=a[i];
    if(s>d){
        cout<<-1;
    }else{
        cout<<d-s;
    }
    //cout<<max(x,d-s);
    
    
    
    
    

    
    
    }
	return 0;
}
//=========================================================================
string DecToBin(lli n){
    string s="";
    while(n!=0){
        s=to_string(n%2)+s;
        n/=2;
    }
    return "0"+s;
}
lli SolveBin(string s){
    lli ans=0;
    lli prod=1;
    rfor(i,s.si-1,0){
        ans+=prod*(s[i]-48);
        prod*=2;
    }
    return ans;
}
void bfs(lli s){
    gqueue.push(s-1);
    visited[s-1] = true;
    prnt[s-1] = -1;
    while (!gqueue.empty()) {
        lli v = gqueue.front();
        gqueue.pop();
        //cout << v+1 <<" ";
        for (lli u : adj[v]) {
            if (!visited[u]) {
                visited[u] = true;
                gqueue.push(u);
                depth[u] = depth[v] + 1;
                prnt[u] = v;
            }
        }
    }
    
}

void dfs(lli s){
    if(visited[s]){
        return ;
    }
    visited[s]= true;
    //cout << s <<" ";
    for(lli u : adj[s-1]){
        dfs(u);
    };
    
}
/*
///DFS AND BFS CODE
    cin>>n>>m;
    for(lli i=0;i<n;i++){
        vector<lli> ele;
        adj.push_back(ele);
    };
    visited.resize(n);
    prnt.resize(n);
    depth.resize(n);
    lli a,b;
    for(lli i=0;i<m;i++){
        cin>>a>>b;
        adj[a-1].push_back(b-1);
        adj[b-1].push_back(a-1);
    }
    bfs(1);
    dfs(2);

*/
void makeset(){
    for(lli i=1;i<n+1;i++){
        parent[i]=i;
        Siz[i]=1;
    }
}
lli find(lli i){                            // find by path-compression
    if(parent[i]!=i){
        parent[i]=find(parent[i]);
    }
    return parent[i];
}
void Union(lli i,lli j){                    //union by rank
    lli irep=find(i),irank,jrank,isz,jsz;
    lli jrep=find(j);
    if(irep==jrep){
        return;
    }else{
         irank = Rank[irep];
         jrank = Rank[jrep];
         isz=Siz[irep];
         jsz=Siz[jrep];
        if(irank>jrank){
            parent[jrep]=irep;
            Siz[irep]+=Siz[jrep];
        }else if(jrank>irank){
            parent[irep]=jrep;
             Siz[jrep]+=Siz[irep];
        }else{
            parent[jrep]=irep;
            Siz[irep]+=Siz[jrep];
            Rank[irep]++;
        }
    }
}
lli nc2(lli x){
return ((x)*(x-1))/2;
}
lli countSubarrays(lli arr[], lli n, lli k) { 
    lli start = 0, end = 0, 
        count = 0, sum = arr[0]; 
  
    while (start < n && end < n) { 
  
        // If sum is less than k, 
        // move end by one position. 
        // Update count and sum 
        // accordingly. 
        if (sum < k) { 
            end++; 
  
            if (end >= start) 
                count += end - start; 
  
            // For last element, 
            // end may become n 
            if (end < n) 
                sum += arr[end]; 
        } 
  
        // If sum is greater than or 
        // equal to k, subtract 
        // arr[start] from sum and 
        // decrease sliding window by 
        // moving start by one position 
        else { 
            sum -= arr[start]; 
            start++; 
        } 
    } 
  
    return count; 
} 

lli modadd(lli n,lli m){
    lli sum = ((n+m)%mod+mod)%mod;
    return sum;
}
lli modsub(lli n,lli m){
    lli diff = ((n-m+mod)%mod+mod)%mod;
    return diff;
}
lli modprod(lli n,lli m){
    lli pro = ((n*m)%mod+mod)%mod;
    return pro;
}
lli power(int x,int y){
    lli res = 1;
    while (y > 0) {
        if (y & 1)
            res = res * x;
        y = y >> 1;
        x = x * x;
    }
    return res;
}
lli powmod(lli x,lli y){
    lli res = 1;
    while (y > 0) {
        if (y & 1)
            res = modprod(res , x);
        y = y >> 1;
        x = modprod(x , x);
    }
    return res;
}
bool sortbysec(const pair<lli,lli> &a, const pair<lli,lli> &b){
    return (a.second < b.second);
}



/*
///KRUSKAL MST

cin >>v>>e;
   vector<pair<lli,pair<lli,lli>>>edges;
   for(lli i=0;i<e;i++){
       lli a,b,c;
       cin >> a>>b>>c;
       pair <lli,lli> ed;
       ed = make_pair(a,b);
       edges.push_back(make_pair(c,ed));
   }
   sort(edges.begin(),edges.end());
   make();
   lli p=0,k=1;
   cout << "Edges in our MST are :\n";
   for(lli i=0;i<e;i++){
       lli a=edges[i].second.first;
       lli b=edges[i].second.second;
       lli w=edges[i].first;
       if(find(a)!=find(b)){
           Union(a,b);
           cout <<"Edge "<<k<<" : "<< a <<" "<< b <<endl;
           k++;
           p+=w;
       }
   }
*/

Measured memory_bytes: 3676