#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>

int main(int argc, char *argv[]){
        long long days = 0;
        long long study = 0;
        int *learn;
        int _;
        int i;
        scanf("%lld %lld\n", &days, &study);
        learn = (int *)malloc(study+1);
        for(i = 0; i < study-1; i++){
                _ = scanf("%d ",&learn[i]);
        }
        _ = scanf("%d",&learn[i+1]);
        for(i = 0; i <= study;i++){
                if(days <= 0){
                        printf("-1\n");
                        return 0;
                }
                days -= learn[i];
        }
        printf("%lld\n", days);
        return 0;
}