import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
        String[] lines = getStdin();
        String[] str = lines[0].split(" ");
        int n = Integer.parseInt(str[0]);
        int m = Integer.parseInt(str[1]);
        String[] a = lines[1].split(" ");
        int[] aa = new int[a.length];
        int plus = 0;
        
            for (int i = 0; i < m; i++){
                aa[i] = Integer.parseInt(a[i]);
            }
            for(int i = 0; i < m; i++){
                 plus = plus + aa[i];
            }
            if(n >= plus){
                System.out.println(n - plus);
            } else {
                System.out.println(-1);
            }
   }
  private static String[] getStdin() {
    Scanner scanner = new Scanner(System.in);
    ArrayList<String> lines = new ArrayList<>();
    while (scanner.hasNext()) {
      lines.add(scanner.nextLine());
    }
    return lines.toArray(new String[lines.size()]);
  }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        String[] lines = getStdin();
        String[] str = lines[0].split(" ");
        int n = Integer.parseInt(str[0]);
        int m = Integer.parseInt(str[1]);
        String[] a = lines[1].split(" ");
        int[] aa = new int[a.length];
        int plus = 0;
        
            for (int i = 0; i < m; i++){
                aa[i] = Integer.parseInt(a[i]);
            }
            for(int i = 0; i < m; i++){
                 plus = plus + aa[i];
            }
            if(n >= plus){
                System.out.println(n - plus);
            } else {
                System.out.println(-1);
            }
   }
  private static String[] getStdin() {
    Scanner scanner = new Scanner(System.in);
    ArrayList<String> lines = new ArrayList<>();
    while (scanner.hasNext()) {
      lines.add(scanner.nextLine());
    }
    return lines.toArray(new String[lines.size()]);
  }
} Main public static void main(String[] args) throws Exception {
        String[] lines = getStdin();
        String[] str = lines[0].split(" ");
        int n = Integer.parseInt(str[0]);
        int m = Integer.parseInt(str[1]);
        String[] a = lines[1].split(" ");
        int[] aa = new int[a.length];
        int plus = 0;
        
            for (int i = 0; i < m; i++){
                aa[i] = Integer.parseInt(a[i]);
            }
            for(int i = 0; i < m; i++){
                 plus = plus + aa[i];
            }
            if(n >= plus){
                System.out.println(n - plus);
            } else {
                System.out.println(-1);
            }
   } main {
        String[] lines = getStdin();
        String[] str = lines[0].split(" ");
        int n = Integer.parseInt(str[0]);
        int m = Integer.parseInt(str[1]);
        String[] a = lines[1].split(" ");
        int[] aa = new int[a.length];
        int plus = 0;
        
            for (int i = 0; i < m; i++){
                aa[i] = Integer.parseInt(a[i]);
            }
            for(int i = 0; i < m; i++){
                 plus = plus + aa[i];
            }
            if(n >= plus){
                System.out.println(n - plus);
            } else {
                System.out.println(-1);
            }
   } String[] lines = getStdin(); lines getStdin() getStdin String[] str = lines[0].split(" "); str lines[0].split(" ") lines[0].split lines[0] lines 0 " " int n = Integer.parseInt(str[0]); n Integer.parseInt(str[0]) Integer.parseInt Integer str[0] str 0 int m = Integer.parseInt(str[1]); m Integer.parseInt(str[1]) Integer.parseInt Integer str[1] str 1 String[] a = lines[1].split(" "); a lines[1].split(" ") lines[1].split lines[1] lines 1 " " int[] aa = new int[a.length]; aa new int[a.length] a.length a a.length int plus = 0; plus 0 for (int i = 0; i < m; i++){
                aa[i] = Integer.parseInt(a[i]);
            } int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
                aa[i] = Integer.parseInt(a[i]);
            } {
                aa[i] = Integer.parseInt(a[i]);
            } aa[i] = Integer.parseInt(a[i]) aa[i] aa i Integer.parseInt(a[i]) Integer.parseInt Integer a[i] a i for(int i = 0; i < m; i++){
                 plus = plus + aa[i];
            } int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
                 plus = plus + aa[i];
            } {
                 plus = plus + aa[i];
            } plus = plus + aa[i] plus plus + aa[i] plus aa[i] aa i if(n >= plus){
                System.out.println(n - plus);
            } else {
                System.out.println(-1);
            } n >= plus n plus {
                System.out.println(n - plus);
            } System.out.println(n - plus) System.out.println System.out System System.out n - plus n plus {
                System.out.println(-1);
            } System.out.println(-1) System.out.println System.out System System.out -1 1 String[] args args private static String[] getStdin() {
    Scanner scanner = new Scanner(System.in);
    ArrayList<String> lines = new ArrayList<>();
    while (scanner.hasNext()) {
      lines.add(scanner.nextLine());
    }
    return lines.toArray(new String[lines.size()]);
  } getStdin {
    Scanner scanner = new Scanner(System.in);
    ArrayList<String> lines = new ArrayList<>();
    while (scanner.hasNext()) {
      lines.add(scanner.nextLine());
    }
    return lines.toArray(new String[lines.size()]);
  } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) ArrayList<String> lines = new ArrayList<>(); lines new ArrayList<>() while (scanner.hasNext()) {
      lines.add(scanner.nextLine());
    } scanner.hasNext() scanner.hasNext scanner {
      lines.add(scanner.nextLine());
    } lines.add(scanner.nextLine()) lines.add lines scanner.nextLine() scanner.nextLine scanner return lines.toArray(new String[lines.size()]); lines.toArray(new String[lines.size()]) lines.toArray lines new String[lines.size()] lines.size() lines.size lines public class Main {
    public static void main(String[] args) throws Exception {
        String[] lines = getStdin();
        String[] str = lines[0].split(" ");
        int n = Integer.parseInt(str[0]);
        int m = Integer.parseInt(str[1]);
        String[] a = lines[1].split(" ");
        int[] aa = new int[a.length];
        int plus = 0;
        
            for (int i = 0; i < m; i++){
                aa[i] = Integer.parseInt(a[i]);
            }
            for(int i = 0; i < m; i++){
                 plus = plus + aa[i];
            }
            if(n >= plus){
                System.out.println(n - plus);
            } else {
                System.out.println(-1);
            }
   }
  private static String[] getStdin() {
    Scanner scanner = new Scanner(System.in);
    ArrayList<String> lines = new ArrayList<>();
    while (scanner.hasNext()) {
      lines.add(scanner.nextLine());
    }
    return lines.toArray(new String[lines.size()]);
  }
} public class Main {
    public static void main(String[] args) throws Exception {
        String[] lines = getStdin();
        String[] str = lines[0].split(" ");
        int n = Integer.parseInt(str[0]);
        int m = Integer.parseInt(str[1]);
        String[] a = lines[1].split(" ");
        int[] aa = new int[a.length];
        int plus = 0;
        
            for (int i = 0; i < m; i++){
                aa[i] = Integer.parseInt(a[i]);
            }
            for(int i = 0; i < m; i++){
                 plus = plus + aa[i];
            }
            if(n >= plus){
                System.out.println(n - plus);
            } else {
                System.out.println(-1);
            }
   }
  private static String[] getStdin() {
    Scanner scanner = new Scanner(System.in);
    ArrayList<String> lines = new ArrayList<>();
    while (scanner.hasNext()) {
      lines.add(scanner.nextLine());
    }
    return lines.toArray(new String[lines.size()]);
  }
} Main
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
        String[] lines = getStdin();
        String[] str = lines[0].split(" ");
        int n = Integer.parseInt(str[0]);
        int m = Integer.parseInt(str[1]);
        String[] a = lines[1].split(" ");
        int[] aa = new int[a.length];
        int plus = 0;
        
            for (int i = 0; i < m; i++){
                aa[i] = Integer.parseInt(a[i]);
            }
            for(int i = 0; i < m; i++){
                 plus = plus + aa[i];
            }
            if(n >= plus){
                System.out.println(n - plus);
            } else {
                System.out.println(-1);
            }
   }
  private static String[] getStdin() {
    Scanner scanner = new Scanner(System.in);
    ArrayList<String> lines = new ArrayList<>();
    while (scanner.hasNext()) {
      lines.add(scanner.nextLine());
    }
    return lines.toArray(new String[lines.size()]);
  }
}