import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        long n = scan.nextLong(), m = scan.nextLong();
        for(int i = 0; i < m; i++) {
            n -= scan.nextLong();
            if(n < 0) {
                System.out.println(-1);
                scan.close();
                return;
            }
        }
        System.out.println(n);
        scan.close();
        return;
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        long n = scan.nextLong(), m = scan.nextLong();
        for(int i = 0; i < m; i++) {
            n -= scan.nextLong();
            if(n < 0) {
                System.out.println(-1);
                scan.close();
                return;
            }
        }
        System.out.println(n);
        scan.close();
        return;
    }
} Main public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        long n = scan.nextLong(), m = scan.nextLong();
        for(int i = 0; i < m; i++) {
            n -= scan.nextLong();
            if(n < 0) {
                System.out.println(-1);
                scan.close();
                return;
            }
        }
        System.out.println(n);
        scan.close();
        return;
    } main {
        Scanner scan = new Scanner(System.in);

        long n = scan.nextLong(), m = scan.nextLong();
        for(int i = 0; i < m; i++) {
            n -= scan.nextLong();
            if(n < 0) {
                System.out.println(-1);
                scan.close();
                return;
            }
        }
        System.out.println(n);
        scan.close();
        return;
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) long n = scan.nextLong() n scan.nextLong() scan.nextLong scan m = scan.nextLong(); m scan.nextLong() scan.nextLong scan for(int i = 0; i < m; i++) {
            n -= scan.nextLong();
            if(n < 0) {
                System.out.println(-1);
                scan.close();
                return;
            }
        } int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
            n -= scan.nextLong();
            if(n < 0) {
                System.out.println(-1);
                scan.close();
                return;
            }
        } {
            n -= scan.nextLong();
            if(n < 0) {
                System.out.println(-1);
                scan.close();
                return;
            }
        } n -= scan.nextLong() n scan.nextLong() scan.nextLong scan if(n < 0) {
                System.out.println(-1);
                scan.close();
                return;
            } n < 0 n 0 {
                System.out.println(-1);
                scan.close();
                return;
            } System.out.println(-1) System.out.println System.out System System.out -1 1 scan.close() scan.close scan return; System.out.println(n) System.out.println System.out System System.out n scan.close() scan.close scan return; String[] args args public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        long n = scan.nextLong(), m = scan.nextLong();
        for(int i = 0; i < m; i++) {
            n -= scan.nextLong();
            if(n < 0) {
                System.out.println(-1);
                scan.close();
                return;
            }
        }
        System.out.println(n);
        scan.close();
        return;
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        long n = scan.nextLong(), m = scan.nextLong();
        for(int i = 0; i < m; i++) {
            n -= scan.nextLong();
            if(n < 0) {
                System.out.println(-1);
                scan.close();
                return;
            }
        }
        System.out.println(n);
        scan.close();
        return;
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        long n = scan.nextLong(), m = scan.nextLong();
        for(int i = 0; i < m; i++) {
            n -= scan.nextLong();
            if(n < 0) {
                System.out.println(-1);
                scan.close();
                return;
            }
        }
        System.out.println(n);
        scan.close();
        return;
    }
}