import java.util.Scanner;

public class Main {
  public static void main(String[] main) {
    Scanner input = new Scanner(System.in);
    String[] ss = input.nextLine().split(" ");
    int n = Integer.parseInt(ss[0]);
    int m = Integer.parseInt(ss[1]);
    ss = input.nextLine().split(" ");
    int total = 0;
    for (int i = 0; i < m; i++) {
      total += Integer.parseInt(ss[i]);
    }
    if (n < total) {
      System.out.println("-1");
    } else {
      System.out.println(n - total);
    }
  }
} import java.util.Scanner; Scanner java.util public class Main {
  public static void main(String[] main) {
    Scanner input = new Scanner(System.in);
    String[] ss = input.nextLine().split(" ");
    int n = Integer.parseInt(ss[0]);
    int m = Integer.parseInt(ss[1]);
    ss = input.nextLine().split(" ");
    int total = 0;
    for (int i = 0; i < m; i++) {
      total += Integer.parseInt(ss[i]);
    }
    if (n < total) {
      System.out.println("-1");
    } else {
      System.out.println(n - total);
    }
  }
} Main public static void main(String[] main) {
    Scanner input = new Scanner(System.in);
    String[] ss = input.nextLine().split(" ");
    int n = Integer.parseInt(ss[0]);
    int m = Integer.parseInt(ss[1]);
    ss = input.nextLine().split(" ");
    int total = 0;
    for (int i = 0; i < m; i++) {
      total += Integer.parseInt(ss[i]);
    }
    if (n < total) {
      System.out.println("-1");
    } else {
      System.out.println(n - total);
    }
  } main {
    Scanner input = new Scanner(System.in);
    String[] ss = input.nextLine().split(" ");
    int n = Integer.parseInt(ss[0]);
    int m = Integer.parseInt(ss[1]);
    ss = input.nextLine().split(" ");
    int total = 0;
    for (int i = 0; i < m; i++) {
      total += Integer.parseInt(ss[i]);
    }
    if (n < total) {
      System.out.println("-1");
    } else {
      System.out.println(n - total);
    }
  } Scanner input = new Scanner(System.in); input new Scanner(System.in) String[] ss = input.nextLine().split(" "); ss input.nextLine().split(" ") input.nextLine().split input.nextLine() input.nextLine input " " int n = Integer.parseInt(ss[0]); n Integer.parseInt(ss[0]) Integer.parseInt Integer ss[0] ss 0 int m = Integer.parseInt(ss[1]); m Integer.parseInt(ss[1]) Integer.parseInt Integer ss[1] ss 1 ss = input.nextLine().split(" ") ss input.nextLine().split(" ") input.nextLine().split input.nextLine() input.nextLine input " " int total = 0; total 0 for (int i = 0; i < m; i++) {
      total += Integer.parseInt(ss[i]);
    } int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
      total += Integer.parseInt(ss[i]);
    } {
      total += Integer.parseInt(ss[i]);
    } total += Integer.parseInt(ss[i]) total Integer.parseInt(ss[i]) Integer.parseInt Integer ss[i] ss i if (n < total) {
      System.out.println("-1");
    } else {
      System.out.println(n - total);
    } n < total n total {
      System.out.println("-1");
    } System.out.println("-1") System.out.println System.out System System.out "-1" {
      System.out.println(n - total);
    } System.out.println(n - total) System.out.println System.out System System.out n - total n total String[] main main public class Main {
  public static void main(String[] main) {
    Scanner input = new Scanner(System.in);
    String[] ss = input.nextLine().split(" ");
    int n = Integer.parseInt(ss[0]);
    int m = Integer.parseInt(ss[1]);
    ss = input.nextLine().split(" ");
    int total = 0;
    for (int i = 0; i < m; i++) {
      total += Integer.parseInt(ss[i]);
    }
    if (n < total) {
      System.out.println("-1");
    } else {
      System.out.println(n - total);
    }
  }
} public class Main {
  public static void main(String[] main) {
    Scanner input = new Scanner(System.in);
    String[] ss = input.nextLine().split(" ");
    int n = Integer.parseInt(ss[0]);
    int m = Integer.parseInt(ss[1]);
    ss = input.nextLine().split(" ");
    int total = 0;
    for (int i = 0; i < m; i++) {
      total += Integer.parseInt(ss[i]);
    }
    if (n < total) {
      System.out.println("-1");
    } else {
      System.out.println(n - total);
    }
  }
} Main
import java.util.Scanner;

public class Main {
  public static void main(String[] main) {
    Scanner input = new Scanner(System.in);
    String[] ss = input.nextLine().split(" ");
    int n = Integer.parseInt(ss[0]);
    int m = Integer.parseInt(ss[1]);
    ss = input.nextLine().split(" ");
    int total = 0;
    for (int i = 0; i < m; i++) {
      total += Integer.parseInt(ss[i]);
    }
    if (n < total) {
      System.out.println("-1");
    } else {
      System.out.println(n - total);
    }
  }
}