
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		int n = scanner.nextInt();
		int m = scanner.nextInt();
		int a =0;
		for(int i=0 ; i<m ; i++) {
			a = scanner.nextInt();
			if(a <= n) {
				n -= a;
			}else {
				n = -1;
				break;
			}
		}

		System.out.println(n);

		scanner.close();




	}

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

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		int n = scanner.nextInt();
		int m = scanner.nextInt();
		int a =0;
		for(int i=0 ; i<m ; i++) {
			a = scanner.nextInt();
			if(a <= n) {
				n -= a;
			}else {
				n = -1;
				break;
			}
		}

		System.out.println(n);

		scanner.close();




	}

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

		Scanner scanner = new Scanner(System.in);

		int n = scanner.nextInt();
		int m = scanner.nextInt();
		int a =0;
		for(int i=0 ; i<m ; i++) {
			a = scanner.nextInt();
			if(a <= n) {
				n -= a;
			}else {
				n = -1;
				break;
			}
		}

		System.out.println(n);

		scanner.close();




	} main {

		Scanner scanner = new Scanner(System.in);

		int n = scanner.nextInt();
		int m = scanner.nextInt();
		int a =0;
		for(int i=0 ; i<m ; i++) {
			a = scanner.nextInt();
			if(a <= n) {
				n -= a;
			}else {
				n = -1;
				break;
			}
		}

		System.out.println(n);

		scanner.close();




	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int n = scanner.nextInt(); n scanner.nextInt() scanner.nextInt scanner int m = scanner.nextInt(); m scanner.nextInt() scanner.nextInt scanner int a =0; a 0 for(int i=0 ; i<m ; i++) {
			a = scanner.nextInt();
			if(a <= n) {
				n -= a;
			}else {
				n = -1;
				break;
			}
		} int i=0 ; int i=0 ; i 0 i<m i m i++ i++ i {
			a = scanner.nextInt();
			if(a <= n) {
				n -= a;
			}else {
				n = -1;
				break;
			}
		} {
			a = scanner.nextInt();
			if(a <= n) {
				n -= a;
			}else {
				n = -1;
				break;
			}
		} a = scanner.nextInt() a scanner.nextInt() scanner.nextInt scanner if(a <= n) {
				n -= a;
			}else {
				n = -1;
				break;
			} a <= n a n {
				n -= a;
			} n -= a n a {
				n = -1;
				break;
			} n = -1 n -1 1 break; System.out.println(n) System.out.println System.out System System.out n scanner.close() scanner.close scanner String[] args args public class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		int n = scanner.nextInt();
		int m = scanner.nextInt();
		int a =0;
		for(int i=0 ; i<m ; i++) {
			a = scanner.nextInt();
			if(a <= n) {
				n -= a;
			}else {
				n = -1;
				break;
			}
		}

		System.out.println(n);

		scanner.close();




	}

} public class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		int n = scanner.nextInt();
		int m = scanner.nextInt();
		int a =0;
		for(int i=0 ; i<m ; i++) {
			a = scanner.nextInt();
			if(a <= n) {
				n -= a;
			}else {
				n = -1;
				break;
			}
		}

		System.out.println(n);

		scanner.close();




	}

} Main

import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		int n = scanner.nextInt();
		int m = scanner.nextInt();
		int a =0;
		for(int i=0 ; i<m ; i++) {
			a = scanner.nextInt();
			if(a <= n) {
				n -= a;
			}else {
				n = -1;
				break;
			}
		}

		System.out.println(n);

		scanner.close();




	}

}
