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):
n, m = map(int, input().split())

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

result = n - sum(a_list)
if result < 0:
    print(-1)
else:
    print(result)

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

a_list = [int(i) for i in input().split(' ')]

result = n - sum(a_list)
if result < 0:
    print(-1)
else:
    print(result)

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, _ = map(int, input().split())
s = sum(map(int, input().split()))

print(N - s if N >= s else -1)

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

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

(print(N - day) if (N - day) >= 0 else print(-1))

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

Su = sum(A)

if Su > T[0]:
    print(-1)
else:
    print(T[0]-Su)

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

Solution (Python):
n, m = [int(w) for w in input().split()]
a = [int(w) for w in input().split()]
a_sum = sum(a)

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

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

print(max(n-sum(data), -1))

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

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

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

free = n - sum(a_list)
if free<-1:
    free = -1

print(free)

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

free = n - sum(a_list)
if free<-1:
    free = -1

print(free)

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

Solution (Python):
tmp = input().split()
N = int(tmp[0])
M = int(tmp[1])

tmp2 = input().split()
TotalDays = 0

for i in tmp2:
    TotalDays = TotalDays + int(i)

if TotalDays <= N:
    print(N-TotalDays)
else:
    print(-1)

Solution (Python):
S = [input() for i in range(2)]
I = S[0].split()
N = int(I[0])
M = int(I[1])
A = list(map(int,S[1].split()))



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

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())

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

holiday = n - sum(workday_list)

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

Solution (Python):
n,m = input().split()
ai = [int(s) for s in input().split()]
count = 0
for i in ai:
    count += i
result = int(n) - count
if result < 0:
    print('-1')
else:
    print(result)

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

    homework_days = sum(A)

    if N - homework_days < 0:
        return -1
    else:
        return N -homework_days

print(main())

Solution (Python):
def to_do():
    N,M=map(int,input().split())
    day_list=list(map(int,input().split()))
    sum=0
    for i in range(0,M):
        sum=sum+day_list[i]
    if sum>N:
        print(-1)
    if sum<=N:
        print(N-sum)
if  __name__=="__main__":
    to_do()

Solution (Python):
a,b = (map(int,input().split()))
c = list(map(int,input().split()))
d = sum(c)

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

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

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

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

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

Solution (Python):
import math 
a = input().split()
days = int(a[0])
num = int(a[1])

b = input().split()
sum = 0
for i in range(num):
    sum += int(b[i])

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

Solution (Python):



import numpy
import math

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

sum = sum(a)

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

Solution (Python):


def main():
    N, M = map(int, input().split(' '))
    A = tuple(map(int, input().split(' ')))

    for i in range(M):
        N -= A[i]
    if N < 0:
        N = -1
    print(N)

if __name__ == '__main__':
    main()

Solution (Python):
N,M=map(int,input().split())
a=[ int(i) for i in input().split()]
if(N-sum(a)<0):
    print('-1')
    exit(0)
print(N-sum(a))

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

Solution (Python):
line_1 = input().split()
line_2 = input().split()
line_1 = list(map(lambda x: int(x), line_1))
line_2 = list(map(lambda x: int(x), line_2))

n = line_1[0]
m = line_1[1]

if (n < m):
  print(-1)
else:
  a = sum(line_2)
  r = n - a
  
  if (r < 0):
    print(-1)
  else:
    print(r)

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

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

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



b = sum(a)

if b <= n:
    print(n - b)
else:
    print("-1")

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

x = n-sum(alist)

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

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

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

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()))

if sum(A) > N:
    print("-1")
else : print(N-sum(A))

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

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

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

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

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

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



goukei = sum(A)

Ans = N - goukei

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

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

print(max(-1, N - sum(A)))

Solution (Python):
aa = input().split(' ')
dayOf = input().split(' ')
sum = 0
for needs in dayOf:
  sum = int(sum) + int(needs)
print(int(aa[0]) - sum if sum <= int(aa[0]) else '-1')

Solution (Python):
n,m = map(int,raw_input().split(' '))
a = n - sum(map(int,raw_input().split(' ')) or [0])
print a if a >= 0 else -1

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

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

a=0
for i in range(l[1]):
  a+=s[i]


if l[0]-a>=0:
  print(l[0]-a)
else:
  print(-1)

Solution (Python):



import numpy
import math

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

sum = sum(a)

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

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

Solution (Python):
n,m=[int(i)for i in input().split()]
list=[int(i) for i in input().split()]
a=n-sum(list)
if a>=0:
  print(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):
N,M = map(int, input().split())
ALL = sum(list(map(int, input().split())))
print(-1 if N-ALL<0 else N-ALL)

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

Solution (Python):
N, M = list(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 = map(int,input().split())

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

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

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

if a[0] >= b:
  print(a[0] - b)
else:
  print("-1")

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):
a,b = map(int, input().split())

days = input().split()

sum = 0
for i in days:
	sum = sum + int(i)

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

Solution (Python):
import sys

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

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

if sum(l) > n:
  print(-1)
  sys.exit()

print(n - sum(l))

Solution (Python):







inputs: list = []
while True:
    try:
        inputs.append(input().strip('\n'))
    except EOFError:
        break



days = int(inputs[0].split(' ')[0])
task_costs = inputs[1].split(' ')
task_costs = [int(t) for t in task_costs]
result = days - sum(task_costs)

print(f'{result if result >= 0 else -1}')

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

Solution (Python):
a = list(map(int, input().split()))
b = list(map(int, input().split()))
sum = 0
for i in b:
  sum += i
if a[0] < sum:
  print("-1")
else:
  print(a[0] - 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 = map(int, input().split())
a = list(map(int, input().split()))

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

Solution (Python):
a=input().split(' ')

b=int(a[0])
d=int(a[1])
c=input().split(' ')
count=0
for i in c:
    count+=int(i)
    

if b-count>=0:
    print(b-count)
else:
    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 = [int(x) for x in input().split()]
s = sum(a)
if(s > n):
  print(-1)
else:
  print(n - s)

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):
day_num, homework_num = map(int, input().split(" "))

requ_day = list(map(int, input().split()))
sum_day = 0

for day in requ_day:
  sum_day += day
  
activ_day = day_num - sum_day

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

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

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

work_days = sum(An)

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

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

print(n-a if n-a>=0 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 = list(map(int,input().split()))
A = list(map(int,input().split()))
L = 0
for i in range(N[1]):
  L = L + A[i]
if L > N[0]:
  x = -1
else:
  x = N[0] - L
print(x)

Solution (Python):
import sys
def inpl(): return list(map(int, sys.stdin.readline().split()))


x = inpl()
y = inpl()
for i in range(0, x[1]):
    x[0] -= y[i]

if x[0] < 0:
    print(-1)
else:
    print(x[0])

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

print(max(-1,N-sum(a)))

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):
import sys
import math
from collections import deque
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def S(): return sys.stdin.readline()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h,w): return [[i for j in range(w)] for k in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)

MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**6+10)
input = sys.stdin.readline

N,M = MI()
l = LI()
n = N
for i in l:
    n = n-i
    if n<0:
        print(-1)
        break
else:
    print(n)

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):
m, n = map(int, input().split())
a = list(map(int, input().split()))

sum_a = 0

for i in range(n):
    sum_a += a[i]

if m < sum_a:
    print(-1)
else:
    print(m-sum_a)

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

if int(n)-sum(a) < 0:
    print("-1")
else:
    print(int(n)-sum(a))

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

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

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

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

Solution (Python):
holidays, homeworks = input().split(' ')
holidays = int(holidays)
homeworks = int(homeworks)

days_per_homework = input().split(' ')
days_to_finish = 0
for _days in days_per_homework:
    days_to_finish = days_to_finish + int(_days)

if days_to_finish <= holidays:
    print(holidays - days_to_finish)
else:
    print(-1)

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

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

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

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

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

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

Solution (Python):
from functools import reduce

n, m = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
sum = reduce(lambda x, y: x + y, a)

print(max(n - sum, -1))

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

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

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 = input().split()
a = [int(i) for i in input().split()]
if int(n) >= sum(a):
  print(int(n)-sum(a))
else:
  print(-1)

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

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

Solution (Python):
N , M = input().split(" ")
Ai = input()
A = Ai.split(" ")
tm = 0
for i in A:
    tm = tm + int(i)
max = int(N)-tm
if max >= 0:
    print(int(N)-tm)
else :
    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 = (int(x) for x in input().split())
take = list(map(int, input().split()))
for per in take:
    n -= per

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

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

sum = 0

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

for i in list(a):
    sum += i

print(max(-1, n-sum))

Solution (Python):
N, M = (int(x) for x in input().split())

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

total_time = 0

for i in A:
    total_time += i

if total_time <= N:
    print(N-total_time)
elif total_time > N:
    print(-1)

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

result = n - total
print(result if result >= 0 else -1)

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

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

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

s = sum(l)

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

Solution (Python):
from sys import stdin, stdout
from collections import defaultdict
import math

N, M = map(int, stdin.readline().strip().split())
arr = list(map(int, stdin.readline().strip().split()))

ans = N - sum(arr)
stdout.writelines(str(-1 if ans < 0 else ans) + '\n')

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(i) for i in input().split())
a=[int(i) for i in input().split()]
s=sum(a)
if n-s>=0:
  print(n-s)
else:
  print(-1)

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

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

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

Solution (Python):
N,M = map(int,input().split())
plan = list(map(int,input().split()))
sum = N
for i in range(M):
  sum = sum - plan[i]

if 0 <= sum <= N:
  print(sum)

else:
  print('-1')

Solution (Python):

NM = input().split(' ')
N = int(NM[0]) ; M = int(NM[1])
Ai = input().split(' ')
sum_Ai = 0
for k in Ai:
    k = int(k)
    sum_Ai += k
if sum_Ai > N:
    print(-1)
else:
    print(N - sum_Ai)

Solution (Python):
num = input().split(" ")
num2 = input().split(" ")

a = int(num[1])

sum = 0
for i in num2:
  sum = sum + int(i)

b = int(num[0])-sum

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

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

Solution (Python):
n, m = map(int, input().split())
A = sum(list(map(int, input().split())))
if A <= n:
    print(n-A)
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(-1)
else:
    print(ans)

Solution (Python):
total, n = (map(int, input().split()))
ar = list((map(int, input().split())))
sum =0
for i in ar:
    sum += i
if sum > total:
    print(-1)
else :
    print(total - sum)

Solution (Python):
import numpy as np

N,M = [int(i) for i in input().split()]
A=np.array([int(i) for i in input().split()])

S = np.sum(A)

p = N-S

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

Solution (Python):



def main():
	n,m = map(int,input().split())
	m_list = list(map(int,input().split()))
	sum = 0
	for i in m_list:
		sum += i
	
	if n < sum:
		print ("-1")
	else:
		print (n-sum)

if __name__ == '__main__':
	main()

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

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

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

x = 0
for i in range(0, len(a)):
  x = x + a[i]
  
x = int(x)
play_day = n - x

if x > n:
  print("-1")
else:
  print(play_day)

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):
def resolve():
    day, w = map(int, input().split())
    work_list = list(map(int, input().split()))
    can_game = day - sum(work_list)
    if 0 > can_game:
        print(-1)
    else:
        print(can_game)

resolve()

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

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

Solution (Python):
N, M = map(int, input().split())
homework_days = [int(num) for num in input().split()]

diff = N - sum(homework_days)
print(diff) if diff >= 0 else print(-1)

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

sum_day = sum(day_list)
remain_day = n - sum_day
if remain_day >= 0:
    print(remain_day)
else:
    print(-1)

Solution (Python):
import numpy as np
days, count = map(int, input().split())
sum = np.sum(list(map(int, input().split())))
if sum <= days:
    print(days-sum)
else:
    print(-1)

Solution (Python):
import math

days, count = map(int, input().split())
sum = sum(list(map(int, input().split())))
if sum <= days:
    print(days - sum)
else:
    print("-1")

Solution (Python):
N,M=map(int,input().split())
As=[int(i) for i in input().split()]

ans=N-sum(As)

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

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

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]=[int(i) for i in input().split()]
A=[int(i) for i in input().split()]
print([N-sum(A),-1][int(0>N-sum(A))])

Solution (Python):
line = input()
niti = line.split()
linit_time = int(niti[0])


line2 = input()
time =line2.split()
total_time =0

for i in range(int(niti[1])):
  total_time +=int(time[i])

if linit_time - total_time < 0:
  print(-1)
else:
  print(linit_time - total_time)

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

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

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

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

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

Solution (Python):
a = input().split(" ")
b = input().split(" ")
c = 0
for i in b:
    c += int(i)
if int(a[0]) >= c:
    print(int(a[0]) - c)
else:
    print(-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())
x = [int(i) for i in input().split()]
sum=sum(x)
print(n-sum)if n>=sum else print("-1")

Solution (Python):
x=input()
z=input()
y=[]
a=[]
y = x.split()
a = z.split()
a = list(map(int,a))
y = list(map(int,y))
if (sum(a)>y[0]):
    print(-1)
else:
    print(y[0]-sum(a))

Solution (Python):
vacation_day,homework_num=map(int,input().split())
homework_spent_list=list(map(int,input().split()))
ans=vacation_day-sum(homework_spent_list)
if ans < 0:
	print(-1)
else:
	print(ans)

Solution (Python):
n, m = 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 = map(int , input().split())
a = list(map(int , input().split()))
ans = n - sum(a)
if ans < 0:
    ans = -1
print(ans)

Solution (Python):
if __name__ == "__main__":
    
    N, M = map(int, input().split(" "))
    
    Asum = sum(map(int, input().split(" ")))

    print(max(N - Asum, -1))

Solution (Python):
m, n = map(int, input().split())
A = list(map(int, input().split()))
for i in range(n):
    m -= A[i]
if m < 0:
    print("-1")
else:
    print(m)

Solution (Python):
D,N = input().split()
D = int(D)
N = int(N)
A = input().split()
for i in range(N):
    D -= int(A[i])
if D < 0 :
    print('-1')
else:
    print(str(D))

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):
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
a=list(map(int,input().split()))
s=sum(a)
if s>n:
    print(-1)
else:
    print(n-s)

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

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

suma = sum(a)

tmp = n - suma

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

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

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()))

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())
total_days = sum([int(e) for e in input().split()])
if total_days > N:
  print(-1)
else:
  print(N - total_days)

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

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

if n - sum(wd) < 0:
    print('-1')
else:
    print(n - sum(wd))

Solution (Python):
i = list(map(int,input().split()))
j = list(map(int,input().split()))
S=sum(j)

  
if i[0]>=S:
	print(i[0]-S)
else:
	print("-1")

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

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

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

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

Solution (Python):

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

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

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

Solution (Python):
yasumi = 0
syukudai = 1
nissu = list(map(int,input().split()))
syukudaiNissu = list(map(int,input().split()))
if sum(syukudaiNissu) > nissu[yasumi]:
  print(-1)
  exit()
print(nissu[yasumi] - sum(syukudaiNissu))

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

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

s = sum(a)

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

Solution (Python):
n,m = map(int , input().split())
a = list(map(int , input().split()))
s = sum(a)
if n>=s:
    print(n-s)
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 = [int(i) for i in input().split()]

A = [int(i) for i in input().split()]
rest = N - sum(A)
if rest >= 0 :
	print(rest)
else :
	print('-1')