
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();
        int M = scan.nextInt();
        int need = 0;

        for(int i = 0; i < M; i++) {
            need += scan.nextInt();
        }

        if(N >= need)
            os.println(N-need);
        else
            os.println(-1);
    }

} import java.io.InputStream; InputStream java.io import java.io.PrintStream; PrintStream java.io import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();
        int M = scan.nextInt();
        int need = 0;

        for(int i = 0; i < M; i++) {
            need += scan.nextInt();
        }

        if(N >= need)
            os.println(N-need);
        else
            os.println(-1);
    }

} Main public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    } main {
        solve(System.in, System.out);
    } solve(System.in, System.out) solve System.in System System.in System.out System System.out String[] args args static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();
        int M = scan.nextInt();
        int need = 0;

        for(int i = 0; i < M; i++) {
            need += scan.nextInt();
        }

        if(N >= need)
            os.println(N-need);
        else
            os.println(-1);
    } solve {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();
        int M = scan.nextInt();
        int need = 0;

        for(int i = 0; i < M; i++) {
            need += scan.nextInt();
        }

        if(N >= need)
            os.println(N-need);
        else
            os.println(-1);
    } Scanner scan = new Scanner(is); scan new Scanner(is) int N = scan.nextInt(); N scan.nextInt() scan.nextInt scan int M = scan.nextInt(); M scan.nextInt() scan.nextInt scan int need = 0; need 0 for(int i = 0; i < M; i++) {
            need += scan.nextInt();
        } int i = 0; int i = 0; i 0 i < M i M i++ i++ i {
            need += scan.nextInt();
        } {
            need += scan.nextInt();
        } need += scan.nextInt() need scan.nextInt() scan.nextInt scan if(N >= need)
            os.println(N-need);
        else
            os.println(-1); N >= need N need os.println(N-need) os.println os N-need N need os.println(-1) os.println os -1 1 InputStream is is PrintStream os os public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();
        int M = scan.nextInt();
        int need = 0;

        for(int i = 0; i < M; i++) {
            need += scan.nextInt();
        }

        if(N >= need)
            os.println(N-need);
        else
            os.println(-1);
    }

} public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();
        int M = scan.nextInt();
        int need = 0;

        for(int i = 0; i < M; i++) {
            need += scan.nextInt();
        }

        if(N >= need)
            os.println(N-need);
        else
            os.println(-1);
    }

} Main

import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();
        int M = scan.nextInt();
        int need = 0;

        for(int i = 0; i < M; i++) {
            need += scan.nextInt();
        }

        if(N >= need)
            os.println(N-need);
        else
            os.println(-1);
    }

}