peterverebics/CodeNet_Python_118 huggingface dataset:
n,m = map(int,input().split())

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

if n-A>=0:
    print(n-A)
else:
    print(-1)
# -*- coding: utf-8 -*-
import math

###
# main
if(__name__ == '__main__'):
    # input
    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)

# else:
    # do nothing
def b163(n, m, al):


    return n - sum(al) if n - sum(al) >= 0 else "-1"

def main():
    n , m = map(int, input().split())
    al = list(map(int, input().split()))
    print(b163(n, m, al))

if __name__ == '__main__':
    main()
N, M = map(int,input().split())
A=[int(i) for i in input().split()]
sum=0
for i in range(M):
  sum=sum+A[i]
days=N-sum
if days<0:
  print("-1")
else:
  print(days)
N,M = map(int,input().split())
data = list(map(int,input().split()))
s = sum(data)
ans = N - s
if ans < 0:
    print(-1)
else:
    print(ans)
n, m = map(int, input().split())
a = sum(map(int, input().split()))
print([n - a, -1][n < a])
N,M=map(int,input().split(' '))
A=list(map(int,input().split(' ')))
print(max(N-sum(A),-1))
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)
N, M = map(int, input().strip().split())
As = list(map(int, input().strip().split()))

rest = N - sum(As)
if rest < 0:
    print(-1)
else:
    print(rest)
n, m = map(int, input().split())
sum = sum(list(map(int, input().split())))
remain = n - sum
print(remain if remain >= 0 else -1)
n,m = map(int,input().split())
list_work =list(map(int,input().split()))
l = n-sum(list_work)
if(l<0):
  print(-1)
else:
  print(l)
n, m = map(int,input().split())
a = list(map(int, input().split()))
t = 0

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

print(ans)
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)
#!/usr/bin/env python3

n,m=map(int,input().split())
arr=list(map(int,input().split()))
print(max(-1,n-sum(arr)))
total, n = (map(int, input().split()))
ar = list((map(int, input().split())))
sum =0
for i in ar:
    sum += i
if sum > total:
    print(-1)
else :
    print(total - sum)
n , m = map(int,input().split())
a = list(map(int,input().split()))
S = sum(a)
if S > n:
    print('-1')
else:
    print(n - S)
N, M = map(int, input().split())
A = list(map(int, input().split()))
SumA = sum(A)
print(max(-1, N - SumA))
N,M = (int(i) for i in input().split())  
A = [int(i) for i in input().split()] 
res = N - sum(A)
if res > -1:
  print(res)
else:
  print(-1)
N, M = map(int, input().split())
A = list(map(int, input().split(" ")))
val = N-sum(A)
if val < 0:
    print(-1)
else :
    print(N-sum(A))
n, m = map(int, input().split())
arr = list(map(int, input().split()))

sm = sum(arr)

if sm > n:
    print(-1)
else:
    print(n-sm)
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")
        exit()
    elif N>=0 and i+1 == M:
        print(N)
        exit()
N,M = map(int,input().split())

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

a = sum(l)

if N-a >= 0:
    print(N-a)

else:
    print(-1)
n,m = map(int,input().split())

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

if n - sum(al) >= 0:
    print(n-sum(al))
else:
    print(-1)
n,m = map(int,input().split())
a = sum(list(map(int,input().split())))
if n -a >= 0:
  print(n-a)
else:
  print(-1)
N, M = map(int, input().split())
A = list(map(int, input().split()))
if sum(A)> N:
    print(-1)
else:
    print(N-sum(A))
n, m = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
for num in a:
    ans += num
if n - ans >= 0:
    print(n-ans)
else:
    print(-1)
N, M = map(int, input().split())
l = list(map(int, input().split()))
l.sort()

free = N - sum(l)
print( -1 if free<0 else free)
N, M = map(int,input().split())
A = list(map(int,input().split()))

sum_A = sum(A)
remain = N - sum_A

if remain >= 0:
    print(remain)
else:
    print(-1)
n,m = map(int,input().split())
s = sum(map(int,input().split()))
print(max([n-s,-1]))
a, b = map(int, input().split())
s = list(map(int, input().split()))
if(sum(s) > a):
  print(-1)
else:
  print(a - sum(s))
n, m = map(lambda x: int(x) ,input().split())
a = input().split()
a = [int(_) for _ in a]

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

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

days = 0

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

remaining = n-days

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

print(max(-1, N-sum(A)))
# -*- coding: utf-8 -*-
# 整数の入力
n, m = map(int, input().split())
# スペース区切りの整数の入力
daystr = input().split()
homeworks = []
for s in daystr:
    homeworks.append(int(s))

days = sum(homeworks)
playable_days = n - days
if playable_days < 0:
    print(-1)
else:
    print(playable_days)
N, M = map(int, input().split())
A = list(map(int, input().split()))

answer = N - sum(A)

if N >= sum(A):
    print(answer)

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

sm = sum(A)
if N < sm:
    print(-1)
else:
    print(N-sm)
n, m = tuple(map(int, input().split()))
nums = list(map(int, input().split()))

ans = n - sum(nums)
print(ans if ans >= 0 else '-1')
N, M = map(int, input().split())
A = list(map(int, input().split()))
if sum(A) <= N:
    print(N - sum(A))
else:
    print(-1)
N, M = map(int, input().split())
As = list(map(int, input().split()))
if N-sum(As) < 0:
  print("-1")
else:
  print(N-sum(As))
n,m=map(int,input().split())
a=list(map(int,input().split()))
if n>=sum(a):
  print(n-sum(a))
else:
  print(-1)
val = list(map(int, input().split(" ")))
data = list(map(int, input().split(" ")))

if sum(data) > val[0]:
    print(-1)
else:
    print(val[0] - sum(data))
n, m = map(int, input().split())
a_list = [int(i) for i in input().split()]

answer = n-sum(a_list)
if answer < 0:
    print(-1)
else:
    print(answer)
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


############ ---- Input Functions ---- ############
def in_int():
    return (int(input()))


def in_list():
    return (list(map(int, input().split())))


def in_str():
    s = input()
    return (list(s[:len(s) - 1]))


def in_ints():
    return (map(int, input().split()))

mod = 7 + 10**9

n, m = in_ints()

a = in_list()

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

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

if N < sum(A):
    print(-1)
else:
    print(N - sum(A))
x, y = map(int,input().split())
arr = list(map(int, input().split()[:y]))
s = 0
for i in arr:
    s += i
re = x - s
if s > x:
    print(-1)
elif s == x:
    print(0)
else:
    print(re)
if __name__ == "__main__":
    n, m = map(int, input().split())
    al = list(map(int, input().split()))
    res = sum(al[:m])
    res = n - res
    if res < 0:
        print("-1")
    else:
        print(res)
# -*- coding: utf-8 -*-


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

print(n-sum(a) if n>=sum(a) else -1)
N,M=map(int,input().split())
A=list(map(int,input().split()))
print(-1 if N-sum(A)<0 else N-sum(A))
n,m=map(int,input().split())
l=list(map(int,input().split()))
s=sum(l)
d=n-s
print(max(-1,d))
import sys
input = sys.stdin.readline
def main():
    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:ans = -1
    print(ans)
if __name__ == "__main__":
    main()
n, m = list(map(int, input().split()))
a_list = list(map(int, input().split()))

homework_sum = sum(a_list)
if homework_sum > n:
    print(-1)
else:
    print(n - homework_sum)
N, M = map(int, input().split())
A = list(map(int, input().split()))
tmp = N - sum(A)

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

sumcost = 0
for a in aes:
  sumcost += a

if sumcost > n:
  print(-1)
else:
  print(n - sumcost)
# 初期入力
N,M = (int(x) for x in input().split())
A = list(map(int, input().split()))

#
day_syukudai = sum(A)
day_asobu = N - day_syukudai
if day_asobu <0:
    print(-1)
else:
    print(day_asobu)
n, m = map(int, input().split())
a = sum(list(map(int, input().split())))

if a > n:
    print(-1)
else :
    print(n - a)
from sys import stdin,stdout

for _ in range(1):
	#n,shift,ch=stdin.readline().split()
	days,ass=map(int,stdin.readline().split())
	s=sum(map(int,stdin.readline().split()))
	ans=-1 if days-s<0 else days-s
	stdout.write(str(ans)+'\n')
M,N = map(int,input().split())
A = list(map(int,input().split()))
ASUM = sum(A)
if M >= ASUM:
  print(M - ASUM)
else:
  print(-1)
N,M = map(int,input().split())
A = list(map(int,input().split()))

if N-sum(A)>=0:
  print(N-sum(A))
else:
  print(-1)
def resolve():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    ans = n - sum(a)
    print(ans if ans >= 0 else -1)


if __name__ == '__main__':
    resolve()
n, m = [int(i) for i in input().split()]
array = [int(i) for i in input().split()]

res = n - sum(array)
print(res if res >= 0 else -1)
n,m = map(int,input().split())
a = list(map(int, input().strip().split()))

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


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

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

if N-sum(A) < 0:
  print(-1)
else:
  print(N - sum(A))
n, m = map(int, input().split())
a = map(int, input().split())

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

ans = -1
total_days = sum(a)
if total_days <= n:
    ans = n - total_days
print(ans)
N,M = map(int,input().split(' '))
An = list(map(int,input().split(' ')))

if N - sum(An) >=0:
    print(N - sum(An))
else:
    print(-1)
n, m = map(int, input().split())
a = list(map(int, input().split()))
sum_a = sum(a)
if n >= sum_a:
    print(n-sum_a)
else:
    print(-1)
nums = input().split(' ')
vals = input().split(' ')
num2 = []
val2 = []

for i in range(len(nums)):
  num2.append(int(nums[i]))

for i in range(len(vals)):
  val2.append(int(vals[i]))

sum = 0

for val in val2:
  sum += val

if (sum > num2[0]):
  print("-1")

else:
  print(num2[0] - sum)
import sys
input = sys.stdin.readline
N,M = map(int,input().split())
A= list(map(int,input().split()))
a=0
for i in range(M):
 a+=A[i]
print(max(N-a,-1))
N, M = map(int, input().split())
Ai = list(map(int, input().split()))

if N - sum(Ai) >= 0:
    print(N - sum(Ai))
else:
    print(-1)
if __name__ == '__main__':
    nm = list(map(int, input().rstrip().split()))
    days = list(map(int, input().rstrip().split()))

    n = nm[0]
    total = sum(days)
    val = n - total

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

day = sum(A)

if day>N:
    print(-1)
else:
    print(N-day)
N,M = map(int,input().split())
work_list = [int(i) for i in input().split()]
print(N - sum(work_list)) if N - sum(work_list) >= 0 else print(-1)
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()
n,m = map(int,input().split())
a = [int(i) for i in input().split()]
sums = sum(a)
if n<sums:
    print(-1)
else:
    print(n-sums)
n,m = map(int,input().split())
A = list(map(int,input().split()))
sa = sum(A)
if n<sa:
  print(-1)
else:
  print(n-sa)
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)
N, M = map(int, input().split())
A = list(map(int, input().split()))  
 
sum=0
for i in range(M):
    sum=sum+A[i]
 
if N < sum:
    print(-1)
else:
    print(N-sum)
n, m = map(int, input().split())
a = list(map(int, input().split()))

print(max(n-sum(a), -1))
N,M=map(int, input().split())  
A = list(map(int, input().split()))
ans = N-sum(A)
if ans<0:
  print(-1)
else:
  print(ans)
n, m = map(int, input().split())
list = [int(x) for x in input().split()]
days = 0
for i in range(m):
  days += list[i]
if days > n:
  print(-1)
else:
  print(n - days)
#B
n,m = map(int,input().split())
a = list(map(int,input().split()))

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

result= N - sum(A)
if result < 0:
    result= -1
print(result)
n, m = map(int, input().split())
a = [int(i) for i in input().split()]
r = n - sum(a)
if r >= 0:
    print(r)
else:
    print(-1)
N, M = map(int, input().split())
*A, = map(int, input().split())

hwd = sum(A)
holiday = N - hwd
if holiday < 0:
    print(-1)
else:
    print(holiday)
n, m = map(int, input().split())
print(max(n - sum(list(map(int, input().split()))), -1))
N,M=(int(x) for x in input().split())
a = list(map(int, input().split()))  
ans=N-(sum(a))
if ans<0:
    ans=-1
    print(ans)
else:
    print(ans)
# -*- coding: utf-8 -*-
N, M = map(int, input().split())
A = list(map(int, input().split()))
B = sum(A)
if B > N:
    print(-1)
else:
    print(N-B)
def main():
    n, m = map(int, input().split())
    a = [int(x) for x in input().split()]
    sum_homework = sum(a)
    if sum_homework > n:
        print(-1)
    else:
        print(n-sum_homework)

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

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

totalwork = sum(works)

if totalwork > n:
    print(-1)
else:
    print(n-totalwork)
n,m = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
if n >= sum(a):
  print(n - sum(a))
else:
  print(-1)
n, m = map(int, input().split())
s = sum(map(int, input().split(" ")))
print(max(-1, n - s))
n,m=map(int,input().split())
a=list(map(int,input().split()))
if sum(a)>n:
    print(-1)
else:
    print(n-sum(a))
n, m = map(int, input().split())
a = list(map(int, input().split()))

x = n - sum(a)
print(x if x > 0 else -1)
N,M = map(int,input().split())
A = list(map(int,input().split()))
counter = 0
 
for i in range(M):
    counter += A[i]
    
print(N-counter)
n, m= map(int,input().split())
lista=list(map(int, input().split()))
eq= 0
eq2= 0

for i in range(m):
	eq+= lista[i]

eq2= n-eq
if eq2==0:
	print("0")
elif eq<0:
	print("-1")
else:
	print(eq2)
a,b=map(int,input().split())
c=input().split()
if sum(int(i) for i in c)>a:
    print(-1)
else:
    print(a-sum(int(i)) for i in c)
N, M = map(int, input().split())
A = list(map(int, input().split()))
print(N-(sum(A)))
d, n = list(map(int, input().split()))
work = list(map(int, input().split()))
sumwork = sum(work)
ans = d - sumwork
print(ans)
#!/usr/bin/env python3
n, m, *a = map(int, open(0).read().split())
d = n - sum(a)
print(d or "-1"* (d < 0))
n, m = map(int, input().split())
l=list(map(int, input().split()))
ans= n-sum(l)
if ans>0:
  print(ans)
else:
  print(-1)
N, M = map(int, input().split())
A = map(int, input().split())
if sum(A) > N:
  print(-1)
else:
  print(N - sum(A))
x, y = map(int,input().split())
arr = list(map(int, input().split()[:y]))
s = 0
for i in arr:
    s += i
re = x - s
if re > 0:
    print(re)
else:
    print(-1)
import sys

def main():

	S = 0
	N,M = map(int, input().split())
	Lists = list(map(int, input().split()))
	
	count = 0
	
	for List in Lists:
		S += List
	
	
	print(N-S)
	
if __name__ == "__main__":
    main()
n, m = map(int,input().split())

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

r = n-sum(a_list)
print(r if r > 0 else -1)
k=input()

list_a=k.split()

n=list_a[0]

int(n)

m=list_a[1]

int(m)

t=input()

list_b=t.split()

h=len(list_b)

list_s=[int(s) for s in list_b]

if m==h and sum(list_s)>=n:
  print(sum(list_s)-n)
elif m==h and sum(list_s)<n:
  print("-1")
N,M = map(int,input().split())
a = list(map(int, input().split()))
for i in range(M):
  N -= a[i]
print(N if N>1 else '-1')
days, num = map(int, input().split())
hwk = map(int, input().split())
if days >= sum(hwk):
  print(days - sum(hwk))
else:
  print(-1)
n, m = map(int, input().split())
A = list(map(int, input().split()))

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

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

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

for i in a:
    cnt+=i
   
if cnt<0:
    print(-1)
else:
    print(n-cnt)
n,m=(int(i) for i in input().split())
l=[int(i) for i in input().split()]
if(sum(l)>=m):
	print(n-sum(l))
else:
	print(-1)
n,m = list(map(int, input().split()))
a = list(map(int, input().split()))
day=n-sum(a)
if day>0:
    print(day)
else:
    print(-1)
from sys import stdin
N,M = stdin.readline().rstrip().split()
a_list = stdin.readline().rstrip().split()
N,M = int(N),int(M)
for a in a_list:
  N-=int(a)
if(N>0):
  print(N)
print(-1)
n,m = map(int, input().split())
a = map(int, input().split())
print(n-sum(a))
-1 if n < sum(a)  else n-sum(a)
n, m = map(int, input().split())
a = list(map(int, input().split()))

p = sum(a)

if n>p:
  print(n-p)
else:
  print(-1)
Summer_Vac,  HomeWork = map(int, input().split())
SyukuDai = input().rstrip().split(' ')
Ans = Summer_Vac

for i in range(HomeWork):
    Ans = Ans - int(SyukuDai[i])

if Ans > 0 :
    print(Ans)
else : 
    print(-1)
import math
from sys import *
inp=stdin.readline

zip=zip 
def linp(x):
    return list(map(int,x.split()))
def minp(x):
    return map(int,x.split())

n,m=minp(inp())
a=linp(inp())
an=sum(a)-n
if an>=0:
    print(an)
else:
    print("-1")
line_1 = input().split()
N = int(line_1[0])
line_2 = input().split()
M = list(map(int,line_2))
 
Ms = sum(M)
 
if N-Ms > 0 :
  print(N-Ms)
else:
  print(-1)
d, n = map(int, input().split())
a = map(int, input().split())
remaining = d - sum(a)
print(d if d >= 0 else -1)
n,m = map(int, input().split())
a = list(map(int, input().split()))
syukudai = 0

for i in range(m):
    syukudai += a[i]
    if syukudai < 0:
        print(-1)
        break
else:
    print(n-syukudai)
N, M = map(int,input().split())
#M 夏休み期間　M　宿題数
A = list(map(int, input().split()))
A_sum = 0
for i in range(0, M):
    A_sum += A[i]
    # A_sum 宿題全日数
x = N - A_sum
if x > N:
    print("-1")
else:
    print(x)
import math
N, M = map(int,input().split())
L = list(map(int,input().split()))
max(-1,N-sum(L))
#cording:utf-8

import math

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

s = [int(M) for M in input().split()]
print(N,M)
print(s)

sum(s)

Pr=N-sum(s)
if Pr<= N:
    print(Pr)

else:
    print(-1)
N, M = map(int, input().split())

A = [int(i) for i in range(M)]

B = sum(A)

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

else:
  print('-1')
import numpy as np
a, b = list(map(int, input().split()))
s = np.sum(list(map(int, input().split())))
print(np.max(a-s, -1))
N,M = map(int,input().split())
A = sum(map(int,input().split()))

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

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

print(sum)
ans = N - sum

print(ans)
a = input()
b = input()
temp = a.split()
n = int(temp[0])
n -= 1
m = int(temp[1])



ai = b.split()

sum = 0

for i in range(m):
    sum += int(ai[i])

temp1 = n - sum
if n <= 0:
    print(-1)
else:
    print(temp1)
from sys import stdin
N,M = stdin.readline().rstrip().split()
a_list = stdin.readline().rstrip().split()
N,M = int(N),int(M)
for a in a_list:
  N-=int(a)
if(N>=0):
  print(N)
print('-1')
import numpy as np
N,M=map(int,input().split())
p=list(map(int,input().split()))
if np.sum(p)>M:
  print(-1)
else:
  print(N-np.sum(p))
N,M = map(int,input().split())
A=list(map(int,input().split()))

if N-sum(A) >0:
    print(N-sum(A))
else:
    print(-1)
def solve():
  n, m = map(int, input().split())
  a = list(map(int, input().split()))
  hoge = max(0, n-sum(a))
  if hoge > 0:
    print(a)
  else:
    print(-1)
  return 0
 
if __name__ == "__main__":
  solve()
def q2():
    N, M = (int(i) for i in input().split())
    A = [int(i) for i in input().split()]
    sum_A = sum(A)
    if N > sum_A:
        ans = N - sum_A
    else:
        ans = 0
    print(ans)


if __name__ == '__main__':
    q2()
n, m = map(int, input().split())
aa = list(map(int, input().split()))
print(n - sum(aa))
import numpy as np

A=list(input().split())

print(A, A[0], int(A[0]))

N=int(A[0])
M=int(A[1])

B=list(input().split())

k=0

for i in range(len(B)):
    k+=int(B[i])

print(N-k if N-k>=0 else -1)
import sys

n, m = map(int, sys.stdin.readline().split())

line = sys.stdin.readline().split()
nums = list(map(int, line))

print(n - sum(nums))
N, M = map(int, input().split())
A = list(map(int, input().split()))
ans = N - sum(A) if N > sum(A) else -1
print(ans)
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")
# abc136

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

ans = n - sum(days)
if ans < 0:
    ans = 0
print(ans)
N,M = map(int, input().split())
A = list(map(int, input().split()))
task = 0
for i in range(M):
    task += A[i]
answer = task
if answer > 0:
    print(N - task)
else:
    print(-1)
N , M = input().split(" ")
A = input()
Ai = A.split(" ")
tm = 0
for i in Ai:
    tm = tm + int(i)
print(int(N)-tm)
n,m = map(int, input().split())

a = [ int(x) for x in input().split()]
print(n-sum(a))
n, _ = map(int, input().split())
nums = list(map(int, input().split()))
total = sum(nums)
ans = n - total
print(ans)
n,m = map(int,input().split())
grid = []
a = list(map(int, input().strip().split()))

res = n - sum(a)
if(res <= 0):
  res = -1
print(res)
s = input().split(" ")
N = int(s[0])
M = s[1]
s = input().split(" ")
A = []
sum = 0
for w in s:
    A.append(int(w))
    sum += int(w)

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

check = n - sum(list(a))
if check > 0:
    print(check)
else:
    print(-1)
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n,m=INTM()
    a=LIST()
    print(n-sum(a))
if __name__ == '__main__':
    do()
x = input().split()
c  =int(x[0])
v = input().split()
f = 0
for i in v:
  f += int(i)
m = c - f
print(m)
n, m = map(int, input().split())
a = list(map(int, input().split()))
if n - sum(a) > 0:
    print(n - sum(a))
else:
    print(-1)
n = input().split()
m = input().split()
n = [int(i) for i in n]
m = [int(i) for i in m]
a = n[0]
for i in m:
  a -= i
  if a<0:
    print("-1")
  else:
    print(a)