import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        String[] input1 = br.readLine().split(" ");
        int n = Integer.parseInt(input1[0]);
        int m = Integer.parseInt(input1[1]);
        
        String[] input2 = br.readLine().split(" ");
        int[] cost = new int[m];
        int totalCost = 0;
        
        for(int i = 0; i < m; i++){
            cost[i] = Integer.parseInt(input2[i]);
            totalCost += cost[i];
        }
        
        out.println(n >= totalCost ? n - totalCost : -1);
        out.close();
        
    }
} import java.util.*; util.* java import java.io.*; io.* java public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        String[] input1 = br.readLine().split(" ");
        int n = Integer.parseInt(input1[0]);
        int m = Integer.parseInt(input1[1]);
        
        String[] input2 = br.readLine().split(" ");
        int[] cost = new int[m];
        int totalCost = 0;
        
        for(int i = 0; i < m; i++){
            cost[i] = Integer.parseInt(input2[i]);
            totalCost += cost[i];
        }
        
        out.println(n >= totalCost ? n - totalCost : -1);
        out.close();
        
    }
} Main public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        String[] input1 = br.readLine().split(" ");
        int n = Integer.parseInt(input1[0]);
        int m = Integer.parseInt(input1[1]);
        
        String[] input2 = br.readLine().split(" ");
        int[] cost = new int[m];
        int totalCost = 0;
        
        for(int i = 0; i < m; i++){
            cost[i] = Integer.parseInt(input2[i]);
            totalCost += cost[i];
        }
        
        out.println(n >= totalCost ? n - totalCost : -1);
        out.close();
        
    } main {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        String[] input1 = br.readLine().split(" ");
        int n = Integer.parseInt(input1[0]);
        int m = Integer.parseInt(input1[1]);
        
        String[] input2 = br.readLine().split(" ");
        int[] cost = new int[m];
        int totalCost = 0;
        
        for(int i = 0; i < m; i++){
            cost[i] = Integer.parseInt(input2[i]);
            totalCost += cost[i];
        }
        
        out.println(n >= totalCost ? n - totalCost : -1);
        out.close();
        
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); out new PrintWriter(new OutputStreamWriter(System.out)) String[] input1 = br.readLine().split(" "); input1 br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int n = Integer.parseInt(input1[0]); n Integer.parseInt(input1[0]) Integer.parseInt Integer input1[0] input1 0 int m = Integer.parseInt(input1[1]); m Integer.parseInt(input1[1]) Integer.parseInt Integer input1[1] input1 1 String[] input2 = br.readLine().split(" "); input2 br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int[] cost = new int[m]; cost new int[m] m int totalCost = 0; totalCost 0 for(int i = 0; i < m; i++){
            cost[i] = Integer.parseInt(input2[i]);
            totalCost += cost[i];
        } int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
            cost[i] = Integer.parseInt(input2[i]);
            totalCost += cost[i];
        } {
            cost[i] = Integer.parseInt(input2[i]);
            totalCost += cost[i];
        } cost[i] = Integer.parseInt(input2[i]) cost[i] cost i Integer.parseInt(input2[i]) Integer.parseInt Integer input2[i] input2 i totalCost += cost[i] totalCost cost[i] cost i out.println(n >= totalCost ? n - totalCost : -1) out.println out n >= totalCost ? n - totalCost : -1 n >= totalCost n totalCost n - totalCost n totalCost -1 1 out.close() out.close out String[] args args public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        String[] input1 = br.readLine().split(" ");
        int n = Integer.parseInt(input1[0]);
        int m = Integer.parseInt(input1[1]);
        
        String[] input2 = br.readLine().split(" ");
        int[] cost = new int[m];
        int totalCost = 0;
        
        for(int i = 0; i < m; i++){
            cost[i] = Integer.parseInt(input2[i]);
            totalCost += cost[i];
        }
        
        out.println(n >= totalCost ? n - totalCost : -1);
        out.close();
        
    }
} public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        String[] input1 = br.readLine().split(" ");
        int n = Integer.parseInt(input1[0]);
        int m = Integer.parseInt(input1[1]);
        
        String[] input2 = br.readLine().split(" ");
        int[] cost = new int[m];
        int totalCost = 0;
        
        for(int i = 0; i < m; i++){
            cost[i] = Integer.parseInt(input2[i]);
            totalCost += cost[i];
        }
        
        out.println(n >= totalCost ? n - totalCost : -1);
        out.close();
        
    }
} Main
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        String[] input1 = br.readLine().split(" ");
        int n = Integer.parseInt(input1[0]);
        int m = Integer.parseInt(input1[1]);
        
        String[] input2 = br.readLine().split(" ");
        int[] cost = new int[m];
        int totalCost = 0;
        
        for(int i = 0; i < m; i++){
            cost[i] = Integer.parseInt(input2[i]);
            totalCost += cost[i];
        }
        
        out.println(n >= totalCost ? n - totalCost : -1);
        out.close();
        
    }
}