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()))
s=sum(A)

if s>N:
  print(-1)
  exit()
  
print(N-s)

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

if sum>N:
  print(-1)
  exit()
  
print(N-sum)

Solution (Python):
line=input()
n,k=map(int,line.split())
pine=input()
koko=pine.split()
koko=map(int,koko)
koko=list(koko)
s=sum(koko)
d=n-s
if d<0:
     print(-1)
else:
     print(d)

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

def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    ans = max(-1, N - sum(A))
    print(ans)


if __name__ == "__main__":
    main()

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

a = sum(al)

if n < a:
    print(-1)
else:
    print(n - 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):
def main():
        N, M = map(int, input().split())
        A = list(map(int, input().split()))

        total = sum(A)

        if total>N:
                ans = -1
        else:
                ans = N-total

        print("{}".format(ans))

if __name__=="__main__":
        main()

Solution (Python):
a,b=map(int,input().split())
 
c=[int(i) for i in input().split()]
d=sum(c)
print(a-sum(c) if a>=sum(c) else '-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):
N, M = [ int(i) for i in input().strip().split(' ')]
A = [ int(i) for i in input().strip().split(' ')]
asobi = N - sum(A)
if asobi < 0:
    print('-1')
else:
    print(asobi)

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

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

Solution (Python):
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n, m = map(int, input().split())
    sum_a = sum(list(map(int, input().split())))
    ans = n - sum_a
    if ans < 0:
        print(-1)
    else:
        print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

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

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

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

days = 0

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

remaining = n-days

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

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

count=0

for i in A :
    count += i
    if count > n :
        
        break
    else :
        pass

if n>= count:
    print(n-count)
else:
    print("-1")

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


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

cnt = 0
for i in A:
    cnt += i

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

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

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

assignments = [int(a) for a in input().split(' ')]
total_a = sum(assignments)
if total_a <= n:
    print(n-total_a)
else:
    print(-1)

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

print(max(M-sum(l), -1))

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

if M < sum(l):
  print(-1)
else:
  print(M - sum(l))

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

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

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

kakaru = 0

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

ans = n - kakaru

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

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):
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())
s = sum(map(int, input().split()))
print(n-s if n >= s else -1)

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


free = N - sum(l)
print(free if free>=0 else -1)

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

free = N - sum(l)
print(free if free>=0 else -1)

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

free = N - sum(l)
print( -1 if free<0 else free)

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

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

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

free = N
s = sum(l)

free -= s
if free<0:
    print(-1)
else:
    print(free)

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

free = N
s = 0
for i in l:
	s += i

free -= s
if free<0:
    print(-1)
else:
    print(free)

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

free = N
for i in l:
	free -= i
    
if free<0:
    print(-1)
else:
    print(free)

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

if sum(A) <= N:
    result = N - sum(A)

print(result)

Solution (Python):
N, M = map(int, input().split())
A = list(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()))
sum = 0
for i in range(M):
    sum = sum + A[i]
date = -1
if N-sum >= 0:
    date = N-sum
print(date)

Solution (Python):
def solve(string):
    n, m, *a = map(int, string.split())
    return str(b if (b := n-sum(a)) >= 0 else -1)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

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

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

Solution (Python):
in1 = input().split()
N = int(in1[0])
M = int(in1[1])
in2 = input().split()
days = 0
for i in range(M):
    days+=int(in2[i])
if days>N:
    print(-1)
else:
    print(N-days)

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

ta = sum(As)

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

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

l = 0

for i in a:
  l += i

if A < l:
  print(-1)
else:
  print(A-l)

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

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

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 = sum(a)
if s>n:
    print(-1)
else:
    print(n-s)

Solution (Python):
d,h=map(int,input().split())
alist=list(map(int,input().split()))
x=sum(alist)
if x<=d:
  print(d-x)
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()))

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

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

vacation = M - sum(days)
print(-1 if vacation < 0 else vacation)

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

for a in A:
    N -= a

if N < 0:
    N = -1

print(N)

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

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

A_sum = sum(A)

resurt = (N - A_sum) if (N - A_sum) >= 0 else -1

print(resurt)

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

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

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 sum(a)>n:
  print(-1)
else:
  print(n-sum(a))

Solution (Python):
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    N, M = map(int, input().split())
    
    s = sum(list(map(int, input().split())))
    if s > N:
        print(-1)
    else:
        print(N - s)


if __name__ == '__main__':
    main()

Solution (Python):
A,B = map(int,input().split())
s = list(map(int,input().split()))
if sum(s) <= A:
  print(A-sum(s))
else:
  print("-1")

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

q = input().split()

s = 0
for i in q:
  s = s + int(i)
  
if d-s >= 0:
	print(d-s)
else:
  	print(-1)

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

Solution (Python):
import math
import time
from collections import defaultdict,deque
from sys import stdin,stdout
from bisect import bisect_left,bisect_right
n,k=map(int,stdin.readline().split())
a=list(map(int,stdin.readline().split()))
ans=n
ans-=sum(a)
print(max(-1,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 = list(map(int, input().split()))

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

Solution (Python):
N, M = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]
print(max(-1, N - sum(A)))

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

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

if __name__ == '__main__':
    main()

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

main()

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

for j in range(b):
  a = a - i[j]
 

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

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

Solution (Python):
n,m=map(int,input().split())
 
a=list(map(int,input().split()))
s=int(sum(a))
 
if (n-s)>= 0:
  print(n-s)
  
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):
from sys import stdin, stdout
from collections import deque, defaultdict
import math as m

rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

def main():
	n, m = rli()
	tot = sum(rli())
	diff = n - tot
	if diff < 0:
		print("-1")
	else:
		print(diff)
	stdout.close()

if __name__ == "__main__":
	main()

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

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



from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement

N, M = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]

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

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

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

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

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

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

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

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

Solution (Python):
def actual(n, m, a_list):
    a_sum = sum(a_list)

    if n >= a_sum:
        return n - a_sum

    return -1

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

print(actual(n, m, a_list))

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())
lst = list(map(int,input().split()))
plus = 0
for a in lst:
    plus += a
if plus <= N:
    print(N-plus)
else:
    print('-1')

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

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

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

Solution (Python):
nums1 = [int(e) for e in input().split()]
nums2 = [int(e) for e in input().split()]

if nums1[0] - sum(nums2) >= 0:
    print(nums1[0] - sum(nums2))
else:
    print('-1')

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

A = (list(int(x) for x in input().split()))
if(sum(A)<=N):
    print(N-sum(A))
else:
    print(-1)

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

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

Solution (Python):
import math

limit = list(map(int, input().split()))
days = list(map(int, input().split()))

sum = 0

for v in days:
    sum += v

print(max(limit[0] - sum, -1))

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

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

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

Solution (Python):
import itertools
import math
import fractions
import functools
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())
hoge=list(map(int,input().split()))

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

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

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

days = sum(A)

rest = N - days
print(max(-1, rest))

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):
def ABC_163_B():
    N,M = map(int, input().split())
    A = list(map(int, input().split()))
    sum = 0

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

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

if __name__ == '__main__':

    ABC_163_B()

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

for i in range(m):
    if n >= a[i]:
        n -= a[i]
    else:
        n = -1
        break

print(n)

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

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

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

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

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)
        exit()
print(n)

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

Solution (Python):
import numpy as np
n,m=map(int,input().split())

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

s=np.sum(a)

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

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

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

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:
    print(n-sum)
else:
    print("-1")

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

ans = n-all_s

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

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

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

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

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

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

for i in range(m):
    n -= a[i]
if n < 0:
    print("-1")
else:
    print(n)

Solution (Python):
def main():
    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)
if __name__ == '__main__':
    main()

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

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

Solution (Python):
def resolve():
    a,b = map(int, input().split())
    A = list(map(int, input().split()))
    count = 0

    for c in range(b):
        count += A[c]
    
    result = a - count
    if result < 0:
        print("-1")
    else:
        print(result)
    
resolve()

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

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

all_days = sum(A)

if(all_days > N):
    print(-1)

else:
    print(N - all_days)

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


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


sumA = int( 0 )
for ai in a:
    sumA += ai

ans = n - sumA

if ans >= 0:
    print( ans )
elif ans < 0:
    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())
A = []
A.extend(map(int, input().split()))

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

Solution (Python):
import numpy as np
N, M = map(int, input().split())

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

Solution (Python):
import functools
N, M = list(map(int,input().split()))
A = list(map(int,input().split()))
N = N - functools.reduce(lambda x,y: x + y, A)
if N < 0:
    print(-1)
else:
    print(N)

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

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

if n - sum(ans) >=0:
  print(n - sum(ans))
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_list = list(map(int, input().split())) 
res = n - sum(a_list)
if res >= 0:
    print(res)
else:
    print(-1)

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

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

for i in range(M):
    N=N-li[i]

if N>=0:
    print(N)

else:
    print("-1")

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

a = [int(i) for i in a]
if int(n) >= sum(a):
    print(int(n)-sum(a))
else:
    print(-1)

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

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

homework_day = sum(A)

play_day = N-homework_day

if(play_day < 0):
    print("-1")
else:
    print("{}".format(play_day))

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

days = sum(A)
free = N - days

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

Solution (Python):
import sys
import os
import bisect, collections, copy, itertools, math, string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int, input().split()))
def LS(): return list(input().split())

def solve():
	nm = LI()
	a = LI()
	n = nm[0]
	m = nm[1]

	for _a in a:
		n -= _a

	if n < 0:
		n = -1
	print(n)
	
if __name__ == '__main__':
	solve()

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


if __name__ == "__main__":
    main()

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

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

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

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

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

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

Solution (Python):
def main():
    NM = input()
    N = int(NM.split(" ")[0])
    M = int(NM.split(" ")[1])
    strA = input()
    listA = strA.split(" ")

    X = 0
    for i in range(0, M):
        X += int(listA[i])

    Y = N - X
    if(Y < 0):
        Y = -1
    print(Y)

if __name__ == '__main__':
    main()

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

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

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

Solution (Python):
import math
import numpy as np

n,k =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()))
t=sum(A)
print(n-t if t<=n else '-1')

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

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=list(map(int,input().split()))
src=list(map(int,input().split()))
for s in src:
  N-=s
if 0<=N:
  print(N)
else:
  print(-1)

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

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

Solution (Python):

N,M = map(int,input().split())
A = [int(x) for x in 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()))
a_sum = sum(a)
if n - a_sum >= 0:
	print(n - a_sum)
else:
	print('-1')

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
input = lambda: sys.stdin.readline().strip()

def main():
    N,M = map(int,input().split())
    A_list = list(map(int,input().split()))

    for i in A_list:
        N -= i
    print(N if N>=0 else -1)

main()

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

Solution (Python):

import math
n, m = map(float,input().split())
a = map(float,input().split())

time = math.ceil(sum(a))

if time > n:
    print(-1)
elif time <= n:
    print(int(n-time))

Solution (Python):

N,M =map(int,input().split())
A =[int(j) for j in 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()))

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

Solution (Python):
import sys

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

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

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

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

Solution (Python):
total, num = map(int, input().split())
days = list(map(int, input().split()))
days = sum(days)
if days > total:
    print(-1)
elif total >= days:
    print(total - days)

Solution (Python):



import sys
sys.setrecursionlimit(10**7)
from pprint import pprint as pp
from pprint import pformat as pf

import math

import bisect


if __name__ == '__main__':
    n, m = list(map(int, input().split()))
    a_list = list(map(int, input().split()))
    s = sum(a_list)
    if n >= s:
        print(n - s)
    else:
        print(-1)

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

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

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

Solution (Python):
bg=input().split()
n=int(bg[0])
m=int(bg[1])

b2=input().split()
s=0
for a in range(m):
  s+=int(b2[a])
  
if n>=s:
  print(n-s)
else:
  print("-1")

Solution (Python):
N, M = input().split()
A = input().split()
sumStudyDay = 0

for i in A:
    sumStudyDay += int(i)
    
leftDay = int(N)-sumStudyDay

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

Solution (Python):


N, M = map(int, input().split())
A = [int(a) for a in input().split()]

for a in A: N -= a
print(N if N >= 0 else -1)

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

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

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

Solution (Python):
import numpy as np

from sys import stdin


def main():
    n, m = map(int, stdin.readline().split())
    a = list(map(int, stdin.readline().split()))
    a = np.array(a)

    ans = n - np.sum(a)

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


if __name__ == "__main__":
    main()