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

Solution (Python):
from sys import stdin

lines = stdin.readlines()

n, m = [int(x) for x in lines[0].rstrip().split()]
a_s = [int(x) for x in lines[1].rstrip().split()]

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

Solution (Python):
a,b=map(int,input().split())
c=list(map(int,input().split()))
k=0
for h in c:
    k=k+h
if a<k:
    print(-1)
else:
    print(a-k)

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

Solution (Python):

a,b=map(int,input().split())
li=list(map(int,input().split()))
sum_w=sum(li)
c=a-sum_w
if c<0:
    print(-1)
else:
    print(c)

Solution (Python):
N,M=map(int,input().split())
A=[int(_) for _ in input().split()]
cnt=0
for i in A:
  cnt+=i
ans=N-cnt
if ans<0:
  ans=-1
print(ans)

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

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

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

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

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

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

print(ans)

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

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

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

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

if M>=sum_A:
  print(M-sum_A)
else:
  print(-1)

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

sum = 0

for i in a:
    sum += i

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

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

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


sumA = sum(A)
bj = -1

if NM[0]-sumA >= 0:
    print(NM[0]-sumA)

else:
    print(bj)

Solution (Python):
n,m = input().split()
n = int(n)
m = int(m)
mlist = input().split(" ")
intmlist = [int(s) for s in mlist]
intmlist.sort(reverse=True)


    


for i in range(0,m):
    n = n - intmlist[i]
    if n < 0:
        print(-1)
        break
    if i == m - 1:
        print(n)

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

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

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

day = list(map(int,input().split()))
days = 0
for i in range(m):
  days += day[i]
  
ans = n -days
if(ans<0):
	print(-1)
else:
  print(ans)

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

ans = -1
A_total = sum(A)

if N - A_total >= 0:
    ans = N - A_total

print(ans)

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

a_sum = sum(A)

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

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

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

Solution (Python):
n, m = map(int, 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()))
homework = sum(a)
dayoff= n - homework
if dayoff < 0:
    print("-1")
else:
    print(dayoff)

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

Solution (Python):
import sys
import math
input = sys.stdin.buffer.readline
def int_array():
	return list(map(int, input().strip().split()))
def str_array():
	return input().strip().split()
 


d, n = int_array()
days = d-sum(int_array())
if days >= 0:
	print(days)
else:
	print(-1)

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


summer_holidays = N
work_days = sum(A)
actual_holidays = summer_holidays - work_days
    
answer = max(-1, actual_holidays)

print(answer)

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

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

Solution (Python):
import numpy as np

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

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

ans = -1

for i in range(m):
  n -= a[i]
  if n < 0:
    break

if n >= 0:
  ans = n

print(ans)

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

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

Solution (Python):
a,b=map(int,input().split())
list1=[0]*b
list1=list(map(int,input().split()))
ans=a-sum(list1)
if ans<0:
    ans=-1
print(ans)

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

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

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

N=int(N)
for i in A:
  N-=int(i)
if N<0:
  print(-1)
else:
  print(N)

Solution (Python):
import numpy as np

def main():
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    nisuu = a[0]
    syukudai = np.sum(np.array(b))
    if nisuu >= syukudai:
        print(nisuu-syukudai)
    else:
        print(-1)

if __name__ == '__main__':
    main()

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

Solution (Python):
def main_function():
    from sys import stdin
    from sys import stdout
    input = stdin.readline
    print = stdout.write

    n, m = list(map(int, input().split()))
    a = list(map(int, input().split()))
    summa = sum(a)
    if summa > n:
        print(f'-1')
    else:
        print(f'{n - summa}')


if __name__ == '__main__':
    main_function()

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

Solution (Python):



import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

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

Solution (Python):
n, m = map(int, input().split())
s = list(int(a) for a in input().split())
ans = n - sum(s)

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

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

Solution (Python):
line1 = input()
line2 = input()
n, m = line1.split(" ")
a_list = line2.split(" ")
a_list = [int(a) for a in a_list]
day = sum(a_list)

if int(n) < day:
    print(-1)
else:
    print(int(n)-day)

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

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

print(d)

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

def main():
    nm = list(map(int, input().split()))
    a = list(map(int, input().split()))
    aa = nm[0] - sum(a)
    aa = aa if aa >= 0 else -1
    print(aa)

if __name__ == '__main__':
    main()

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

syuku = list(map(int, input().split(' ')))

result = N - sum(syuku)

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

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

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

homework_day = sum(A)

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

Solution (Python):
from sys import stdin

def main():

    input = stdin.readline

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

    ans = N - sum(A)

    if ans < 0:
        ans = -1

    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
a,b=map(int,input().split())
s=-1
List=list(map(int,input().split()))
t=sum(List)
if a-t>=0:
  s=a-t
print(s)

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

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

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

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

homework_days = sum(An)

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

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

S=0
for x in range(0,M):
	S=S+X[x]

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

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

Solution (Python):
n,m=map(int,input().split())
li=[int(x) for x in input().split()]
s=sum(li)
if n>=s:
	print(n-s)
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):
N,M = map(int, input().split())
M_list = input().split()

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

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

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

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

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

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

Solution (Python):
def main():
    i = input().split()[0]
    i = int(i)
    ii = input().split()
    ii = [int(x) for x in ii]
    ii = sum(ii)
    if ii > i:
        print(-1)
    else:
        print(i - ii)


main()

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

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

print(ans)

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

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

Solution (Python):


import sys
import pprint

sys.setrecursionlimit(10 ** 6)

class Logger:
	def __init__(self, debug):
		self.debug = debug
	def print(self, *args):
		if self.debug:
			pprint.pprint(args)


def main():
	log = Logger(1)
	n, m = map(int, sys.stdin.readline().split())
	a = list(map(int, sys.stdin.readline().split()))
	if n - sum(a) >= 0:
		print(n-sum(a))
	else:
		print(-1)
	


main()

Solution (Python):


def main():


    line1 = input().split(' ')
    n = int(line1[0])
    m = int(line1[1])
    a = [int(x) for x in input().split(' ')]
    s = sum(a)
    rest = n - s
    if rest >= 0:
        print(rest)
    else:
        print(-1)
    

if __name__ == '__main__':
    main()

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

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

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

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

res = N - sum(As)

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

Solution (Python):
input = raw_input

n, m = map(int, input().split(" "))
ds = map(int, input().split(" "))
sd = sum(ds)
out = n - sd

if out < 0:
    out = -1
print(out)

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

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

play_days = N
for i in A:
  play_days -= i
if play_days < 0:
  print(-1)
else:
  print(play_days)

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

days = n - sum(am)

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

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

Ans_sum = sum(A)

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

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

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

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

sum_A = sum(A)

ans = N - sum_A

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

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

Solution (Python):
import math




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


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

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

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

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

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

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

days = N - sum(A)

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

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

Solution (Python):

from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect

def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    n, m = LI()
    a = LI()
    if n - sum(a) >= 0:
        print(n - sum(a))
    else:
        print('-1')

    return


if __name__ == "__main__":
    solve()

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 math

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

for i in range (m):
    s = s + math.ceil(a[i])

t = n - s

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

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

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

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

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

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))


def main():
    N, M = MI()
    A = LI()
    sumA = sum(A)
    ans = N - sumA
    if ans<0:
        print(-1)
    else:
        print(ans)



if __name__ == "__main__":
	main()

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Solution (Python):
import math
s = input().split()
n=int(s[0])
m = int(s[1])
s = input().split()
for i in s:
    n-=int(i)
if n<0:
    print(-1)
else:
    print(n)

Solution (Python):
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import time
import math
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
sys.setrecursionlimit(10**7)
input=lambda :sys.stdin.readline().rstrip()
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()))
v = n
for d in a:
    v -= d
print(v if v>=0 else -1)

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

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

Solution (Python):
if __name__ == '__main__':
    s = input().rstrip().split(' ')
    N,M = int(s[0]), int(s[1])
    s = input().rstrip().split(' ')
    A = [int(elem) for elem in s]
    res = N-sum(A)
    print(-1 if res<0 else res)

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

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

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

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

Solution (Python):
k,p = map(int,input().split())
H = list(map(int,input().split()))
kk=sum(H)
if k-kk >= 0:
    print(k-kk)
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=[0]*M
day=0
A= [int(i) for i in input().split()]
for cnt in range(M):
  day+=A[cnt]
  if day>N:
    ans=-1
    break
ans=N-day
if ans<0:
  print("-1")
else:
  print(ans)

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

a = sum(list(map(int, input().split()))) 
ans = n - a

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

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

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

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


import numpy as np
import math


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

A = map(int, input().split())
count = 0
for a in A:
    count += a

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

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

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

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

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

if __name__ == '__main__':
    main()

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

asoberu = n - homeworks
asoberu = asoberu if asoberu >= 0 else -1

print(asoberu)

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


ans = n
for i in range(m):
    ans -= lis[i]
if ans >= 0:
    print(ans)
else:
    print("-1")

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

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

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

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

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

Solution (Python):
i,ii = map(int,input().split())

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

sum = sum(l)

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

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

Solution (Python):
il1 = input().split()
il2 = input().split()

il1 = [int(i) for i in il1]
il2 = [int(i) for i in il2]

N = il1[0]
M = il1[1]

A = il2

for a in il2:
    N = N - a

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

Solution (Python):
nm = list(map(int, input().split()))
a = list(map(int, input().split()))
asobi=nm[0]
for i in range(nm[1]):
    asobi-=a[i]

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

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

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

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

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

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

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

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

Solution (Python):
import math
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(int(N-sum))

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

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

day_sum = sum(A)

ans = N - day_sum

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

else:
    print(str(ans))

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

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

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

Solution (Python):


import sys
import math


sys.setrecursionlimit(10 ** 6)

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

a_sum = sum(A)

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

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

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

hw = sum(A)
play = N - hw

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

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

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

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

task_time = sum([int(i) for i in A_lis])

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

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