import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    for(int i=0; i<M; i++){
      N -= sc.nextInt();
      if(N<0){
        System.out.print("-1");
        return;
      }
    }
    System.out.print(N);
  }
} import java.util.*; util.* java class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    for(int i=0; i<M; i++){
      N -= sc.nextInt();
      if(N<0){
        System.out.print("-1");
        return;
      }
    }
    System.out.print(N);
  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    for(int i=0; i<M; i++){
      N -= sc.nextInt();
      if(N<0){
        System.out.print("-1");
        return;
      }
    }
    System.out.print(N);
  } main {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    for(int i=0; i<M; i++){
      N -= sc.nextInt();
      if(N<0){
        System.out.print("-1");
        return;
      }
    }
    System.out.print(N);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int M = sc.nextInt(); M sc.nextInt() sc.nextInt sc for(int i=0; i<M; i++){
      N -= sc.nextInt();
      if(N<0){
        System.out.print("-1");
        return;
      }
    } int i=0; int i=0; i 0 i<M i M i++ i++ i {
      N -= sc.nextInt();
      if(N<0){
        System.out.print("-1");
        return;
      }
    } {
      N -= sc.nextInt();
      if(N<0){
        System.out.print("-1");
        return;
      }
    } N -= sc.nextInt() N sc.nextInt() sc.nextInt sc if(N<0){
        System.out.print("-1");
        return;
      } N<0 N 0 {
        System.out.print("-1");
        return;
      } System.out.print("-1") System.out.print System.out System System.out "-1" return; System.out.print(N) System.out.print System.out System System.out N String[] args args
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    for(int i=0; i<M; i++){
      N -= sc.nextInt();
      if(N<0){
        System.out.print("-1");
        return;
      }
    }
    System.out.print(N);
  }
}
