import java.util.Scanner;

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

		// 入力値の取得
		int N = sc.nextInt();
		int M = sc.nextInt();
		long sum = 0;
		for (int i = 0; i < M; i++) {
			sum += sc.nextInt();
			if (sum > N) {
				System.out.println(-1);
				sc.close();
				return;
			}
		}
		
		// 結果の出力
		System.out.println(N - sum);

		sc.close();
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		// 入力値の取得
		int N = sc.nextInt();
		int M = sc.nextInt();
		long sum = 0;
		for (int i = 0; i < M; i++) {
			sum += sc.nextInt();
			if (sum > N) {
				System.out.println(-1);
				sc.close();
				return;
			}
		}
		
		// 結果の出力
		System.out.println(N - sum);

		sc.close();
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		// 入力値の取得
		int N = sc.nextInt();
		int M = sc.nextInt();
		long sum = 0;
		for (int i = 0; i < M; i++) {
			sum += sc.nextInt();
			if (sum > N) {
				System.out.println(-1);
				sc.close();
				return;
			}
		}
		
		// 結果の出力
		System.out.println(N - sum);

		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);

		// 入力値の取得
		int N = sc.nextInt();
		int M = sc.nextInt();
		long sum = 0;
		for (int i = 0; i < M; i++) {
			sum += sc.nextInt();
			if (sum > N) {
				System.out.println(-1);
				sc.close();
				return;
			}
		}
		
		// 結果の出力
		System.out.println(N - sum);

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

		// 入力値の取得
		int N = sc.nextInt();
		int M = sc.nextInt();
		long sum = 0;
		for (int i = 0; i < M; i++) {
			sum += sc.nextInt();
			if (sum > N) {
				System.out.println(-1);
				sc.close();
				return;
			}
		}
		
		// 結果の出力
		System.out.println(N - sum);

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

		// 入力値の取得
		int N = sc.nextInt();
		int M = sc.nextInt();
		long sum = 0;
		for (int i = 0; i < M; i++) {
			sum += sc.nextInt();
			if (sum > N) {
				System.out.println(-1);
				sc.close();
				return;
			}
		}
		
		// 結果の出力
		System.out.println(N - sum);

		sc.close();
	}
} Main
import java.util.Scanner;

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

		// 入力値の取得
		int N = sc.nextInt();
		int M = sc.nextInt();
		long sum = 0;
		for (int i = 0; i < M; i++) {
			sum += sc.nextInt();
			if (sum > N) {
				System.out.println(-1);
				sc.close();
				return;
			}
		}
		
		// 結果の出力
		System.out.println(N - sum);

		sc.close();
	}
}
