import * as fs from 'fs';

// parameter "input" gets all data
function Main(input: string) {
    const lines = input.split('\n');
    const [n, m] = lines[0].split(' ').map(int => parseInt(int));
    const a = lines[1].split(' ').map(int => parseInt(int));

    let left = n;
    for (let i = 0; i < m; i++) {
        left -= a[i];
        if (left < 0) {
            left = -1;
            break;
        }
    }

    //output

    let result = left;
    console.log(result);
    return result;
}

// Don't edit this line!
Main(fs.readFileSync('/dev/stdin', 'utf8'));
