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

int main()
{
    int M;
    scanf("%d",&M);
    int N;
    scanf("%d",&N);
    int A[N];
    int i ;
    int sum = 0;
    for ( i = 0 ; i < N ; i++){

        scanf("%d",&A[i]);
        sum = sum + A[i];}

    int W = M - sum ;
    printf("%d",W);
    return 0;
}
