#include <bits/stdc++.h>
int main(void) {
  int N, M, i;
  scanf("%d", &N);
  scanf("%d\n", &M);
  int A;
  for (i = 1; i <= M; i++) {
    scanf("%d,", &A);
    N = N - A;
    if (N < 0) {
      printf("-1");
    }
  }
  printf("%d", N);
}
