#include <math.h>
#include <stdio.h>
#include <string.h>

#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <istream>
#include <sstream>
#include <string>
#include <tuple>
#include <vector>

using lint = long long;
using namespace std;

lint Sum(lint a, lint b) {
    return (a + b) * (b - a + 1) / 2;
}

lint permutation(lint n, lint k) {
    lint v = 1;
    if (0 < k && k <= n) {
        for (lint i = 0; i < k; i++) {
            v *= (n - i);
        }
    } else if (k > n) {
        v = 0;
    }
    return v;
}

lint factorial(lint n) {
    return permutation(n, n - 1);
}

lint combination(lint n, lint k) {
    return permutation(n, k) / factorial(k);
}

lint homogeneous(lint n, lint k) {
    return combination(n + k - 1, k);
}

// // round returns rounded linteger number
// lint round(double x) {
//     if (x < double(lint(x)) + 0.5) {
//         return lint(x);
//     }
//     return lint(x) + 1;
// }

// template <double... nums>
// // minf returns min{a, b}(a, b: float64)
// double minf(double a, double b) {
//     min(Ints);
// }

// mini returns min{a, b} (a, b: int)
lint mini(lint a, lint b) {
    if (a > b) {
        return b;
    }
    return a;
}

// minf returns max{a, b}(a, b: float64)
lint maxf(double a, double b) {
    if (a > b) {
        return a;
    }
    return b;
}

// maxi returns max{a, b} (a, b: int)
lint maxi(lint a, lint b) {
    if (a > b) {
        return a;
    }
    return b;
}

// pawf paw returns f^num(f:float64)
lint pawf(double f, lint num) {
    double result = 1;
    for (lint i = 0ll; num > i; i++) {
        result *= f;
    }
    return result;
}

// pawi paw returns f^num(f:int)
lint pawi(lint f, lint num) {
    lint result = 1;
    for (lint i = 0; num > i; i++) {
        result *= f;
    }
    return result;
}

vector<lint> atois(vector<string> str) {
    vector<lint> result((lint)str.size());
    for (lint i = 0; i < (lint)str.size(); i++) {
        std::sscanf(str[i].c_str(), "%lld", &result[i]);
    }
    return result;
}

vector<vector<lint>> alatois(vector<vector<string>> str) {
    vector<vector<lint>> result((lint)str.size());
    for (lint i = 0; i < (lint)str.size(); i++) {
        result[i] = atois(str[i]);
    }
    return result;
}

// split split strings into vector<string> by charactor del
std::vector<string> split(std::string str, char del) {
    std::vector<std::string> result;
    std::string input = "";
    std::stringstream ss;

    // stream に押し込む
    ss << str;
    char now;

    for (;;) {
        now = ss.get();
        if (now == del) {
            result.push_back(input);
            input = "";
            continue;
        }
        if (now == std::istringstream::traits_type::eof()) {
            result.push_back(input);
            break;
        }
        input += now;
    }

    return result;
}

// readLine read standard input data
string readLine() {
    const lint readLen = 100000;
    char buf[readLen];
    string input = "";
    vector<string> result;

    for (;;) {
        fgets(buf, sizeof(buf), stdin);
        input += string(buf);
        if (input.find("\n") != std::string::npos) {
            break;
        }
    }
    return input;
}

// rLine Read all standard input data
std::vector<std::vector<string>> rLine(lint line) {
    std::vector<std::vector<string>> stringInput;
    std::string s;

    for (int i = 0; i < line; i++) {
        s = readLine();
        stringInput.push_back(split(s, ' '));
    }

    return stringInput;
}

// irLine Read Standard input data and convert into integer
vector<vector<lint>> irLine(int i) {
    return alatois(rLine(i));
}

// mrLine Read multi-line standard input data
// put the location of data of the number of lines in a first line
// ex:
// 3 5
// 1 2
// 2 3
// 3 5
// you have to put 1, where the number 3 put in the first line
tuple<vector<lint>, vector<vector<string>>> mrLine(lint line) {
    std::vector<std::vector<string>> stringInput;
    std::vector<lint> input;
    std::string s;

    s = readLine();

    std::vector<std::string> x = split(s, ' ');
    input = atois(x);

    stringInput = rLine(input[line - 1]);

    return forward_as_tuple(input, stringInput);
}

// mirLine  Read multi-line standard input data and convert into integer data
// put the location of data of the number of lines in a first line
// ex:
// 3 5
// 1 2
// 2 3
// 3 5
// you have to put 1, where the number 3 put in the first line
tuple<vector<lint>, vector<vector<lint>>> mirLine(lint line) {
    vector<lint> first;
    vector<vector<string>> input;
    std::tie(first, input) = mrLine(line);
    return forward_as_tuple(first, alatois(input));
}

lint gcd(lint a, lint b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}

lint gcd3(lint a, lint b, lint c) {
    return gcd(gcd(a, b), c);
}

// meds3 return median of 3 stringer values
string meds3(string x, string y, string z) {
    if (x < y) {
        if (x > z) {
            return x;
        } else if (z > y) {
            return y;
        } else {
            return z;
        }
    }
    if (z < y) {
        return y;
    } else if (x < z) {
        return x;
    } else {
        return z;
    }
}

// medi3 return median of 3 stringer values
lint medi3(lint x, lint y, lint z) {
    if (x < y) {
        if (x > z) {
            return x;
        } else if (z > y) {
            return y;
        } else {
            return z;
        }
    }
    if (z < y) {
        return y;
    } else if (x < z) {
        return x;
    } else {
        return z;
    }
}

// iQuicksort sort integer slice by quick sort
void iQuicksort(vector<lint>& a, lint left, lint right) {
    if (left < right) {
        lint i = left;
        lint j = right;
        lint tmp = 0;
        lint pivot = medi3(a[i], a[i + (j - i) / 2], a[j]);

        for (;;) {
            for (; a[i] < pivot; i++) {
            }
            for (; pivot < a[j]; j--) {
            }
            if (i >= j) {
                break;
            }
            tmp = a[i];
            a[i] = a[j];
            a[j] = tmp; /* a[i], a[j] を交換 */
            i++;
            j--;
        }
        iQuicksort(a, left, i - 1); /* 分割した左を再帰的にソート */
        iQuicksort(a, j + 1, right); /* 分割した右を再帰的にソート */
    }
}

// iQuicksort sort integer slice by quick sort
void sQuicksort(vector<string>& a, lint left, lint right) {
    if (left < right) {
        lint i = left;
        lint j = right;
        string tmp = 0;
        string pivot = meds3(a[i], a[i + (j - i) / 2], a[j]);

        for (;;) {
            for (; a[i] < pivot; i++) {
            }
            for (; pivot < a[j]; j--) {
            }
            if (i >= j) {
                break;
            }
            tmp = a[i];
            a[i] = a[j];
            a[j] = tmp; /* a[i], a[j] を交換 */
            i++;
            j--;
        }
        sQuicksort(a, left, i - 1); /* 分割した左を再帰的にソート */
        sQuicksort(a, j + 1, right); /* 分割した右を再帰的にソート */
    }
}

// qiSort sort integer slie by quick sort
void qiSort(vector<lint>& a) {
    iQuicksort(a, 0, a.size() - 1);
}

// qsSort sort stringer slie by quick sort
void qsSort(vector<string>& a) {
    sQuicksort(a, 0, a.size() - 1);
}

// abis returns absolute integer number
lint absi(lint a) {
    if (a > 0) {
        return a;
    }
    return -a;
}

// absf returns absolute float number
double absf(double a) {
    if (a > 0) {
        return a;
    }
    return -a;
}

int main() {
    auto input = irLine(2);

    auto N = input[0][0];
    auto A = input[1];

    int sum = 0;

    for (lint i = 0; i < A.size(); i++) {
        sum += A[i];
    }

    if (N - sum < 0) {
        printf("%d", -1);
    } else {
        printf("%d", N - sum);
    }

    return 0;
}


Measured memory_bytes: 3856