Problem:
 Score : 200 points    Problem Statement Takahashi has N days of summer vacation.  His teacher gave him M summer assignments. It will take A_i days for him to do the i -th assignment.  He cannot do multiple assignments on the same day, or hang out on a day he does an assignment.  What is the maximum number of days Takahashi can hang out during the vacation if he finishes all the assignments during this vacation?  If Takahashi cannot finish all the assignments during the vacation, print -1 instead.      Constraints  1 \leq N \leq 10^6  1 \leq M \leq 10^4  1 \leq A_i \leq 10^4         Input Input is given from Standard Input in the following format:  N  M  A_1  ...  A_M       Output Print the maximum number of days Takahashi can hang out during the vacation, or -1 .        Sample Input 1 41 2
5 6      Sample Output 1 30  For example, he can do the first assignment on the first 5 days, hang out on the next 30 days, and do the second assignment on the last 6 days of the vacation. In this way, he can safely spend 30 days hanging out.       Sample Input 2 10 2
5 6      Sample Output 2 -1  He cannot finish his assignments.       Sample Input 3 11 2
5 6      Sample Output 3 0  He can finish his assignments, but he will have no time to hang out.       Sample Input 4 314 15
9 26 5 35 8 9 79 3 23 8 46 2 6 43 3      Sample Output 4 9

Solution (Python):
from sys import stdin,stdout

for _ in range(1):
	
	days,ass=map(int,stdin.readline().split())
	s=sum(map(int,stdin.readline().split()))
	ans=-1 if days-s<0 else days-s
	stdout.write(str(ans)+'\n')

Solution (Python):
N, M = map(int, input().split())
A = list(map(int, input().split()))

count = sum(A)

if count > N:
    print(-1)
else:
    print(N - count)

Solution (Python):
n, m = map(int, input().split())
a = input().split() 

a = sum(int(i) for i in a)

asobi = n -a
if asobi >= 0:
  print(asobi)
else:
  print(-1)

Solution (Python):
n,m=[int(_) for _ in input().split()]
a=[int(_) for _ in input().split()]
print(n-sum(a) if n-sum(a)>=0 else -1)

Solution (Python):
def main():
    n,m = map(int,input().split())
    arr = list(map(int,input().split()))
    total = sum(arr)
    if total > n:
        print(-1)
    else:
        print(n-total)
        

main()

Solution (Python):
a = input()
b = input()

days,home = [int(i) for i in a.split(" ")]
cost = [int(n) for n in b.split(" ")]



validdate = int(days) - sum(cost)
if validdate >= 0:
    print(validdate)
else:
    print(-1)

Solution (Python):






"""Module docstring
"""

import functools
import heapq
import itertools
import logging
import math
import random
import string
import sys
from argparse import ArgumentParser
from collections import defaultdict, deque
from copy import deepcopy
from typing import Dict, List, Optional, Set, Tuple


def solve(values: List[str], nb: int) -> int:
    sum_v = sum(values)
    if sum_v <= nb:
        return nb - sum_v
    return -1


def do_job():
    "Do the work"
    LOG.debug("Start working")
    
    N, _M = map(int, input().split())
    values = list(map(int, input().split()))
    result = solve(values, N)
    print(result)


def print_output(testcase: int, result) -> None:
    "Formats and print result"
    if result is None:
        result = -1
    print("Case 
    
    


def configure_log(log_file: Optional[str] = None) -> None:
    "Configure the log output"
    log_formatter = logging.Formatter(
        "%(asctime)s - %(filename)s:%(lineno)d - " "%(levelname)s - %(message)s"
    )
    if log_file:
        handler = logging.FileHandler(filename=log_file)
    else:
        handler = logging.StreamHandler(sys.stdout)
    handler.setFormatter(log_formatter)
    LOG.addHandler(handler)


LOG = None

if not LOG:
    LOG = logging.getLogger("template")
    configure_log()


def main(argv=None):
    "Program wrapper."
    if argv is None:
        argv = sys.argv[1:]
    parser = ArgumentParser()
    parser.add_argument(
        "-v",
        "--verbose",
        dest="verbose",
        action="store_true",
        default=False,
        help="run as verbose mode",
    )
    args = parser.parse_args(argv)
    if args.verbose:
        LOG.setLevel(logging.DEBUG)
    do_job()
    return 0


if __name__ == "__main__":
    import doctest

    doctest.testmod()
    sys.exit(main())


class memoized:
    """Decorator that caches a function's return value each time it is called.
    If called later with the same arguments, the cached value is returned, and
    not re-evaluated.
    """

    def __init__(self, func):
        self.func = func
        self.cache = {}

    def __call__(self, *args):
        try:
            return self.cache[args]
        except KeyError:
            value = self.func(*args)
            self.cache[args] = value
            return value
        except TypeError:
            
            
            return self.func(*args)

    def __repr__(self):
        """Return the function's docstring."""
        return self.func.__doc__

    def __get__(self, obj, objtype):
        """Support instance methods."""
        return functools.partial(self.__call__, obj)

Solution (Python):
N,M = map(int, input().split())
A = list(map(int, input().split()))

sumDays = sum(A)

if sumDays <= N:
  print(N-sumDays)
else:
  print('-1')

Solution (Python):
import math

N, M = map(int, input().split())
List = [int(i) for i in input().split()]
sum = sum(List)
answer = N-sum
if answer<-1:
  answer = -1
  
  
print(answer)

Solution (Python):
nums = input()
alldays = int(nums.split(' ')[0])
hwday = input().split(' ')
hwday = list(map(int,hwday))
for i in range(len(hwday)):
	alldays -= hwday[i]
if alldays >= 0:
	print(alldays)
else:
	print('-1')

Solution (Python):
n, m = map(int, input().split(' '))
a = list(map(int, input().split(' ')))

work_time = sum(a)
play_time = n - work_time 

if play_time  < 0:
    play_time = -1

print(play_time)

Solution (Python):

arg1 = list(map(int, input().split()))
arg2 = list(map(int, input().split()))

N = arg1[0]

A = sum(arg2)

if N-A>=0:
    print(N-A)
else:
    print('-1')

Solution (Python):
N,M = map(int,input().split())
A = list(map(int,input().split()))
S = 0
for i in range(M):
  S += A[i]
if N<S:
  print(-1)
else:
  print(N-S)

Solution (Python):
N, M = [int(a) for a in input().split()]
A =[int(a) for a in input().split()]
def f():
    if sum(A)>N:return -1
    return -sum(A)+N
print(f())

Solution (Python):

def main():
    for _ in inputt(1):
        n, m = inputi()
        A = inputl()
        n -= sum(A)
        print(-1 if n < 0 else n)








from math import *
from heapq import *
from itertools import *
from functools import reduce, lru_cache, partial
from collections import Counter, defaultdict
import re, copy, operator, cmath
import sys, io, os, builtins
sys.setrecursionlimit(1000)






BUFSIZE = 8192
class FastIO(io.IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = io.BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(io.IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
def print(*args, **kwargs):
    sys.stdout.write(kwargs.pop("split", " ").join(map(str, args)))
    sys.stdout.write(kwargs.pop("end", "\n"))
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip()
inputt = lambda t = 0: range(t) if t else range(int(input()))
inputs = lambda: input().split()
inputi = lambda: map(int, inputs())
inputl = lambda t = 0, k = inputi: map(list, (k() for _ in range(t))) if t else list(k())






def len(a):
    if isinstance(a, range):
        return -((a.start - a.stop) // a.step)
    return builtins.len(a)
def bisect_left(a, x, key = None, lo = 0, hi = None):
    if lo < 0: lo = 0
    if hi == None: hi = len(a)
    if key == None: key = do_nothing
    while lo < hi:
        mid = (lo + hi) // 2
        if key(a[mid]) < x: lo = mid + 1
        else: hi = mid
    return lo
def bisect_right(a, x, key = None, lo = 0, hi = None):
    if lo < 0: lo = 0
    if hi == None: hi = len(a)
    if key == None: key = do_nothing
    while lo < hi:
        mid = (lo + hi) // 2
        if x < key(a[mid]): hi = mid
        else: lo = mid + 1
    return lo
def insort_left(a, x, key = None, lo = 0, hi = None):
    lo = bisect_left(a, x, key, lo, hi)
    a.insert(lo, x)
def insort_right(a, x, key = None, lo = 0, hi = None):
    lo = bisect_right(a, x, key, lo, hi)
    a.insert(lo, x)
do_nothing = lambda x: x
bisect = bisect_right
insort = insort_right
def index(a, x, default = None, key = None, lo = 0, hi = None):
    if lo < 0: lo = 0
    if hi == None: hi = len(a)
    if key == None: key = do_nothing
    i = bisect_left(a, x, key, lo, hi)
    if lo <= i < hi and key(a[i]) == x: return a[i]
    if default != None: return default
    raise ValueError
def find_lt(a, x, default = None, key = None, lo = 0, hi = None):
    if lo < 0: lo = 0
    if hi == None: hi = len(a)
    i = bisect_left(a, x, key, lo, hi)
    if lo < i <= hi: return a[i - 1]
    if default != None: return default
    raise ValueError
def find_le(a, x, default = None, key = None, lo = 0, hi = None):
    if lo < 0: lo = 0
    if hi == None: hi = len(a)
    i = bisect_right(a, x, key, lo, hi)
    if lo < i <= hi: return a[i - 1]
    if default != None: return default
    raise ValueError
def find_gt(a, x, default = None, key = None, lo = 0, hi = None):
    if lo < 0: lo = 0
    if hi == None: hi = len(a)
    i = bisect_right(a, x, key, lo, hi)
    if lo <= i < hi: return a[i]
    if default != None: return default
    raise ValueError
def find_ge(a, x, default = None, key = None, lo = 0, hi = None):
    if lo < 0: lo = 0
    if hi == None: hi = len(a)
    i = bisect_left(a, x, key, lo, hi)
    if lo <= i < hi: return a[i]
    if default != None: return default
    raise ValueError





class Tree:
    def __init__(n):
        self._n = n
        self._conn = [[] for _ in range(n)]
        self._list = [0] * n
    def connect(a, b):
        pass





class Sieve:
    def __init__(self):
        self._n = 6
        self._list = [2, 3, 5, 7, 11, 13]
    def extend(self, n):
        pass


sieve = Sieve()
def isprime(n):
    pass
def prime(n):
    pass
def factorint(n):
    factordict = defaultdict(int)
    for i in sieve:
        if n <= i * i:
            break
        while not n % i:
            factordict[i] += 1
            n //= i
    if n != 1:
        factordict[n] += 1
    return factordict





if __name__ == "__main__":
    main()

Solution (Python):
import sys


n, m = map(int, input().split())
a = list(map(int, input().split()))

ans = n - sum(a)
if ans >= 0:
    print(ans)
else:
    print(-1)

Solution (Python):
n,m=map(int,input().split())
A=list(map(int,input().split()))
if n>=sum(A):
    
    print(n-sum(A))
else:
    print(-1)

Solution (Python):
N, M = map(int, input().split())
A = list(map(int, input().split()))
if N-sum(A) >= 0:
    print(N-sum(A))
else:
    print(-1)

Solution (Python):
N, M = [int(el) for el in input().split()]
sm = sum([int(el) for el in input().split()])
print(-1 if N < sm else N - sm)

Solution (Python):
n,m=map(int,input().split())
a=list(map(int,input().split()))

day=n-sum(a)
if day<0:
    print(-1)
else:
    print(day)

Solution (Python):
N,M=map(int,input().split())
A=list(map(int,input().split()))
left=N-sum(A)
if(left<0):
	print(-1)
else:
	print(left)

Solution (Python):
N,M = map(int , input().split())
listA = list(map(int, input().split()))

sum = 0
for a in listA :
    sum = sum + a

if N - sum < 0 :
    print(-1)
else :
    print(N - sum)

Solution (Python):
def resolve():
    N, M = map(int, input().split())
    a_list = list(map(int, input().split()))
    rel = sum(a_list)
    if(rel > N):
        print("-1")
    else:
        print(N - rel)

resolve()

Solution (Python):
n,m=map(int,input().split())
A=list(map(int, input().split()))
s=sum(A)
if n-s<0:
	print('-1')
else:
	print(n-s)

Solution (Python):
N, M= map(int,input().split())
numbers = list(map(int, input().split()))

amount = 0
for i in range(M):
    amount = amount + numbers[i]

if N - amount >=  0:
    print(N - amount)
else:
    print(-1)

Solution (Python):
n,m=map(int,input().split())
a=list(map(int,input().split()))
if n-sum(a) >= 0:
    print(n-sum(a))
else:
    print(-1)

Solution (Python):
N, M = map(int, input().split())
A = list(map(int, input().split()))
if N - sum(A) < 0:
    print(-1)
else:
    print(N - sum(A))

Solution (Python):
a=input().split()
N=int(a[0])
M=int(a[1])
M_list=input().split()
Flag=True
item_list=[]
for item in M_list :
	item_list.append(int(item))
    
if N<sum(item_list):
	print('-1')
else :
	for item in item_list :
		N-=item
	print(N)

Solution (Python):
n,m=map(int,input().split())
a=list(map(int,input().split()))
if(sum(a)>n):
    print(-1)
else:
    print(abs(sum(a)-n))

Solution (Python):
n, m = map(int, input().split())
a = list(map(int, input().split()))

homework = sum(a)
res = n - homework
if res >= 0:
    print(res)
else:
    print(-1)

Solution (Python):


A,B=(int(x) for x in input().split())

days_l = [int(x) for x in input().split()]
hw = sum(days_l)

if A >= hw:
    print(A - hw)
else:
    print('-1')

Solution (Python):
N = list(map(int, input().split()))
A = list(map(int, input().split()))
 
if N[0]-sum(A)>-1:
  print(N[0]-sum(A))
else:
  print(-1)

Solution (Python):
N,M = map(int,input().split())
A = list(map(int,input().split()))
sum = sum(A)
day = N-sum
if day < 0:
    print("-1")
else:
    print(day)

Solution (Python):
N, M= map(int, input().split())
A = list(map(int, input().split()))    
if N-sum(A)>=0:
    print(N-sum(A))
else:
    print("-1")

Solution (Python):
n, m = (int(x) for x in input().split())
task = []
for x in input().split():
    task.append(int(x))

vacation = n - sum(task)
if vacation < 0:
    vacation = -1

print(vacation)

Solution (Python):
n, m = map(int, (input().split()))
a = list(map(int, input().split()))
an = n - sum(a)
if an < 0:
    print(-1)
else:
    print(an)

Solution (Python):
lists = list(map(int, input().split())) 
a = list(map(int, input().split())) 

ans = sum(a)
if ans <= lists[0]:
    print(lists[0]-ans)
else:
    print(-1)

Solution (Python):


n, m = map(int, input().split())
a = list(map(int, input().split()))

ans = n-sum(a)
if ans >= 0:
    print(ans)
else:
    print(-1)

Solution (Python):
N,M = map(int,input().split())
A = list(map(int,input().split()))
a = sum(A)
if N >= a:
    print(N-a)
else:
    print(-1)

Solution (Python):
n, m = input().split()
n = int(n)
m = int(m)
a = input().split()
for i in range(m):
    a[i] = int(a[i])

if n >= sum(a):
    print(n - sum(a))
else:
    print(-1)

Solution (Python):
import sys


def solve(N: int, M: int, A: "List[int]"):

    a = sum(A)

    if a > N:
        print(-1)
    else:
        print(N-a)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    M = int(next(tokens))  
    A = [int(next(tokens)) for _ in range(M)]  
    solve(N, M, A)

if __name__ == '__main__':
    main()

Solution (Python):
def days():
  n, m = map(int, input().split())
  days = list(map(int, input().split()))
  days = sum(days)
  if n - days >= 0:
    return n - days
  else:
    return -1
result = days()
print(result)

Solution (Python):
n,m = map(int,input().split())

a = list(map(int,input().split()))

ans = n - sum(a)
ans = ans if ans>=0 else -1

print(ans)

Solution (Python):
n,m=map(int,input().split())
a=list(map(int,input().split()))
if sum(a)>n:
    print(-1)
else:
    print(n-sum(a))

Solution (Python):
n, m = map(int, input().split())
A = input().split()
a = [int(i) for i in A]

ans = sum(a)

if ans > n:
    print(-1)
else:
    print(n-ans)

Solution (Python):
from sys import stdin
input = stdin.readline

N,M = map(int, input().split())

l = list(map(int, input().split()))

d = 0
d = N - sum(l)

if (d < 0 ):
    print("-1")
else:
    print(d)

Solution (Python):
N,M = map(int,input().split())

homework = [int(x) for x in input().split()]

homework_day = 0
for i in range(M):
    homework_day += homework[i]

if homework_day <= N :
    print(N - homework_day)
else:
    print("-1")

Solution (Python):
N, M = map(int, input().split())
A = list(map(int, input().split()))

a = sum(A)
output = max(N - a, -1)

print(output)

Solution (Python):
if __name__ == "__main__":
    n, m = map(int, input().split())
    a = [int(x) for x in input().split()]
    ans = n

    for ai in a:
        ans -= ai
        if ans < 0:
            ans = -1
            break
    
    print(ans)

Solution (Python):
n,m = list(map(int, input().split()))
lst = list(map(int, input().split()))

print(n-sum(lst) if n-sum(lst)>=0 else -1)

Solution (Python):
N, M = [int(n) for n in input().split()]
A = [int(n) for n in input().split()]

homework = sum(A)
ans = N - homework

if ans < 0:
	print(-1)
else:
	print(ans)

Solution (Python):
n,m = list(map(int,input().split()))
a = list(map(int,input().split()))
val = n-sum(a)
if val >= 0:
    print(val)

else:
    print(-1)

Solution (Python):
import sys
from typing import Callable, NoReturn, Tuple


def main() -> NoReturn:
    scan: Callable[[], str] = sys.stdin.readline

    n, m = map(int, scan().rstrip().split())
    a: Tuple[int] = tuple(int(a_i) for a_i in scan().rstrip().split())

    playtime: int = n - sum(a)
    if playtime < 0:
        playtime = -1

    print(playtime)


if __name__ == '__main__':
    main()

Solution (Python):
n,m = map(int,input().split())
a = list(map(int,input().split()))

if sum(a) > n:
    print(-1)
else:
    print(n-sum(a))

Solution (Python):

init = [int(s) for s in input().rstrip().split(' ')]
data = [int(s) for s in input().rstrip().split(' ')]

days_homework = sum(data)
left_time = init[0] - days_homework
if left_time < 0:
    print(-1)
else:
    print(left_time)

Solution (Python):
N,M = map(int, input().split())
A = list(map(int,input().split()))


need = 0
for i in range(M):
    need += A[i]

ans = N-need

if ans < 0:
    ans = -1

print(ans)

Solution (Python):
N, M = input().split(' ')
N = int(N)
M = int(M)

AmStr = input().split(' ')
Am = []
sumA = 0
for v in AmStr:
  sumA += int(v)
  Am.append(int(v))

if (N - sumA >= 0):
  print(N - sumA)
else:
  print(-1)

Solution (Python):
n, m = map(int, input().split())
a = list(map(int, input().split()))

x = n - sum(a)
print(x if x >= 0 else -1)

Solution (Python):
N, M = map(int, input().split())
A = list(map(int, input().split()))
flag = True
 
for i in  A:
  N = N - i
  if N < 0:
    flag = False
    break
 
if flag == True:
  print(N)
else:
  print(-1)

Solution (Python):
n, m = map(int, input().split())
ass = list(map(int, input().split()))
d = n - sum(ass)
if d < 0:
  print(-1)
else:
  print(int(d))

Solution (Python):
NM=input()
NM=NM.split()
A=input()
A=A.split()
sum=0
for i in A:
  sum=sum+int(i)
if(sum>int(NM[0])):
    print(-1)
else:
    print(int(NM[0])-sum)

Solution (Python):
N, M = map(int, input().split())
A = list(map(int, input().split()))
ans = N - sum(a for a in A)

if ans < 0:
    print(-1)
else:
    print(ans)

Solution (Python):
n, m = list(map(int, input().split()))

a = list(map(int, input().split()))
a_sum = sum(a)

if n - a_sum < 0:
	print(-1)
else:
	print(n - a_sum)

Solution (Python):
n, m = map(int, input().split())
a = list(map(int, input().split()))

if n >= sum(a):
    print(n-sum(a))
else:
    print(-1)

Solution (Python):
N,M = list(map(int,input().split()))
A = list(map(int,input().split()))
x = 0
for i in A:
    x += i
if N - x >= 0:
    print(N-x)
else:
    print(-1)

Solution (Python):
N,M = map(int,input().split())
A = map(int,input().split())

s = sum(A)
if N-s<0:
    print(-1)
else:
    print(N-s)

Solution (Python):
N, M = map(int, input().split())
A = list(map(int, input().split()))
daytofinish = sum(A)
if N-daytofinish < 0:
    print(-1)
else:
    print(N-daytofinish)

Solution (Python):
N,M = map(int,input().split())
A = list(map(int,input().split()))

G = 0

for T in A:
    G += T

if N - G < 0:
    print(-1)
else:
    print(N-G)

Solution (Python):
N,M = map(int, input().split())
A = list(map(int, input().split()))
if sum(A) > N:
    print(-1)
else:
    print(N - sum(A))

Solution (Python):
n, m = map(int, input().split())
A = list(map(int, input().split()))
ans = n-sum(A)
if ans < 0:
    print(-1)
else:
    print(ans)

Solution (Python):
n,m = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
r = n - sum(a)
if r < 0:
    print(-1)
else:
    print(r)

Solution (Python):
n, k = list(map(int, input().split()))

nums = list(map(int, input().split()))

res = n - sum(nums)

print(-1 if res < 0 else res)

Solution (Python):
N,M=map(int,input().split())
A=list(map(int,input().split()))

total=sum(A)
if total>N:
    print(-1)
elif total==N:
    print(0)
else:
    print(N-total)

Solution (Python):
data = input().split()
N = int(data[0])
M = int(data[1])
A = list(map(int,input().split()))

rest = N - sum(A)
if rest >= 0:
  print(rest)
else:
  print(-1)

Solution (Python):
n,m=[int(i) for i in input().split(" ")]

sum=sum([int(i) for i in input().split(" ")])
if n-sum<0:
    print(-1)
else:
    print(n-sum)

Solution (Python):
N,M=map(int,input().split())
A=list(map(int,input().split()))
S=0
for i in range(M):
	S=S+A[i]
if N>=S:
	print(N-S)
else:
	print(-1)

Solution (Python):
n,m = map(int,input().split())
arr = list(map(int,input().split()))

s = sum(arr)

if s > n:
    print(-1)
else:
    print(n-s)

Solution (Python):
N,M=map(int,input().split())
A=list(map(int,input().split()))
sum=0
for i in range(M):
  sum+=A[i]
if N-sum>=0:
  print(N-sum)
else:
  print(-1)

Solution (Python):
n, m = list(map(int, input().split()))
lis = list(map(int, input().split()))

if sum(lis) <= n:
  print(n - sum(lis))
else:
  print(-1)

Solution (Python):
N, M = [int(data) for data in input().split()]
A =  [int(data) for data in input().split()][0:M]

r = N - sum(A)


if r >= 0:
    print(r)
else:
    print(-1)

Solution (Python):
vacationDays, homeworkN  = map(int, input().split())
homeworkDays = sum(map(int, input().split()))

PlayDays = vacationDays - homeworkDays

print(PlayDays if PlayDays >= 0 else -1)

Solution (Python):
n,m = map(int, input().split())
a = [int(i) for i in input().split()]

if sum(a) <= n:
    print(n-sum(a))
elif sum(a) > n:
    print('-1')

Solution (Python):
n, m = map(int, input().split())
a = list(map(int, input().split()))
print(max(n-sum(a),-1))

Solution (Python):
N, M =  map(int, input().split())
A = list(map(int, input().split()))

answer  = N - sum(A)
if answer < 0:
    print("-1")
else:
    print(answer)

Solution (Python):
n,m = map(int,input().split())
a_list = list(map(int,input().split()))

if n >= sum(a_list):
    print(n-sum(a_list))
else:
    print(-1)

Solution (Python):


n, m = map(int, input().split())
A = list(map(int, input().split()))

req = 0
for i in range(m):
  req += A[i]

rem = n - req
if rem >= 0 :
  print(rem)
else:
  print(-1)

Solution (Python):
n,m = map(int,input().split())
a  = list(map(int,input().split()))
summer = sum(a)
if summer <= n :
    vacation = n - summer
    print(vacation)
else :
    print(-1)

Solution (Python):


n, m = map(int, input().split())
a_list = input().split()

a_total = 0
for a in a_list:
  a_total += int(a)

d = n - a_total
if d < 0:
  print(-1)
else:
  print(d)

Solution (Python):
import math

N, M = map(int, input().split(" "))
A = map(int, input().split(" "))

a = sum(A)
if a <= N:
  print(N - a)
else:
  print(-1)

Solution (Python):
N, M = map(int, input().split())
sum_A = sum(list(map(int, input().split())))
print(N - sum_A if N >= sum_A else -1)

Solution (Python):
n, m = map(int, input().split())
a = list(map(int, input().split()))


if n-sum(a) >= 0:
  print(n-sum(a))
else:
  print(-1)

Solution (Python):

N,M = (int(x) for x in input().split())
A = list(map(int, input().split()))


day_syukudai = sum(A)
day_asobu = N - day_syukudai
if day_asobu <0:
    print(-1)
else:
    print(day_asobu)

Solution (Python):
n, m = map(int, input().split())
a = list(map(int, input().split()))

a_sum = sum(a)

if a_sum <= n:
    print(n - a_sum)
else:
    print(-1)

Solution (Python):
N,M=map(int,input().split())

*A,=map(int,input().split())

H=N-sum([a for a in A])
print (H if H>=0 else -1)

Solution (Python):
N,M=map(int,input().split())
A=list(map(int,input().split()))
x=0
for i in A:
    x+= i
day=0
if x<=N:
    day=N-x
    print(day)
else:
    print('-1')

Solution (Python):
n,m=map(int,input().split())
lists=list(map(int,input().split()))
if n>=sum(lists):
    print(n-sum(lists))
else:
    print(-1)

Solution (Python):
n,m=map(int, input().split())
a=list(map(int, input().split()))

i = n - sum(a)
if i < 0:
    print(-1)
else:
    print(n - sum(a))

Solution (Python):
N, M = map(int,input().split())
A = list(map(int, input().split()))

result = N - sum(A)
if result>=0:
    print(result)
else:
    print(-1)

Solution (Python):
n, m = map(int, input().split())
a = sum(map(int, input().split()))
print(r if (r := n-a) >= 0 else -1)

Solution (Python):
n,m = map(int,input().split())
a = list(map(int,input().split()))

if sum(a) <= n:
    print(n - sum(a))
else:
    print(-1)

Solution (Python):
n,m = map(int,input().split())
L = list(map(int,input().split()))

if sum(L)>n:
    print("-1")
else:
    print(n-sum(L))

Solution (Python):
n, m = map(int, input().split())
A = list(map(int, input().split()))

total = sum(A)
if total > n:
    print(-1)
else:
    print(n-total)

Solution (Python):
N,M=map(int,input().split())
A=list(map(int,input().split()))
print(N-sum(A) if N>=sum(A) else -1)

Solution (Python):
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
tmp = 0
for i in range(M):
  tmp += A[i]
if N >= tmp:
  print(N - tmp)
else:
  print(-1)

Solution (Python):
N , M = map(int,input().split())
A = list(map(int,input().split()))
S = sum(A)
print(max(-1, N-S))

Solution (Python):

import math


def main():

    
    first_input = list(map(lambda x:int(x), input().split(" ")))
    second_input = list(map(lambda x:int(x), input().split(" ")))

    
    
    

    
    

    N = first_input[0]
    M = first_input[1]

    Nokori = N
    for a in second_input:
        Nokori = Nokori - a

    if Nokori>=0:
        print(Nokori)
    else:
        print("-1")

if __name__ == '__main__':
    main()

Solution (Python):
n, m = map(int, input().split())
daylist = list(map(int, input().split()))
if sum(daylist) <= n:
    print(n - sum(daylist))
else:
    print(-1)

Solution (Python):

"""
@author: H_Hoshigi
"""
def main():
    N, M = map(int, input().split())
    A_list = list(map(int, input().split()))
    diff = N - sum(A_list)
    if diff >= 0:
        print(diff)
    else:
        print(-1)

if __name__ == "__main__":
    main()

Solution (Python):
N,M=map(int,input().split())
A=[int(x) for x in input().split()]
Sum=0
for i in range(M):
    Sum+=A[i]
if Sum>N:
    print("-1")
else:
    print(N-Sum)

Solution (Python):
a,b=map(int,input().split())

c=list(map(int,input().split()))
d=0
for i in range (0,b):
    d=d+c[i]
if a-d>=0:
    print(a-d)
else:
    print(-1)

Solution (Python):
N = list(map(int, input().split()))
A=list(map(int, input().split()))
sum_A = 0

for i in range(N[1]):
    sum_A += A[i]
    
if N[0]-sum_A >= 0:
    print(N[0]-sum_A)
else:
    print(-1)

Solution (Python):
n,m = map(int,input().split())
a = list(map(int,input().split()))

if n < sum(a):
    print(-1)

else:
    print(n-sum(a))

Solution (Python):
n,m = map(int,input().split())
a = list(map(int,input().split()))

su = 0
for i in a:
  su += i

if su > n:
  print(-1)
else:
  print(n-su)

Solution (Python):
N, M = map(int, input().split())
A = list(map(int, input().split()))
for a in A:
    N -= a
print(N) if N >= 0 else print(-1)

Solution (Python):


n_and_m = input()

n, m = map(int, n_and_m.split())

homeworks = input()
homeworks = homeworks.split()

do_homework = 0
for num in homeworks:
    do_homework = do_homework + int(num)

if do_homework > n:
    print(-1)

else:
    print(n - do_homework)

Solution (Python):
N,M = map(int, input().split())
A = [int(x) for x in input().split()]
sum = 0
for i in range(M):
    sum = sum + A[i]
if sum > N:
    print("-1")
else:
    print(N-sum)

Solution (Python):
N,M=map(int, input().split())
A=list(map(int, input().split()))
sumA=sum(A)
if sumA>N:
    print('-1')
else:
    print(N-sumA)

Solution (Python):
N, M = map(int, input().split())
A = list(map(int, input().split()))


for i in A:
  N -= i

if N < 0:
  print(-1)
else:
  print(N)

Solution (Python):
n,m = map(int, input().split())
a = list(map(int, input().split()))

play = n - sum(a)
if play >= 0:
    print(play)
else:
    print('-1')

Solution (Python):
n, m = map(int, input().split())
a = list(map(int, input().split()))
sum = 0
for i in range(m):
    sum += a[i]
if sum > n:
    print(-1)
else:
    print(n-sum)

Solution (Python):
d,n = map(int,input().split())
a = list(map(int,input().split()))
print(max(-1,d-sum(a)))

Solution (Python):
N, M = list(map(int, input().split()))

A = list(map(int, input().split()))

sum = sum(A)

if N >= sum:
    print(N - sum)
else:
    print(-1)

Solution (Python):

N,M = list(map(int, input().split()))
A = list(map(int, input().split()))

day = sum(A)
play = N-day
if play < 0:
    play = -1

print(play)

Solution (Python):
temp = input().split()
n = int(temp[0])
m = int(temp[1])
a = list(map(int, input().split()))

for i in range(m):
	n -= a[i]

if n < 0:
	print("-1")
else:
	print("%d" % n)

Solution (Python):
n, m = map(int, input().split())
a = input().split()
for i in a:
    n -= int(i)
if n >= 0:
    print(n)
else:
    print(-1)

Solution (Python):
vacations, assignments = map(int, input().split())
days = sum(list(map(int,input().split())))

if days > vacations:
    print("-1")
else:
    print(vacations-days)

Solution (Python):
N,M=map(int,input().split())
A=list(map(int,input().split()))
a=sum(A)
ans=N-a
if ans<0:
  ans=-1
print(ans)

Solution (Python):




N, M = map(int, input().split())
A = list(map(int, input().split()))

S = 0

for i in range(M):
  S += A[i]
  
R = N - S

if R < 0:
  print(-1)
else:
  print(R)

Solution (Python):
n, m = map(int, input().split())
a = list(map(int, input().split()))

ans = 0
for i in range(m):
    ans += a[i]

if (n - ans >= 0):
    print(n-ans)
else:
    print(-1)

Solution (Python):
n,m = map(int, input().split())
 
a = [ int(x) for x in input().split()]
res=n-sum(a)
if(res>=0):
	print(res)
else: print(-1)

Solution (Python):
n,m = map(int,input().split())
lst = list(map(int,input().split()))

sum = sum(lst)
print(n-sum if sum<=n else '-1')