import java.util.Scanner;

/**
 *
 * @author Masaya Misaizu
 */
public class Main {
    private static int error =-1;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        if(a> Math.pow(10,6))
           {
               System.out.println(error);
               System.exit(0);
           }
        int b = sc.nextInt();
            if(b> Math.pow(10,4))
            {
                System.out.println(error);
                System.exit(0);
            }
        int sum = 0;
        for (int i = 0; i < b ; i++) {
            int c = sc.nextInt();
            if(c> Math.pow(10,4))
               {
                   System.out.println(error);
                   System.exit(0);
               }
            if(a>=sum)
                {
                    sum+=c;
                }
            else
                break;
            }
        if(a < sum){
            System.out.println(error);
        }
        else
            System.out.println(a-sum);
            
    

            }
} import java.util.Scanner; Scanner java.util public class Main {
    private static int error =-1;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        if(a> Math.pow(10,6))
           {
               System.out.println(error);
               System.exit(0);
           }
        int b = sc.nextInt();
            if(b> Math.pow(10,4))
            {
                System.out.println(error);
                System.exit(0);
            }
        int sum = 0;
        for (int i = 0; i < b ; i++) {
            int c = sc.nextInt();
            if(c> Math.pow(10,4))
               {
                   System.out.println(error);
                   System.exit(0);
               }
            if(a>=sum)
                {
                    sum+=c;
                }
            else
                break;
            }
        if(a < sum){
            System.out.println(error);
        }
        else
            System.out.println(a-sum);
            
    

            }
} Main private static int error =-1; error -1 1 public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        if(a> Math.pow(10,6))
           {
               System.out.println(error);
               System.exit(0);
           }
        int b = sc.nextInt();
            if(b> Math.pow(10,4))
            {
                System.out.println(error);
                System.exit(0);
            }
        int sum = 0;
        for (int i = 0; i < b ; i++) {
            int c = sc.nextInt();
            if(c> Math.pow(10,4))
               {
                   System.out.println(error);
                   System.exit(0);
               }
            if(a>=sum)
                {
                    sum+=c;
                }
            else
                break;
            }
        if(a < sum){
            System.out.println(error);
        }
        else
            System.out.println(a-sum);
            
    

            } main {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        if(a> Math.pow(10,6))
           {
               System.out.println(error);
               System.exit(0);
           }
        int b = sc.nextInt();
            if(b> Math.pow(10,4))
            {
                System.out.println(error);
                System.exit(0);
            }
        int sum = 0;
        for (int i = 0; i < b ; i++) {
            int c = sc.nextInt();
            if(c> Math.pow(10,4))
               {
                   System.out.println(error);
                   System.exit(0);
               }
            if(a>=sum)
                {
                    sum+=c;
                }
            else
                break;
            }
        if(a < sum){
            System.out.println(error);
        }
        else
            System.out.println(a-sum);
            
    

            } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc if(a> Math.pow(10,6))
           {
               System.out.println(error);
               System.exit(0);
           } a> Math.pow(10,6) a Math.pow(10,6) Math.pow Math 10 6 {
               System.out.println(error);
               System.exit(0);
           } System.out.println(error) System.out.println System.out System System.out error System.exit(0) System.exit System 0 int b = sc.nextInt(); b sc.nextInt() sc.nextInt sc if(b> Math.pow(10,4))
            {
                System.out.println(error);
                System.exit(0);
            } b> Math.pow(10,4) b Math.pow(10,4) Math.pow Math 10 4 {
                System.out.println(error);
                System.exit(0);
            } System.out.println(error) System.out.println System.out System System.out error System.exit(0) System.exit System 0 int sum = 0; sum 0 for (int i = 0; i < b ; i++) {
            int c = sc.nextInt();
            if(c> Math.pow(10,4))
               {
                   System.out.println(error);
                   System.exit(0);
               }
            if(a>=sum)
                {
                    sum+=c;
                }
            else
                break;
            } int i = 0; int i = 0; i 0 i < b i b i++ i++ i {
            int c = sc.nextInt();
            if(c> Math.pow(10,4))
               {
                   System.out.println(error);
                   System.exit(0);
               }
            if(a>=sum)
                {
                    sum+=c;
                }
            else
                break;
            } {
            int c = sc.nextInt();
            if(c> Math.pow(10,4))
               {
                   System.out.println(error);
                   System.exit(0);
               }
            if(a>=sum)
                {
                    sum+=c;
                }
            else
                break;
            } int c = sc.nextInt(); c sc.nextInt() sc.nextInt sc if(c> Math.pow(10,4))
               {
                   System.out.println(error);
                   System.exit(0);
               } c> Math.pow(10,4) c Math.pow(10,4) Math.pow Math 10 4 {
                   System.out.println(error);
                   System.exit(0);
               } System.out.println(error) System.out.println System.out System System.out error System.exit(0) System.exit System 0 if(a>=sum)
                {
                    sum+=c;
                }
            else
                break; a>=sum a sum {
                    sum+=c;
                } sum+=c sum c break; if(a < sum){
            System.out.println(error);
        }
        else
            System.out.println(a-sum); a < sum a sum {
            System.out.println(error);
        } System.out.println(error) System.out.println System.out System System.out error System.out.println(a-sum) System.out.println System.out System System.out a-sum a sum String[] args args public class Main {
    private static int error =-1;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        if(a> Math.pow(10,6))
           {
               System.out.println(error);
               System.exit(0);
           }
        int b = sc.nextInt();
            if(b> Math.pow(10,4))
            {
                System.out.println(error);
                System.exit(0);
            }
        int sum = 0;
        for (int i = 0; i < b ; i++) {
            int c = sc.nextInt();
            if(c> Math.pow(10,4))
               {
                   System.out.println(error);
                   System.exit(0);
               }
            if(a>=sum)
                {
                    sum+=c;
                }
            else
                break;
            }
        if(a < sum){
            System.out.println(error);
        }
        else
            System.out.println(a-sum);
            
    

            }
} public class Main {
    private static int error =-1;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        if(a> Math.pow(10,6))
           {
               System.out.println(error);
               System.exit(0);
           }
        int b = sc.nextInt();
            if(b> Math.pow(10,4))
            {
                System.out.println(error);
                System.exit(0);
            }
        int sum = 0;
        for (int i = 0; i < b ; i++) {
            int c = sc.nextInt();
            if(c> Math.pow(10,4))
               {
                   System.out.println(error);
                   System.exit(0);
               }
            if(a>=sum)
                {
                    sum+=c;
                }
            else
                break;
            }
        if(a < sum){
            System.out.println(error);
        }
        else
            System.out.println(a-sum);
            
    

            }
} Main
import java.util.Scanner;

/**
 *
 * @author Masaya Misaizu
 */
public class Main {
    private static int error =-1;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        if(a> Math.pow(10,6))
           {
               System.out.println(error);
               System.exit(0);
           }
        int b = sc.nextInt();
            if(b> Math.pow(10,4))
            {
                System.out.println(error);
                System.exit(0);
            }
        int sum = 0;
        for (int i = 0; i < b ; i++) {
            int c = sc.nextInt();
            if(c> Math.pow(10,4))
               {
                   System.out.println(error);
                   System.exit(0);
               }
            if(a>=sum)
                {
                    sum+=c;
                }
            else
                break;
            }
        if(a < sum){
            System.out.println(error);
        }
        else
            System.out.println(a-sum);
            
    

            }
}
