import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        String[] lines = getStdin();
        String line = lines[0];
        String[] a = line.split(" ");
        int term = Integer.parseInt(a[0]);
        int num = Integer.parseInt(a[1]);

        String line1 = lines[1];
        String[] b = line1.split(" ");
        //int cost = Integer.parseInt(b[i]);

        for (int i = 0; i < num; i++){
            int cost = Integer.parseInt(b[i]);
            term = term - cost;
        }
        if (term < 0){
            System.out.println("-1");
        } else if (term >= 0){
            System.out.println(term);
        }




    }
  
  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 line = lines[0];
        String[] a = line.split(" ");
        int term = Integer.parseInt(a[0]);
        int num = Integer.parseInt(a[1]);

        String line1 = lines[1];
        String[] b = line1.split(" ");
        //int cost = Integer.parseInt(b[i]);

        for (int i = 0; i < num; i++){
            int cost = Integer.parseInt(b[i]);
            term = term - cost;
        }
        if (term < 0){
            System.out.println("-1");
        } else if (term >= 0){
            System.out.println(term);
        }




    }
  
  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 line = lines[0];
        String[] a = line.split(" ");
        int term = Integer.parseInt(a[0]);
        int num = Integer.parseInt(a[1]);

        String line1 = lines[1];
        String[] b = line1.split(" ");
        //int cost = Integer.parseInt(b[i]);

        for (int i = 0; i < num; i++){
            int cost = Integer.parseInt(b[i]);
            term = term - cost;
        }
        if (term < 0){
            System.out.println("-1");
        } else if (term >= 0){
            System.out.println(term);
        }




    } main {
        String[] lines = getStdin();
        String line = lines[0];
        String[] a = line.split(" ");
        int term = Integer.parseInt(a[0]);
        int num = Integer.parseInt(a[1]);

        String line1 = lines[1];
        String[] b = line1.split(" ");
        //int cost = Integer.parseInt(b[i]);

        for (int i = 0; i < num; i++){
            int cost = Integer.parseInt(b[i]);
            term = term - cost;
        }
        if (term < 0){
            System.out.println("-1");
        } else if (term >= 0){
            System.out.println(term);
        }




    } String[] lines = getStdin(); lines getStdin() getStdin String line = lines[0]; line lines[0] lines 0 String[] a = line.split(" "); a line.split(" ") line.split line " " int term = Integer.parseInt(a[0]); term Integer.parseInt(a[0]) Integer.parseInt Integer a[0] a 0 int num = Integer.parseInt(a[1]); num Integer.parseInt(a[1]) Integer.parseInt Integer a[1] a 1 String line1 = lines[1]; line1 lines[1] lines 1 String[] b = line1.split(" "); b line1.split(" ") line1.split line1 " " for (int i = 0; i < num; i++){
            int cost = Integer.parseInt(b[i]);
            term = term - cost;
        } int i = 0; int i = 0; i 0 i < num i num i++ i++ i {
            int cost = Integer.parseInt(b[i]);
            term = term - cost;
        } {
            int cost = Integer.parseInt(b[i]);
            term = term - cost;
        } int cost = Integer.parseInt(b[i]); cost Integer.parseInt(b[i]) Integer.parseInt Integer b[i] b i term = term - cost term term - cost term cost if (term < 0){
            System.out.println("-1");
        } else if (term >= 0){
            System.out.println(term);
        } term < 0 term 0 {
            System.out.println("-1");
        } System.out.println("-1") System.out.println System.out System System.out "-1" if (term >= 0){
            System.out.println(term);
        } term >= 0 term 0 {
            System.out.println(term);
        } System.out.println(term) System.out.println System.out System System.out term 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 line = lines[0];
        String[] a = line.split(" ");
        int term = Integer.parseInt(a[0]);
        int num = Integer.parseInt(a[1]);

        String line1 = lines[1];
        String[] b = line1.split(" ");
        //int cost = Integer.parseInt(b[i]);

        for (int i = 0; i < num; i++){
            int cost = Integer.parseInt(b[i]);
            term = term - cost;
        }
        if (term < 0){
            System.out.println("-1");
        } else if (term >= 0){
            System.out.println(term);
        }




    }
  
  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 line = lines[0];
        String[] a = line.split(" ");
        int term = Integer.parseInt(a[0]);
        int num = Integer.parseInt(a[1]);

        String line1 = lines[1];
        String[] b = line1.split(" ");
        //int cost = Integer.parseInt(b[i]);

        for (int i = 0; i < num; i++){
            int cost = Integer.parseInt(b[i]);
            term = term - cost;
        }
        if (term < 0){
            System.out.println("-1");
        } else if (term >= 0){
            System.out.println(term);
        }




    }
  
  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 line = lines[0];
        String[] a = line.split(" ");
        int term = Integer.parseInt(a[0]);
        int num = Integer.parseInt(a[1]);

        String line1 = lines[1];
        String[] b = line1.split(" ");
        //int cost = Integer.parseInt(b[i]);

        for (int i = 0; i < num; i++){
            int cost = Integer.parseInt(b[i]);
            term = term - cost;
        }
        if (term < 0){
            System.out.println("-1");
        } else if (term >= 0){
            System.out.println(term);
        }




    }
  
  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()]);
  }
  
}
