#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;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2RlZmluZSBlbCAiXG4iCiNkZWZpbmUgbGwgbG9uZyBsb25nCiNkZWZpbmUgdWxsIHVuc2lnbmVkIGxvbmcgbG9uZwojZGVmaW5lIHNlIHNlY29uZAojZGVmaW5lIGZpIGZpcnN0CiNkZWZpbmUgYmUgYmVnaW4oKQojZGVmaW5lIGVuIGVuZCgpCiNkZWZpbmUgRmFzdGVyIGNpbi50aWUoMCk7IGNvdXQudGllKDApOyBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKDApOwoKaW50IG1haW4oKQp7CiAgICBGYXN0ZXI7CiAgICBpbnQgeCwgbjsgY2luID4+IHggPj4gbjsKICAgIGludCBhW25dOwogICAgZm9yKGF1dG8gJnggOiBhKSBjaW4gPj4geDsKICAgIGludCBhbnMgPSAwOwogICAgZm9yKGludCBpID0gMDsgaSA8IG47IGkrKykKICAgIHsKICAgICAgICBhbnMgPSB4ICsgYW5zIC0gYVtpXTsKICAgICAgICBpZihhbnMgPCAwKQogICAgICAgIHsKICAgICAgICAgICAgY291dCA8PCAtMTsKICAgICAgICAgICAgcmV0dXJuIDA7CiAgICAgICAgfQogICAgfQogICAgY291dCA8PCBhbnMgKyB4OwogICAgcmV0dXJuIDA7Cn0K