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

Solution (Python):
from math import *
from copy import *
from string import *				
from random import *
from sys import stdin
from sys import maxsize
from operator import *				
from itertools import *
from collections import Counter		
import math

def bin1(l,r,k,t,b,val,ans):
	if(l>r):
		return ans
	else:
		mid=(l+r)//2
		v=k**mid
		if(v==val):
			return v
		elif(v>val):
			ans=mid
			return bin1(mid+1,r,k,t,b,val,ans)
		else:
			return bin1(l,mid-1,k,t,b,val,ans)
		
def bin2(l,r,k,t,b,val,ans):
	if(l>r):
		return ans
	else:
		mid=(l+r)//2
		v=t*(k**mid)+b*(mid)
		if(v==val):
			return v
		elif(v>val):
			ans=mid
			return bin2(l,mid-1,k,t,b,val,ans)
		else:
			return bin2(mid+1,r,k,t,b,val,ans)

def SieveOfEratosthenes(n): 
      
    
    
    
    prime = [True for i in range(n+1)] 
    p = 2
    while (p * p <= n): 
          
        
        if (prime[p] == True): 
              
            
            for i in range(p * p, n+1, p): 
                prime[i] = False
        p += 1
    return prime
def bin(l,r,ll,val):
	if(l>r):
		return -1
	else:
		mid=(l+r)//2
		if(val>=ll[mid][0] and val<=ll[mid][1]):
			return mid
		elif(val<ll[mid][0]):
			return bin(l,mid-1,ll,val)
		else:
			return bin(mid+1,r,ll,val)
def deci(n):
	s=""
	while(n!=0):
		if(n%2==0):
			n=n//2
			s="0"+s
		else:
			n=n//2
			s="1"+s
	return s
def diff(s1,s2):
	if(len(s1)<len(s2)):
		v=len(s1)
		while(v!=len(s2)):
			s1="0"+s1
			v=v+1
	else:
		v=len(s2)
		while(v!=len(s1)):
			s2="0"+s2
			v=v+1
	c=0
	for i in range(len(s1)):
		if(s1[i:i+1]!=s2[i:i+1]):
			c=c+1
	return c
from sys import stdin, stdout 
if __name__ == '__main__':
	n,m=map(int,stdin.readline().split(" "))
	l=list(map(int,stdin.readline().split(" ")))
	total=sum(l)
	if(total>n):
		stdout.write(str(-1)+"\n")
	else:
		stdout.write(str(n-total)+"\n")

Solution (Python):

import sys


def solve(N: int, M: int, A: "List[int]"):
    if (N-sum(A) < 0):
        print(-1)
    else:
        print(N-sum(A))
    return



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

if __name__ == '__main__':
    main()

Solution (Python):
a,b = map(int, input().split())
s = input()
count = 0
nums = s.rstrip().split(' ')
for num in nums:
  count += int(num)
c = a - count
if c >= 0:
  print(c)
else:
  print(-1)

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

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

Solution (Python):
N, M = [int(s) for s in input().split(" ")]
A = [int(s) for s in 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()))

p = sum(a)

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

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

else:
    print(N-A)

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

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

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

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

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

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

diff = N - sum(A)

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

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

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

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

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

B = sum(A)

if N >= B:
  print(N-B)

else:
  print('-1')

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

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):
a, b = list(map(int, input().strip().split()))
c = list(map(int, input().split()))
d = a - sum(c)
print(d if d >= 0 else '-1')

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

Solution (Python):


def solve():
    N, M = map(int, input().split())
    A = [int(i) for i in input().split()]
    print(max(N - sum(A), -1))


if __name__ == '__main__':
    solve()

Solution (Python):



def main():
    import sys
    input = sys.stdin.readline
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    diff = n - sum(a)

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


if __name__ == '__main__':
    main()

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

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

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

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

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

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

num_list_sum=sum(num_list)

if n>=num_list_sum:
  print(n-num_list_sum)
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 = 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()))



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

Solution (Python):
import sys
import math



def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())

def LI(): return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'


p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")



N,M=MI()
A=LI()
if N-sum(A) < 0 :
  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):
def abc(N, M, A):
    
    ans = N
    
    
    for i in range(0, M):
        ans -= A[i]
    
    
    if ans < 0:
        ans = -1
    
    
    return(ans)



if __name__ == "__main__":
    
    
    N, M = map(int, input().split())
    
    
    A = list(map(int, input().split()))
    
    
    f = abc(N, M, A)
    
    
    print(f)

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

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):
N, M = map(int, input().split())
Days = list(map(int, input().split()))
total_days = sum(Days)
diff = N - total_days
if diff >= 0:
    print(diff)
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 = map(int, input().split())
a = list(map(int, input().split()))
print(max(n - sum(a), -1))

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

Solution (Python):
import numpy as np
N,M = map(int,input().strip().split(" "))
A = np.empty(M)
A = np.array(input().strip().split(" ")).astype(np.int32)
res = N - A.sum()
if res >= 0:
    print(res)
else:
    print(-1)

Solution (Python):

"""
Spyderエディタ

これは一時的なスクリプトファイルです
"""

n, m = map(int, input().split())
nums = [int(s) for s in input().split()]

asobi = n - sum(nums)

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

Solution (Python):
import numpy as np

N, M = input().split()

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

if np.sum(A) <= int(N):
    print(int(N)-np.sum(A))
    
else:
    print(-1)

Solution (Python):
m,n = map(int,input().split())
l = list(map(int,input().split()))
s = 0
for i in range(n):
  s += l[i]
print(max(m-s,-1))

Solution (Python):
m,n = map(int,input().split())
l = list(map(int,input().split()))
s = 0
for i in range(n):
  s += l[i]
print(max(m-s,-1))

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

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

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

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

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

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

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

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

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

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

Solution (Python):
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("-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())
A=[int(e) for e in input().split()]
s=0
for i in A:
    s+=i
if N-s>=0:
    print(N-s)
else:
    print(-1)

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

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

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



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

Solution (Python):

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

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

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

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

total = 0
for time in times:
    total += time

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

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

Solution (Python):
n = input().split(" ")
a = input().split(" ")
n[0] = int(n[0])
sum_HomeworkDays = 0

for i in a:
	sum_HomeworkDays += int(i)
    
if n[0]-sum_HomeworkDays >= 0:
  print(n[0]-sum_HomeworkDays)
else:
  print("-1")

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

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

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

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

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

sum=sum(a)

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

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

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

    ans = -1
    if sum(a) <= n:
        ans = n - sum(a)

    print(ans)

if __name__ == '__main__':
    main()

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

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

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

total = sum(a)

answer = n - total

if total > n:
    answer = -1

print(answer)

Solution (Python):

def main():
    N, _, *A = map(int, open(0).read().split())
    print(max(-1, N - sum(A)))


if __name__ == "__main__":
    main()

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

Solution (Python):
print(max(int(input().split()[0]) - sum(map(int, input().split())), -1))

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

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

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

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

if __name__ == "__main__":
    main()

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

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

if __name__ == "__main__":
    main()

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

l = 0
i = 0

for i in A:
    l += i

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

Solution (Python):
def main():
    N, M = map(int, input().split())
    li = list(map(int, input().split()))
    s = 0
    for i in range(M):
      s += li[i]

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

if __name__ == '__main__':
  main()

Solution (Python):
N=()
M=()
A=()

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

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

Solution (Python):
NM = [int(s) for s in input().split()]
N, M = NM[0], NM[1]
arr = [int(s) for s in input().split()]
total = sum(arr)
if total <= N:
    print(N-total)
else:
    print(-1)

Solution (Python):
NM = [int(s) for s in input().split()]
N, M = NM[0], NM[1]
arr = [int(s) for s in input().split()]
total = sum(arr)
if total <= N:
    print(N-total)
else:
    print(-1)

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

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

HW = list(map(int,input().split()))
Holidays = N -sum(HW)

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

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

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

Solution (Python):
def Main():
    N, M = list(map(int, input().split(" ")))
    nSums = sum(list(map(int, input().split(" "))))
    
    playDays = N - nSums if nSums <= N else -1
    print(playDays)
    
    
if __name__ == "__main__":
    Main()

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

Solution (Python):
def main():
    N, M = map(int, input().split())
    HW = [int(a) for a in input().split()]
    if N >= sum(HW):
        print(N-sum(HW))
    else:
        print(-1)
if __name__ == "__main__":
    main()

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

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

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

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

day = 0

for i in A:
    day += i

remaining = N-day

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

Solution (Python):
import numpy as np
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

N, M = map(int, input().split())
A = np.array(list(map(int, input().split())))
tot = np.sum(A)

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

Solution (Python):
import numpy as np
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

N, M = map(int, input().split())
A = np.array(list(map(int, input().split())))
tot = np.sum(A)

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

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

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

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

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

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

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):
NM = str(input()).split()
work = str(input()).split()
SV = int(NM[0])
for i in range(len(work)):

	SV -= int(work[i])
	if SV <= -1:
		SV = -1
		break

print(SV)

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

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

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

min_time=0
for i in range(M):
    min_time=min_time+necess[i]
    

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

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

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

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

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

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

Solution (Python):
days , assi = map(int,input().split())
lst = []
lst = [int(i) for i in input().split()]
tot = sum(lst)
if (tot>days):
    print(-1)
else:
    print(days-tot)

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

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

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

totalA = sum(A)

ans = N - totalA

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

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

c = input().split()

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

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

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

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

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

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

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

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

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

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

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

Solution (Python):
duration, homeworks_count = [int(x) for x in input().split(' ')]
homework_lengths = [int(x) for x in input().split(' ')]

print(max(duration - sum(homework_lengths), -1))

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

suma = sum(listA)
out = n - suma
if out >= 0:
  print(out)
else:
  print("-1")

Solution (Python):

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

tot = sum(a)
ans = max(-1, n-sum(a))
print(ans)

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

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

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

Solution (Python):
N, K = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
ans = N - sum(l)
if ans < 0:
  print(-1)
else:
  print(ans)

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

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

Solution (Python):
days , assi = map(int,input().split())
lst = []
lst = [int(i) for i in input().split()]
tot = sum(lst)
if (tot>days):
    print(-1)
else:
    print(days-tot)

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

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

Solution (Python):
import sys
from random import choice,randint
inp=sys.stdin.readline
out=sys.stdout.write
flsh=sys.stdout.flush
 
sys.setrecursionlimit(10**9)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
 
def MI(): return map(int, inp().strip().split())
def LI(): return list(map(int, inp().strip().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines().strip()]
def LI_(): return [int(x)-1 for x in inp().strip().split()]
def LF(): return [float(x) for x in inp().strip().split()]
def LS(): return inp().strip().split()
def I(): return int(inp().strip())
def F(): return float(inp().strip())
def S(): return inp().strip()
def pf(s): return out(s+'\n')
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)

def main():
    n,m=MI()
    a = LI()
    s = sum(a)
    if s>n:
        print(-1)
    else:
        print(n-s)

if __name__ == "__main__":
    main()

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

if A>=sum(Lis):
    print(A-sum(Lis))

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

Solution (Python):
import sys


try:
    sys.stdin = open(sys.path[0] + '\\input.txt', 'r')
    sys.stdout = open(sys.path[0] + '\\output.txt', 'w')
except FileNotFoundError:
    pass


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

sm = n - sum(arr)

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

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

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

Solution (Python):
t=list(map(int,input().split()))		
s=list(map(int,input().split()))		
 
temp = 0
for i in s:
  temp += i


if(t[0]-temp>=0):
  print(t[0]-temp)
else:
  print(-1)

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

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

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

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

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

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

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

result = 0

for i in A:
    result = result + i

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

Solution (Python):
def input_int_list():
    return [int(thing) for thing in input().split(" ")]

def int_input():
    return int(input())

N,M=input_int_list()
A_list=input_int_list()

ans=N-sum(A_list)
if ans<0:
    ans=-1

print(ans)

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

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

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

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

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