import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) throws Exception{
		int num = 998244353;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
//	 		String input1 = bf.readLine().trim();
//	 		String input2 = bf.readLine().trim();
	 		StringTokenizer st = new StringTokenizer(bf.readLine());
	 		long n = Long.parseLong(st.nextToken());
	 		long m = Long.parseLong(st.nextToken());
	 		ArrayList<Integer> array = new ArrayList<Integer>();
	 		StringTokenizer st2 = new StringTokenizer(bf.readLine());
	 		long sum = 0;
	 		for(int j=0;j<m;j++){
	 			array.add(Integer.parseInt(st2.nextToken()));
	 			sum+=(long)(array.get(j));
	 		}
	 		if (sum > n)
	 			out.println(-1);
	 		else
	 			out.println(n-sum);
 		
 		
 		out.println();
	 		
 		out.close();
 		
 		
 		
 	}
}
 	
 
//StringJoiner sj = new StringJoiner(" "); 
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is

 		
 		
 		
 		
	

 import java.util.*; util.* java import java.io.*; io.* java public class Main {

	public static void main(String[] args) throws Exception{
		int num = 998244353;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
//	 		String input1 = bf.readLine().trim();
//	 		String input2 = bf.readLine().trim();
	 		StringTokenizer st = new StringTokenizer(bf.readLine());
	 		long n = Long.parseLong(st.nextToken());
	 		long m = Long.parseLong(st.nextToken());
	 		ArrayList<Integer> array = new ArrayList<Integer>();
	 		StringTokenizer st2 = new StringTokenizer(bf.readLine());
	 		long sum = 0;
	 		for(int j=0;j<m;j++){
	 			array.add(Integer.parseInt(st2.nextToken()));
	 			sum+=(long)(array.get(j));
	 		}
	 		if (sum > n)
	 			out.println(-1);
	 		else
	 			out.println(n-sum);
 		
 		
 		out.println();
	 		
 		out.close();
 		
 		
 		
 	}
} Main public static void main(String[] args) throws Exception{
		int num = 998244353;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
//	 		String input1 = bf.readLine().trim();
//	 		String input2 = bf.readLine().trim();
	 		StringTokenizer st = new StringTokenizer(bf.readLine());
	 		long n = Long.parseLong(st.nextToken());
	 		long m = Long.parseLong(st.nextToken());
	 		ArrayList<Integer> array = new ArrayList<Integer>();
	 		StringTokenizer st2 = new StringTokenizer(bf.readLine());
	 		long sum = 0;
	 		for(int j=0;j<m;j++){
	 			array.add(Integer.parseInt(st2.nextToken()));
	 			sum+=(long)(array.get(j));
	 		}
	 		if (sum > n)
	 			out.println(-1);
	 		else
	 			out.println(n-sum);
 		
 		
 		out.println();
	 		
 		out.close();
 		
 		
 		
 	} main {
		int num = 998244353;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
//	 		String input1 = bf.readLine().trim();
//	 		String input2 = bf.readLine().trim();
	 		StringTokenizer st = new StringTokenizer(bf.readLine());
	 		long n = Long.parseLong(st.nextToken());
	 		long m = Long.parseLong(st.nextToken());
	 		ArrayList<Integer> array = new ArrayList<Integer>();
	 		StringTokenizer st2 = new StringTokenizer(bf.readLine());
	 		long sum = 0;
	 		for(int j=0;j<m;j++){
	 			array.add(Integer.parseInt(st2.nextToken()));
	 			sum+=(long)(array.get(j));
	 		}
	 		if (sum > n)
	 			out.println(-1);
	 		else
	 			out.println(n-sum);
 		
 		
 		out.println();
	 		
 		out.close();
 		
 		
 		
 	} int num = 998244353; num 998244353 BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); bf new BufferedReader(new InputStreamReader(System.in)) PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) StringTokenizer st = new StringTokenizer(bf.readLine()); st new StringTokenizer(bf.readLine()) long n = Long.parseLong(st.nextToken()); n Long.parseLong(st.nextToken()) Long.parseLong Long st.nextToken() st.nextToken st long m = Long.parseLong(st.nextToken()); m Long.parseLong(st.nextToken()) Long.parseLong Long st.nextToken() st.nextToken st ArrayList<Integer> array = new ArrayList<Integer>(); array new ArrayList<Integer>() StringTokenizer st2 = new StringTokenizer(bf.readLine()); st2 new StringTokenizer(bf.readLine()) long sum = 0; sum 0 for(int j=0;j<m;j++){
	 			array.add(Integer.parseInt(st2.nextToken()));
	 			sum+=(long)(array.get(j));
	 		} int j=0; int j=0; j 0 j<m j m j++ j++ j {
	 			array.add(Integer.parseInt(st2.nextToken()));
	 			sum+=(long)(array.get(j));
	 		} {
	 			array.add(Integer.parseInt(st2.nextToken()));
	 			sum+=(long)(array.get(j));
	 		} array.add(Integer.parseInt(st2.nextToken())) array.add array Integer.parseInt(st2.nextToken()) Integer.parseInt Integer st2.nextToken() st2.nextToken st2 sum+=(long)(array.get(j)) sum (long)(array.get(j)) array.get array j if (sum > n)
	 			out.println(-1);
	 		else
	 			out.println(n-sum); sum > n sum n out.println(-1) out.println out -1 1 out.println(n-sum) out.println out n-sum n sum out.println() out.println out out.close() out.close out String[] args args public class Main {

	public static void main(String[] args) throws Exception{
		int num = 998244353;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
//	 		String input1 = bf.readLine().trim();
//	 		String input2 = bf.readLine().trim();
	 		StringTokenizer st = new StringTokenizer(bf.readLine());
	 		long n = Long.parseLong(st.nextToken());
	 		long m = Long.parseLong(st.nextToken());
	 		ArrayList<Integer> array = new ArrayList<Integer>();
	 		StringTokenizer st2 = new StringTokenizer(bf.readLine());
	 		long sum = 0;
	 		for(int j=0;j<m;j++){
	 			array.add(Integer.parseInt(st2.nextToken()));
	 			sum+=(long)(array.get(j));
	 		}
	 		if (sum > n)
	 			out.println(-1);
	 		else
	 			out.println(n-sum);
 		
 		
 		out.println();
	 		
 		out.close();
 		
 		
 		
 	}
} public class Main {

	public static void main(String[] args) throws Exception{
		int num = 998244353;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
//	 		String input1 = bf.readLine().trim();
//	 		String input2 = bf.readLine().trim();
	 		StringTokenizer st = new StringTokenizer(bf.readLine());
	 		long n = Long.parseLong(st.nextToken());
	 		long m = Long.parseLong(st.nextToken());
	 		ArrayList<Integer> array = new ArrayList<Integer>();
	 		StringTokenizer st2 = new StringTokenizer(bf.readLine());
	 		long sum = 0;
	 		for(int j=0;j<m;j++){
	 			array.add(Integer.parseInt(st2.nextToken()));
	 			sum+=(long)(array.get(j));
	 		}
	 		if (sum > n)
	 			out.println(-1);
	 		else
	 			out.println(n-sum);
 		
 		
 		out.println();
	 		
 		out.close();
 		
 		
 		
 	}
} Main
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) throws Exception{
		int num = 998244353;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
//	 		String input1 = bf.readLine().trim();
//	 		String input2 = bf.readLine().trim();
	 		StringTokenizer st = new StringTokenizer(bf.readLine());
	 		long n = Long.parseLong(st.nextToken());
	 		long m = Long.parseLong(st.nextToken());
	 		ArrayList<Integer> array = new ArrayList<Integer>();
	 		StringTokenizer st2 = new StringTokenizer(bf.readLine());
	 		long sum = 0;
	 		for(int j=0;j<m;j++){
	 			array.add(Integer.parseInt(st2.nextToken()));
	 			sum+=(long)(array.get(j));
	 		}
	 		if (sum > n)
	 			out.println(-1);
	 		else
	 			out.println(n-sum);
 		
 		
 		out.println();
	 		
 		out.close();
 		
 		
 		
 	}
}
 	
 
//StringJoiner sj = new StringJoiner(" "); 
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is

 		
 		
 		
 		
	


