#include<bits/stdc++.h>
using namespace std;
#define el "\n"
#define ll long long
#define ull unsigned long long
#define se second
#define fi first
#define be begin()
#define en end()
#define Faster cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

int main()
{
    Faster;
    int x, n; cin >> x >> n;
    int a[n];
    for(auto &x : a) cin >> x;
    int ans = 0;
    for(int i = 0; i < n; i++)
    {
        ans = x + ans - a[i];
        if(ans < 0)
        {
            cout << -1;
            return 0;
        }
    }
    cout << ans + x;
    return 0;
}
