import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		int N = Integer.parseInt(tokens[0]);
		int M = Integer.parseInt(tokens[1]);
		int[] A = new int[M];
		tokens = in.readLine().split(" ");
		for (int i = 0; i < M; ++i) {
			A[i] = Integer.parseInt(tokens[i]);
		}
		long sum = 0;
		for (int i = 0; i < M; ++i) {
			sum += A[i];
		}
		if (sum > N) {
			System.out.println("-1");
		} else {
			System.out.println((N - sum));
		}
	}

	void calc() {
	}

	void showResult() {
	}
} import java.util.*; util.* java import java.util.stream.Collectors; Collectors java.util.stream import java.io.*; io.* java import java.nio.charset.StandardCharsets; StandardCharsets java.nio.charset public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		int N = Integer.parseInt(tokens[0]);
		int M = Integer.parseInt(tokens[1]);
		int[] A = new int[M];
		tokens = in.readLine().split(" ");
		for (int i = 0; i < M; ++i) {
			A[i] = Integer.parseInt(tokens[i]);
		}
		long sum = 0;
		for (int i = 0; i < M; ++i) {
			sum += A[i];
		}
		if (sum > N) {
			System.out.println("-1");
		} else {
			System.out.println((N - sum));
		}
	}

	void calc() {
	}

	void showResult() {
	}
} Main public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	} main {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	} InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8); reader new InputStreamReader(System.in, StandardCharsets.UTF_8) BufferedReader in = new BufferedReader(reader); in new BufferedReader(reader) Main ins = new Main(in); ins new Main(in) ins.calc() ins.calc ins ins.showResult() ins.showResult ins String[] args args Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		int N = Integer.parseInt(tokens[0]);
		int M = Integer.parseInt(tokens[1]);
		int[] A = new int[M];
		tokens = in.readLine().split(" ");
		for (int i = 0; i < M; ++i) {
			A[i] = Integer.parseInt(tokens[i]);
		}
		long sum = 0;
		for (int i = 0; i < M; ++i) {
			sum += A[i];
		}
		if (sum > N) {
			System.out.println("-1");
		} else {
			System.out.println((N - sum));
		}
	} Main {
		String[] tokens = in.readLine().split(" ");
		int N = Integer.parseInt(tokens[0]);
		int M = Integer.parseInt(tokens[1]);
		int[] A = new int[M];
		tokens = in.readLine().split(" ");
		for (int i = 0; i < M; ++i) {
			A[i] = Integer.parseInt(tokens[i]);
		}
		long sum = 0;
		for (int i = 0; i < M; ++i) {
			sum += A[i];
		}
		if (sum > N) {
			System.out.println("-1");
		} else {
			System.out.println((N - sum));
		}
	} String[] tokens = in.readLine().split(" "); tokens in.readLine().split(" ") in.readLine().split in.readLine() in.readLine in " " int N = Integer.parseInt(tokens[0]); N Integer.parseInt(tokens[0]) Integer.parseInt Integer tokens[0] tokens 0 int M = Integer.parseInt(tokens[1]); M Integer.parseInt(tokens[1]) Integer.parseInt Integer tokens[1] tokens 1 int[] A = new int[M]; A new int[M] M tokens = in.readLine().split(" ") tokens in.readLine().split(" ") in.readLine().split in.readLine() in.readLine in " " for (int i = 0; i < M; ++i) {
			A[i] = Integer.parseInt(tokens[i]);
		} int i = 0; int i = 0; i 0 i < M i M ++i ++i i {
			A[i] = Integer.parseInt(tokens[i]);
		} {
			A[i] = Integer.parseInt(tokens[i]);
		} A[i] = Integer.parseInt(tokens[i]) A[i] A i Integer.parseInt(tokens[i]) Integer.parseInt Integer tokens[i] tokens i long sum = 0; sum 0 for (int i = 0; i < M; ++i) {
			sum += A[i];
		} int i = 0; int i = 0; i 0 i < M i M ++i ++i i {
			sum += A[i];
		} {
			sum += A[i];
		} sum += A[i] sum A[i] A i if (sum > N) {
			System.out.println("-1");
		} else {
			System.out.println((N - sum));
		} sum > N sum N {
			System.out.println("-1");
		} System.out.println("-1") System.out.println System.out System System.out "-1" {
			System.out.println((N - sum));
		} System.out.println((N - sum)) System.out.println System.out System System.out (N - sum) N sum BufferedReader in in void calc() {
	} calc {
	} void showResult() {
	} showResult {
	} public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		int N = Integer.parseInt(tokens[0]);
		int M = Integer.parseInt(tokens[1]);
		int[] A = new int[M];
		tokens = in.readLine().split(" ");
		for (int i = 0; i < M; ++i) {
			A[i] = Integer.parseInt(tokens[i]);
		}
		long sum = 0;
		for (int i = 0; i < M; ++i) {
			sum += A[i];
		}
		if (sum > N) {
			System.out.println("-1");
		} else {
			System.out.println((N - sum));
		}
	}

	void calc() {
	}

	void showResult() {
	}
} public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		int N = Integer.parseInt(tokens[0]);
		int M = Integer.parseInt(tokens[1]);
		int[] A = new int[M];
		tokens = in.readLine().split(" ");
		for (int i = 0; i < M; ++i) {
			A[i] = Integer.parseInt(tokens[i]);
		}
		long sum = 0;
		for (int i = 0; i < M; ++i) {
			sum += A[i];
		}
		if (sum > N) {
			System.out.println("-1");
		} else {
			System.out.println((N - sum));
		}
	}

	void calc() {
	}

	void showResult() {
	}
} Main
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		int N = Integer.parseInt(tokens[0]);
		int M = Integer.parseInt(tokens[1]);
		int[] A = new int[M];
		tokens = in.readLine().split(" ");
		for (int i = 0; i < M; ++i) {
			A[i] = Integer.parseInt(tokens[i]);
		}
		long sum = 0;
		for (int i = 0; i < M; ++i) {
			sum += A[i];
		}
		if (sum > N) {
			System.out.println("-1");
		} else {
			System.out.println((N - sum));
		}
	}

	void calc() {
	}

	void showResult() {
	}
}
