
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();
        int a[] = new int[m];
        for(int i=0;i<m;i++){
            a[i] = sc.nextInt();
        }
        int sum = 0;
        for(int j=0;j<m;j++){
            sum = sum + a[j];
        }
        if(sum>n){
            System.out.println(-1);
            return;
        }
        n = n - sum;
        System.out.println(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();
        int a[] = new int[m];
        for(int i=0;i<m;i++){
            a[i] = sc.nextInt();
        }
        int sum = 0;
        for(int j=0;j<m;j++){
            sum = sum + a[j];
        }
        if(sum>n){
            System.out.println(-1);
            return;
        }
        n = n - sum;
        System.out.println(n);
    } 
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int a[] = new int[m];
        for(int i=0;i<m;i++){
            a[i] = sc.nextInt();
        }
        int sum = 0;
        for(int j=0;j<m;j++){
            sum = sum + a[j];
        }
        if(sum>n){
            System.out.println(-1);
            return;
        }
        n = n - sum;
        System.out.println(n);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int a[] = new int[m];
        for(int i=0;i<m;i++){
            a[i] = sc.nextInt();
        }
        int sum = 0;
        for(int j=0;j<m;j++){
            sum = sum + a[j];
        }
        if(sum>n){
            System.out.println(-1);
            return;
        }
        n = n - sum;
        System.out.println(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 int a[] = new int[m]; a new int[m] m for(int i=0;i<m;i++){
            a[i] = sc.nextInt();
        } int i=0; int i=0; i 0 i<m i m i++ i++ i {
            a[i] = sc.nextInt();
        } {
            a[i] = sc.nextInt();
        } a[i] = sc.nextInt() a[i] a i sc.nextInt() sc.nextInt sc int sum = 0; sum 0 for(int j=0;j<m;j++){
            sum = sum + a[j];
        } int j=0; int j=0; j 0 j<m j m j++ j++ j {
            sum = sum + a[j];
        } {
            sum = sum + a[j];
        } sum = sum + a[j] sum sum + a[j] sum a[j] a j if(sum>n){
            System.out.println(-1);
            return;
        } sum>n sum n {
            System.out.println(-1);
            return;
        } System.out.println(-1) System.out.println System.out System System.out -1 1 return; n = n - sum n n - sum n sum System.out.println(n) System.out.println 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();
        int a[] = new int[m];
        for(int i=0;i<m;i++){
            a[i] = sc.nextInt();
        }
        int sum = 0;
        for(int j=0;j<m;j++){
            sum = sum + a[j];
        }
        if(sum>n){
            System.out.println(-1);
            return;
        }
        n = n - sum;
        System.out.println(n);
    } 
}