import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;

class Main {
    public static void main(String[] args){
        try{
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            String[] ss=br.readLine().split(" ");
            int n=Integer.parseInt(ss[0]);
            int m=Integer.parseInt(ss[1]);
            ss=br.readLine().split(" ");
            int[] arr=new int[m];
            long sum=0;
            for(int j=0;j<m;j++){
                arr[j]=Integer.parseInt(ss[j]);
                sum+=arr[j];
            }
            if(sum>n){
                System.out.println(-1);
            }else{
                System.out.println(n-sum);
            }



        }catch(Exception e){
            System.out.println("KKKK "+e.getMessage());
        }
    }
    static boolean check(int[] arr){
        int odd=0;
        for(int i=0;i<arr.length;i++){
            if(arr[i]%2!=0){
                odd++;
            }
        }
        if(odd<=1){
            return true;
        }
        return false;
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.ArrayList; ArrayList java.util import java.util.HashMap; HashMap java.util import java.util.HashSet; HashSet java.util import java.util.List; List java.util class Main {
    public static void main(String[] args){
        try{
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            String[] ss=br.readLine().split(" ");
            int n=Integer.parseInt(ss[0]);
            int m=Integer.parseInt(ss[1]);
            ss=br.readLine().split(" ");
            int[] arr=new int[m];
            long sum=0;
            for(int j=0;j<m;j++){
                arr[j]=Integer.parseInt(ss[j]);
                sum+=arr[j];
            }
            if(sum>n){
                System.out.println(-1);
            }else{
                System.out.println(n-sum);
            }



        }catch(Exception e){
            System.out.println("KKKK "+e.getMessage());
        }
    }
    static boolean check(int[] arr){
        int odd=0;
        for(int i=0;i<arr.length;i++){
            if(arr[i]%2!=0){
                odd++;
            }
        }
        if(odd<=1){
            return true;
        }
        return false;
    }
} Main public static void main(String[] args){
        try{
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            String[] ss=br.readLine().split(" ");
            int n=Integer.parseInt(ss[0]);
            int m=Integer.parseInt(ss[1]);
            ss=br.readLine().split(" ");
            int[] arr=new int[m];
            long sum=0;
            for(int j=0;j<m;j++){
                arr[j]=Integer.parseInt(ss[j]);
                sum+=arr[j];
            }
            if(sum>n){
                System.out.println(-1);
            }else{
                System.out.println(n-sum);
            }



        }catch(Exception e){
            System.out.println("KKKK "+e.getMessage());
        }
    } main {
        try{
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            String[] ss=br.readLine().split(" ");
            int n=Integer.parseInt(ss[0]);
            int m=Integer.parseInt(ss[1]);
            ss=br.readLine().split(" ");
            int[] arr=new int[m];
            long sum=0;
            for(int j=0;j<m;j++){
                arr[j]=Integer.parseInt(ss[j]);
                sum+=arr[j];
            }
            if(sum>n){
                System.out.println(-1);
            }else{
                System.out.println(n-sum);
            }



        }catch(Exception e){
            System.out.println("KKKK "+e.getMessage());
        }
    } try{
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            String[] ss=br.readLine().split(" ");
            int n=Integer.parseInt(ss[0]);
            int m=Integer.parseInt(ss[1]);
            ss=br.readLine().split(" ");
            int[] arr=new int[m];
            long sum=0;
            for(int j=0;j<m;j++){
                arr[j]=Integer.parseInt(ss[j]);
                sum+=arr[j];
            }
            if(sum>n){
                System.out.println(-1);
            }else{
                System.out.println(n-sum);
            }



        }catch(Exception e){
            System.out.println("KKKK "+e.getMessage());
        } catch(Exception e){
            System.out.println("KKKK "+e.getMessage());
        } Exception e {
            System.out.println("KKKK "+e.getMessage());
        } System.out.println("KKKK "+e.getMessage()) System.out.println System.out System System.out "KKKK "+e.getMessage() "KKKK " e.getMessage() e.getMessage e {
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            String[] ss=br.readLine().split(" ");
            int n=Integer.parseInt(ss[0]);
            int m=Integer.parseInt(ss[1]);
            ss=br.readLine().split(" ");
            int[] arr=new int[m];
            long sum=0;
            for(int j=0;j<m;j++){
                arr[j]=Integer.parseInt(ss[j]);
                sum+=arr[j];
            }
            if(sum>n){
                System.out.println(-1);
            }else{
                System.out.println(n-sum);
            }



        } BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] ss=br.readLine().split(" "); ss br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " 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=br.readLine().split(" ") ss br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int[] arr=new int[m]; arr new int[m] m long sum=0; sum 0 for(int j=0;j<m;j++){
                arr[j]=Integer.parseInt(ss[j]);
                sum+=arr[j];
            } int j=0; int j=0; j 0 j<m j m j++ j++ j {
                arr[j]=Integer.parseInt(ss[j]);
                sum+=arr[j];
            } {
                arr[j]=Integer.parseInt(ss[j]);
                sum+=arr[j];
            } arr[j]=Integer.parseInt(ss[j]) arr[j] arr j Integer.parseInt(ss[j]) Integer.parseInt Integer ss[j] ss j sum+=arr[j] sum arr[j] arr j if(sum>n){
                System.out.println(-1);
            }else{
                System.out.println(n-sum);
            } sum>n sum n {
                System.out.println(-1);
            } System.out.println(-1) System.out.println System.out System System.out -1 1 {
                System.out.println(n-sum);
            } System.out.println(n-sum) System.out.println System.out System System.out n-sum n sum String[] args args static boolean check(int[] arr){
        int odd=0;
        for(int i=0;i<arr.length;i++){
            if(arr[i]%2!=0){
                odd++;
            }
        }
        if(odd<=1){
            return true;
        }
        return false;
    } check {
        int odd=0;
        for(int i=0;i<arr.length;i++){
            if(arr[i]%2!=0){
                odd++;
            }
        }
        if(odd<=1){
            return true;
        }
        return false;
    } int odd=0; odd 0 for(int i=0;i<arr.length;i++){
            if(arr[i]%2!=0){
                odd++;
            }
        } int i=0; int i=0; i 0 i<arr.length i arr.length arr arr.length i++ i++ i {
            if(arr[i]%2!=0){
                odd++;
            }
        } {
            if(arr[i]%2!=0){
                odd++;
            }
        } if(arr[i]%2!=0){
                odd++;
            } arr[i]%2!=0 arr[i]%2 arr[i] arr i 2 0 {
                odd++;
            } odd++ odd if(odd<=1){
            return true;
        } odd<=1 odd 1 {
            return true;
        } return true; true return false; false int[] arr arr
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;

class Main {
    public static void main(String[] args){
        try{
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            String[] ss=br.readLine().split(" ");
            int n=Integer.parseInt(ss[0]);
            int m=Integer.parseInt(ss[1]);
            ss=br.readLine().split(" ");
            int[] arr=new int[m];
            long sum=0;
            for(int j=0;j<m;j++){
                arr[j]=Integer.parseInt(ss[j]);
                sum+=arr[j];
            }
            if(sum>n){
                System.out.println(-1);
            }else{
                System.out.println(n-sum);
            }



        }catch(Exception e){
            System.out.println("KKKK "+e.getMessage());
        }
    }
    static boolean check(int[] arr){
        int odd=0;
        for(int i=0;i<arr.length;i++){
            if(arr[i]%2!=0){
                odd++;
            }
        }
        if(odd<=1){
            return true;
        }
        return false;
    }
}