#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M,A;
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> A;
    if(N - A < 0){
      cout << -1 << endl;
      break;
    }
    N -= A;
  }
  if(N >= 0){
    cout << N << endl;
  }

}
