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 = map(int,input().split())
shukudai_kakarujikann = sum(A)
if shukudai_kakarujikann > N:
    print("-1")
    exit(0)
else:
    print(N - shukudai_kakarujikann)

Solution (Python):
N, M = [int(v) for v in input().split()]
A = [int(v) for v in 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()))
a=sum(A)
if N>=a:
  print(N-a)
else:
  print(-1)

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


s = [int(e) for e in input().split()]


sm = sum(s)

if n < sm :
  print('-1')
else:
  print( n - sm )

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

vacation = n-sum(As)
if vacation < 0:
	print('-1')
else:
	print(vacation)

Solution (Python):
n,m,*a = map(int,open(0).read().split())
print(max(-1,n-sum(a)))

Solution (Python):


day = input().split(" ")
natsu = int(day[0])
kazu = int(day[1])
syuku = input().split(" ")
total = 0
for i in range(len(syuku)):
    total += int(syuku[i])
if natsu < total:
    print(-1)
else:
    print(natsu- total)

Solution (Python):


days, task_cnt = map(int, input().split())
tasks = [int(i) for i in input().split()]

aa = days - sum(tasks)

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

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 = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

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

Solution (Python):
n,m = (int(x) for x in input().split())
a = [int(i) for i in 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())
for a in a_list:
    n -= a

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

Solution (Python):
n, m = [int(i)for i in input().split()]
t = sum([int(i)for i in input().split()])
ans = max(-1, n - t)
print(ans)

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

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

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

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

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

    if (N < sum(A)):
        ans = -1

    print(ans)


resolve()

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()))
count = 0
for i in range(M):
    count += A[i]
print()
if N < count:
    print(-1)
else:
    print(N-count)

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

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

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

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

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

sum=0
for i in range(m):
  sum+=l[i]

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

Solution (Python):
a,b=input().split()
a=int(a)
b=int(b)
x=[]
c=input().split()
for i in range(b):
    x.append(int(c[i]))
z=sum(x)
if z<= a:
    print(a-z)
else:
    print(-1)

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

ans = n - sum(a)

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

Solution (Python):
import sys
N,M = list(map(int, sys.stdin.readline().rstrip().split())) 
A = list(map(int, sys.stdin.readline().rstrip().split())) 

s = 0
for n in range(M):
  s += A[n]
  
s = N - s
if s < 0:
  print(-1)
else:
  print(s)

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

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

Solution (Python):

from collections import deque
from operator import itemgetter
from bisect import bisect_left, bisect
import itertools
import sys
import math
sys.setrecursionlimit(10**6)
input = sys.stdin.readline



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


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):
N, M = input().split()
A = input().split()

N = int(N)
M = int(M)


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



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

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

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

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

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

Solution (Python):
input_line1 = input()
input_line2 = input()

n, m = map(int, input_line1.split())
a_list = map(int, input_line2.split())

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

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

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):
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())
h = list(map(int, input().split()))
res = max(N - sum(h), -1)
print(res)

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 = map(int, input().split())
l = list(map(int, input().split()))

s = sum(l)

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

Solution (Python):
import math
import operator as op
from functools import reduce

def ncr(n, r):
    r = min(r, n-r)
    numer = reduce(op.mul, range(n, n-r, -1), 1)
    denom = reduce(op.mul, range(1, r+1), 1)
    return numer / denom
"""
int(input())
map(int,input().split())
list(map(int,input().split()))
"""


            
       

t=1
for term in range(1,t+1):
    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())
li = list(map(int,input().split()))

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

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

import sys


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



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

    sum = 0
    for i in range(M):
        sum += a[i]
    left = N - sum
    if left >= 0:
        print(left)
    else:
        print(-1)

if __name__ == '__main__':
    main()

Solution (Python):


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

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

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())
li = list(map(int, input().split()))

s = sum(li)
if (s > n):
    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())
A_list=list(map(int,input().split()))
sum_A=sum(A_list)
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):
n, m = tuple(map(int, input().split()))
nums = list(map(int, input().split()))

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

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


for i in a:
    n-=i
if n>=0 :
    print(n)
elif n < 0:
    print(-1)

Solution (Python):


import sys
import math
import bisect
from fractions import gcd
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint

INF = float('inf')

ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
lmtx = lambda h: [list(map(int, lmis())) for _ in range(h)]
sys.setrecursionlimit(1000000000)


def lcm(a, b):
    return (a * b) // gcd(a, b)



n, m = mis()
alist = lmis()

freedays = n - sum(alist)

if freedays < 0:
    print('-1')
else:
    print(str(freedays))

Solution (Python):
n, m = map(int, input().split())
a = 0
alist = list(map(int, input().split()))
for _ in alist:
  a += _

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

else:
  ans = n - a
  print(ans)

Solution (Python):
import numpy as np

n,m = map(int, input().split())
arr = [int(_) for _ in input().split()]

if n < np.sum(arr):
  print(-1)
else:
  print(n-np.sum(arr))

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

sum_a = sum(a)
res = n - sum_a
if res < 0:
    res = -1
print(res)

Solution (Python):


def main():
    *I, = map(int, open(0).read().split())
    N = I[0]
    M = I[1]
    A = I[2:]

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


main()

Solution (Python):


n, m = [0] * 2
a = []

def format_input(filename = None):
	global n, m
	global a
	if filename == None:
		n, m = list(map(int, input().split()))
		a = list(map(int, input().split()))

	elif filename == '__random__':
		from random import randint as rng
		n = rng(1, 10**6)
		m = rng(1, 10**4)
		a = [rng(1, 10**4) for i in range(m)]
		print(n, m)
		print(' '.join(list(map(str, a))))

def get_answer():
	answer = max(n - sum(a), -1)
	return answer

if __name__ == '__main__':
	format_input()

	ans = get_answer()
	print(ans)

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

Solution (Python):
import numpy as np
if __name__ == "__main__":
    
    
    
    
    N, M = map(int, input().split())
    
    line = np.array(list(map(int, input().rstrip().split(' '))))
    ans = N-line.sum()
    if ans >= 0:
        print(ans)
    else:
        print(-1)

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

cost = list(map(int,input().split()))
flg = True

for i in cost:
    n -= i
    if n < 0:
        print(-1)
        flg = False
        break
if flg:
    print(n)

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

Solution (Python):
def main():
  N, M = map(int, input().split())
  xyz = [int(t) for t in input().split()]
  hi = N - sum(xyz)
  if hi >= 0:
    print(hi)
  else:
    print(-1)
main()

Solution (Python):
day,work_num=map(int,input().split())
works=list(map(int,input().split()))
if day>=sum(works):
    print(day-sum(works))
else:
    print(-1)

Solution (Python):
import math

nm = input().split(" ")

m = int(nm[0])
n = int(nm[1])

alist = input().split(" ")

sum = 0

for i in range(n):
    sum = sum + int(alist[i])

if sum <= m:
    sa = math.floor(m-sum)
    print(sa)
else:
    print(-1)

Solution (Python):
def solution():
    return 1

def main():
    N , M = list(map(int , input().split()))
    assignments = list(map(int , input().split()))
    for a in assignments:
        N -= a 
    if N < -1:
        N = -1
    print(N)       
   
if __name__ == "__main__":
    main()

Solution (Python):
def main():
    N, M = map(int, input().split(' ')) 
    An = list(map(int, input().split(' '))) 
    
    if sum(An) > N:
        print('-1')
        return
    
    out = []
    for a in An:
        if a <= 24:
            out.append(a)
        else:
            t = a // 24
            m = a % 24
            for _ in range(t):
                out.append(24)
            out.append(m)
    nissuu = len(out)
    
    
    print(N - sum(out))
            
    
    
    
    
main()

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


if __name__ == "__main__":
    
    
    
    
    
    main()

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

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

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

time_to_finish = sum([int(x) for x in input().split(' ')])
hanging_out = n - time_to_finish

if hanging_out < 0:
    print('-1')
else:
    print(hanging_out)

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

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

Solution (Python):
import math
def A():
    r = int(input())
    print(math.pi*(r)*2)

def B():
    N, M = map(int, input().split())
    A = [int(i) for i in input().split()]
    ans = N-sum(A)
    if ans >= 0:
        print(ans)
    else:
        print(-1)

B()

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

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

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

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

Solution (Python):
l=[int(i) for i in input().split()]
m=[int(i) for i in input().split()]
print(max(-1,l[0]-sum(m)))

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

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

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

summ = sum(A)
subd = N_niti - summ

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

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

total = sum(lst)

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

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 math



if(__name__ == '__main__'):
    
    n, m = map(int, input().split(" "))
    a = list(map(int, input().split(" ")))

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

    ans = -1
    if sum <= n:
        ans = n - sum

    print(ans)

Solution (Python):
import numpy as np
from collections import defaultdict
from math import gcd
import time
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


start = time.time()
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_lst = list(map(int, input().split()))

res = n - sum(a_lst)

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

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

Solution (Python):
D, N = map(int, input().split())
d=list(map(int,input().split()))
SUM=sum(d)

if SUM > D:
    print(-1)
else:
    print(D-SUM)

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

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

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

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

Solution (Python):
NM = input()
NMs = NM.split(" ")
N = int(NMs[0])
M = int(NMs[1])
A = input()
Ai = A.split(" ")
days = 0
for i in Ai:
    days = days + int(i)
if days <= N:
    print (N - days)
else:
    print("-1")

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

for i in a:
    arr += i

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

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

allAssignm = sum(A)

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

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

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

A_ = sum(A)

if N >= A_:
    print(N-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):
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


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


if __name__ == '__main__':
    main()

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

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

Solution (Python):
def main():
    n, m = map(int, input().split())
    a_list = list(map(int, input().split()))
    s = sum(a_list)
    print(max(-1, 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 -= a[i]
    
if N < 0:
    print(-1)
else:
    print(N)

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

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

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

for a_i in a:
    total = total + int(a_i)

print( max( int(n)-total, -1 ) )

Solution (Python):
a,b=map(int,input().split())
List=list(map(int,input().split()))
for i in List:
  a-=i
if a>=0:
  print(a)
else:
  print("-1")

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

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

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

for i in range(len(s)):
  a=a-s[i]
  
if a>=0:
  print(a)
else:
  print("-1")

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

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

c = map(int,input().split())
syukudai = sum(c)

if syukudai <= yasumi:
  print(str(yasumi - syukudai))
else:
  print("-1")

Solution (Python):
N, M = [int(s) for s in input().split()]
sAs = sum([int(s) for s in input().split()])

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

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

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

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

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

  req_days = sum(A_list)

  ans = N-req_days

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


if __name__ == "__main__":
  main()

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

res = N- sum(Alist)

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

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

total=sum(A)

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

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

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

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

N = NM[0]

ans = N - sum(A)

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

Solution (Python):
N,M = list(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):
N,M = map(int,input().split())
Am = list(map(int,input().split()))
res = N-sum(Am)
if res < 0:
  print(-1)
else:
  print(N-sum(Am))

Solution (Python):
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
A = [int(i) for i in input().split()]
del A[m:len(A)]
print(n - sum(A)) if sum(A) <= n else print(-1)

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

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

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

do = 0

for i in range(m):
    do += li[i]

ans = n-do

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

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

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

Solution (Python):



import sys


def input():
    return sys.stdin.readline()


def resolve():
    n, m = map(int, input().split())
    a_list = list(map(int, input().split()))

    task = 0
    for ai in a_list:
        task += ai

    if task > n:
        print("-1")
    else:
        print(n- task)


if __name__ == "__main__":
    resolve()

Solution (Python):
N, M = list(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 = (int(x) for x in input().split())
la = list(map(int, input().split()))
s = n-sum(la)
print(s if s>=0 else -1)

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

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

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

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

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

ans=n-sum(hw)
if ans>=0:
    print(ans)
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):
natu = input().split()
n = int(natu[0])
m = int(natu[1])

work = input().split()
work = [int(n) for n in work]

summary = sum(work)

if (n < summary):
    print(-1)
elif (n == summary):
    print(0)
else:
    print(n-summary)

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=list(map(int,input().split()))
i=max(-1,n-sum(a))
print(i)

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

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


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        
        
        lines.append(input())
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (n, m) = [int(e) for e in lines[0].split(' ')]
    a = [int(e) for e in lines[1].split(' ')]

    return (n, m, a)


def solve(n, m, a):

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

    
    return result
    


def main():
    
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()

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

rem = n - sum(a)

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

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())
li=[int(i) for i in input().split()]

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

Solution (Python):
import sys
M, N = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
total = 0
for i in range(N):
  total += A[i]
  if(total>M):
    print(-1)
    sys.exit()
print(M-total)

Solution (Python):
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
n,m = [int(i) for i in readline().split()]
A = [int(i) for i in readline().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()))

SA = sum(A)
if N < SA :
    print("-1")
else:
    D = N - SA
    print(int(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(n < sum):
	print("-1")
else:
	print(n - sum)

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())
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()))
print(max(-1, N - sum(a)))