#include <stdio.h>
int main(void){
    int n, m, i, d = 0, flag = 0;
    int a[1000];
    
    scanf("%d %d", &n, &m);
    
    for(i = 0; i < m; i++){
        scanf("%d\n", &a[i]);
    }
    
    for(i = 0; i < m; i++){
        d = d + a[i];
        if(d <= n){
            flag = 1;
        }else if(d > n){
            flag = 0;
        }
    }
    
    if(flag == 1){
        printf("%d\n", n - d);
    }else{
        printf("-1\n");
    }
    
}
