import java.util.Scanner;
public class Main{


    public static void main(String[] args) {


        Scanner reader = new Scanner(System.in);

        int N = reader.nextInt();
        int M = reader.nextInt();
        int Total =0;
        int b=0;

        for (int i = 0; i <M; i++) {
            int A = reader.nextInt();

             Total +=A;

            if (Total>N){

             b=-1;
            } else {
                b = N-Total;


            }

        }

        System.out.println(b);


    }

}

 import java.util.Scanner; Scanner java.util public class Main{


    public static void main(String[] args) {


        Scanner reader = new Scanner(System.in);

        int N = reader.nextInt();
        int M = reader.nextInt();
        int Total =0;
        int b=0;

        for (int i = 0; i <M; i++) {
            int A = reader.nextInt();

             Total +=A;

            if (Total>N){

             b=-1;
            } else {
                b = N-Total;


            }

        }

        System.out.println(b);


    }

} Main public static void main(String[] args) {


        Scanner reader = new Scanner(System.in);

        int N = reader.nextInt();
        int M = reader.nextInt();
        int Total =0;
        int b=0;

        for (int i = 0; i <M; i++) {
            int A = reader.nextInt();

             Total +=A;

            if (Total>N){

             b=-1;
            } else {
                b = N-Total;


            }

        }

        System.out.println(b);


    } main {


        Scanner reader = new Scanner(System.in);

        int N = reader.nextInt();
        int M = reader.nextInt();
        int Total =0;
        int b=0;

        for (int i = 0; i <M; i++) {
            int A = reader.nextInt();

             Total +=A;

            if (Total>N){

             b=-1;
            } else {
                b = N-Total;


            }

        }

        System.out.println(b);


    } Scanner reader = new Scanner(System.in); reader new Scanner(System.in) int N = reader.nextInt(); N reader.nextInt() reader.nextInt reader int M = reader.nextInt(); M reader.nextInt() reader.nextInt reader int Total =0; Total 0 int b=0; b 0 for (int i = 0; i <M; i++) {
            int A = reader.nextInt();

             Total +=A;

            if (Total>N){

             b=-1;
            } else {
                b = N-Total;


            }

        } int i = 0; int i = 0; i 0 i <M i M i++ i++ i {
            int A = reader.nextInt();

             Total +=A;

            if (Total>N){

             b=-1;
            } else {
                b = N-Total;


            }

        } {
            int A = reader.nextInt();

             Total +=A;

            if (Total>N){

             b=-1;
            } else {
                b = N-Total;


            }

        } int A = reader.nextInt(); A reader.nextInt() reader.nextInt reader Total +=A Total A if (Total>N){

             b=-1;
            } else {
                b = N-Total;


            } Total>N Total N {

             b=-1;
            } b=-1 b -1 1 {
                b = N-Total;


            } b = N-Total b N-Total N Total System.out.println(b) System.out.println System.out System System.out b String[] args args public class Main{


    public static void main(String[] args) {


        Scanner reader = new Scanner(System.in);

        int N = reader.nextInt();
        int M = reader.nextInt();
        int Total =0;
        int b=0;

        for (int i = 0; i <M; i++) {
            int A = reader.nextInt();

             Total +=A;

            if (Total>N){

             b=-1;
            } else {
                b = N-Total;


            }

        }

        System.out.println(b);


    }

} public class Main{


    public static void main(String[] args) {


        Scanner reader = new Scanner(System.in);

        int N = reader.nextInt();
        int M = reader.nextInt();
        int Total =0;
        int b=0;

        for (int i = 0; i <M; i++) {
            int A = reader.nextInt();

             Total +=A;

            if (Total>N){

             b=-1;
            } else {
                b = N-Total;


            }

        }

        System.out.println(b);


    }

} Main
import java.util.Scanner;
public class Main{


    public static void main(String[] args) {


        Scanner reader = new Scanner(System.in);

        int N = reader.nextInt();
        int M = reader.nextInt();
        int Total =0;
        int b=0;

        for (int i = 0; i <M; i++) {
            int A = reader.nextInt();

             Total +=A;

            if (Total>N){

             b=-1;
            } else {
                b = N-Total;


            }

        }

        System.out.println(b);


    }

}


