peterverebics/CodeNet_Python_118 huggingface dataset:
N,M = map(int, input().split())
A_sum = sum(map(int, input().split()))
total = N-A_sum
print(-1 if total < 0 else total)
n,m = map(int,input().split())
ls=list(map(int,input().split()))

s=sum(ls)
if n>=s:
    print(n-s)
else:
    print(-1)
input_line = input().split(' ')
input_line = list(map(int, input_line))
input_assign = input().split(' ')
input_assign = list(map(int, input_assign))

len = input_line[0] - sum(input_assign)
if len < 0:
  print(-1)
else:
  print(len)
N, M = map(int, input().split())
A = list(map(int, input().split()))

if sum(A) > N:
  print(-1)
else:
  print(N - sum(A))
params0 = list(map(lambda x: int(x), input().split(' ')))
params1 = list(map(lambda x: int(x), input().split(' ')))

days = params0[0]
required = sum(params1)
if days >= required:
    print(days - required)
else:
    print(-1)
n,m=map(int, input().split())
a=list(map(int, input().split()))
total=sum(a)
if total > n:
    print(-1)
else:
    print(n-total)
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,m = inpl()
a = inpl()
su = sum(a)
if n >= su:
    print(n-su)
else:
    print(-1)
N, M = map(int, input().split())
As = list(map(int, input().split()))
print(max(-1, N - sum(As)))
N,M = map(int,input().split())
A = list(map(int,input().split()))
A_sum = sum(A)
if A_sum > N:
  print(-1)
else:
  print(N-A_sum)
n, m = map(int, input().split())
a = list(map(int, input().split()))

s = 0
for i in range(m):
    s += a[i]
if n >= s:
    print(n - s)
else:
    print('-1')
import sys
readline = sys.stdin.buffer.readline
n, m = map(int, readline().split())
a = map(int, readline().split())
print(h if (h := n - sum(a)) >= 0 else -1)
import sys
import math

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

s = N - A
if s < 0:
    print(-1)
else:
    print(s)
import numpy as np

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

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

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

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

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

ans=-1
SUM=0
for i in range(M):
    SUM += A[i]
if SUM <= N:
    ans = N - SUM

print(ans)
#!/usr/bin/env python

from sys import stdin, stderr

def main():
   N, M = map(int, stdin.readline().split())
   A = map(int, stdin.readline().split())

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

   return 0

if __name__ == '__main__': main()
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())
a = list(map(int, input().split()))
sum_of_a = sum(a)
leisure = n - sum_of_a
ans = 0
if leisure >= 0:
  ans = leisure
else:
  ans = -1
print(ans)
N,M=list(map(int, input().split()))
A=list(map(int, input().split()))
b=sum(A)
if b>N:
    print(-1)
else:
    print(N-b)
# -*- coding: utf-8 -*-

A,B=(int(x) for x in input().split())

days_l = [int(x) for x in input().split()]
hw = sum(days_l)

if A >= hw:
    print(A - hw)
else:
    print('-1')
n,m=map(int,raw_input().split())
a=map(int,raw_input().split())
print n-sum(a) if sum(a)<=n else\
      -1
N, M = map(int, input().split())
A = list(map(int, input().split()))
if sum(A) > N:
  print(-1)
else:
  print(N - sum(A))
input_line = input()
Line = input_line.split()
Line = [int(s) for s in Line]

N,M = Line[0],Line[1]

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

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

p = sum(a)

print(n - p if n - p >= 0 else -1)
n , m = map(int,input().split())
a = list(map(int,input().split()))
if n >= sum(a):
    print(n-sum(a))
else:
    print(-1)
N, M = map(int, input().split())
A = list(map(int, input().split()))
if (res := N - sum(A)) < 0:
    print(-1)
else:
    print(res)
days,works = input().strip().split()
days,works = [int(days),int(works)]
#
array = list(map(int,input().strip().split()))
#
sum = 0
for i in range(works):
    sum += array[i]
days -= sum
if days >= 0:
    print(days)
else:
    print("-1")
n,m=map(int,input().split())
l=list(map(int,input().split()))
if n - sum(l) >-1:
    print(n - sum(l))
else:
    print(-1)
n, m = map(int, input().split())
a = map(int, input().split())
sum_a = sum(a)
if n < sum_a:
    print(-1)
else:
    print(n - sum_a)
N, M=map(int,input().split())
a = list(map(int,input().split()))
a=sum(a)
if(N-a>=0):
    print(N-a)
else:
    print(-1)
n,m = map(int,input().split())
a = map(int,input().split())

date = sum(a)
if n-date < 0:
    print(-1)
else:
    print(n-date)
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np

def main():
    N, M, *A = map(int, read().split())
    ans = sum(A)
    if ans > N:
        ans = -1
    else:
        ans = N - ans
    print(ans)
    return

if __name__ == '__main__':
    main()
def resolve():
    n,m = map(int, input().split())
    a = list(map(int, input().split()))
    if sum(a) > n:
        print(-1)
        return
    print(n - sum(a))

if __name__ == '__main__':
    resolve()
n,m = (int(num) for num in input().split())
a = [int(num) for num in input().split()]
if n < sum(a):
    print("-1")
else:
    print(n - sum(a))
x,m = map(int, input().split())
ds = list(map(int, input().split()))
if(sum(ds) > x):
    print(-1)
else:
    print(x-sum(ds))
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 = max(-1, n - sum(a))
print(ans)
N, M = map(int, input().split())

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

x = sum(A)

if N >= x:
  print(str(N-x))
else:
  print(-1)
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)
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()))

days = sum(A)
holidays = N - days

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

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

sumDays = sum(A)

if sumDays <= N:
  print(N-sumDays)
else:
  print('-1')
n,m = map(int,input().split())
li = list(map(int,input().split()))

s = sum(li)
if s>n:
    print('-1')
else:
    print(n-s)
from sys import stdin
input = stdin.readline

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

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

d = 0
d = N - sum(l)

if (d < 0 ):
    print("-1")
else:
    print(d)
n,m = map(int,input().split())
li = list(map(int,input().split()))

print(max(-1,n-sum(li)))
N, M = map(int, input().split())
A = list(map(int, input().split()))
if N - sum(A) >= 0:
    print(N - sum(A))
else:
    print(-1)
num=input().split()
N=int(num[0])
M=int(num[1])
list=input().split()
list= [int(i) for i in list]
D=sum(list)
if N>=D:
    print(N-D)
else:
    print(-1)
n, m = map(int, input().split())
a = list(map(int, input().split()))

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

sa = sum(aaa)
if sa > n:
    print(-1)
else:
    print(n - sa)
n,m,*a=map(int,open(0).read().split())
if (k:=n-sum(a))<0:print(-1)
else:print(k)
n,m = map(int, input().split())
a = list(map(int, input().split()))
ans = n-sum(a)
if ans >= 0:
  print(ans)
else:
  print(-1)
N, M = map(int, input().split())
homework_days = [int(num) for num in input().split()]

diff = N - sum(homework_days)
print(diff) if diff >= 0 else print(-1)
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)
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")
N,M = map(int,input().split())
A = list(map(int,input().split()))
X = sum(A)
if(N - X < 0):
  print("-1")
else:
  print(str(N-X))
n,m=map(int,input().split())
lists=list(map(int,input().split()))
if n>=sum(lists):
    print(n-sum(lists))
else:
    print(-1)
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)
n,m,*a=map(int,open(0).read().split())
s=sum(a)
print(max(-1,n-s))
import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N, M = map(int, readline().split())
A = list(map(int, readline().split()))
sum_A = sum(A)

if sum_A > N:
    print(-1)
else:
    print(N - sum_A)
line = [int(x) for x in input().split()]

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

t = sum(vals)

if t > line[0]:
  print(-1)
else:
  print(line[0] - t)
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()))
t = sum(a)
print(max((N - t),-1))
def main():
  b = list(map(int,input().split()))
  n = b[0]
  m = b[1]
  a = list(map(int,input().split()))
  for i in a:
    n -= i
  if n < 0:
    print('-1')
  else:
    print(n)

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

if N < sum(A):
  print(-1)
  exit()
print(N - sum(A))
n,m=map(int,input().split())
hoge=list(map(int,input().split()))

if(sum(hoge)>n):
  print(-1)
else:
  print(n-sum(hoge))
NM = input().split()
A = input().split()
N = int(NM[0])
M = int(NM[1])
a = 0
for i in range(M):
    a+=int(A[i])
if a>N:
    print(-1)
else:
    print(N-a)
N, M = map(int, input().split())
A = list(map(int, input().split()))
sum = sum(A)
if sum > N:
    ans = -1
else:
    ans = N - sum
print(ans)
N=int(input().split()[0])
lst=list(map(int,input().split()))
s=N-sum(lst)
if s<0:
  print(-1)
else:
  print(s)
N, M=map(int, input().split())
A=list(map(int, input().split()))
tmp=N-sum(A)
if tmp>=0:
    print(tmp)
else:
    print(-1)
n, m = 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)
N, M = map(int, input().split())
A = list(map(int, input().split()))

a = sum(A)

if a > N:
    print(-1)
else:
    print(N - a)
N , M = input().split(" ")
Ai = input()
A = Ai.split(" ")
tm = 0
for i in A:
    tm = tm + int(i)
max = int(N)-tm
if max >= 0:
    print(int(N)-tm)
else :
    print("-1")
n,m = map(int,input().split())

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

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

if ans < 0:
    print(-1)
else:
    print(ans)
# https://atcoder.jp/contests/abc163/tasks/abc163_b

n, m = map(int, input().split())
a = list(map(int, input().split()))
day = sum(a)
if day <= n:
    print(n-day)
else:
    print('-1')
N,M = map(int,input().split())
A = list(map(int,input().split()))
sumA = sum(A)
if N-sumA < 0:
  print(-1)
else:
  print(N-sumA)
n,m = map(int,input().split())
a = list(map(int,input().split()))
s = sum(a)
if n < s:
    print(-1)
else:
    print(n-s)
n, m = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]

work_days = sum(a)

if n - work_days < 0:
    print(-1)
else:
    print(n - work_days)
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))
import sys
input = sys.stdin.readline
def print_ans(N, M, ar):
    """Test Case
    >>> print_ans(41, 2, [5, 6])
    30
    >>> print_ans(10, 2, [5, 6])
    -1
    >>> print_ans(11, 2, [5, 6])
    0
    """
    tmp = N -sum(ar)
    if(tmp >= 0):
        print(tmp)
    else:
        print("-1")



if __name__ == '__main__':
    N, M = map(int, input().rstrip().split())
    ar = list(map(int, input().rstrip().split()))
    print_ans(N, M, ar)
import numpy as np

NM=np.array(input().split(),dtype=np.int32)
N=NM[0]
M=NM[1]

A=np.array(input().split(),dtype=np.int32)

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

if(sum(c)-a >0):
    print("-1")
else:
    print(a-sum(c))
data = input().split()
 
n = int(data[0])
m = int(data[1])
 
data = input().split()
 
homework = [int(s) for s in data]
day = 0
 
for i in homework:
  day += i

ans = n - day
if ans < 0:
  ans = -1

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

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

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

print(ans)
N, M = input().split()
A = input().split()

homework_days = 0
for day in A:
  homework_days += int(day)
  
if homework_days > int(N):
  print(-1)
else:
  print(int(N) - homework_days)
N, M = map(int, input().split())
A = list(map(int, input().split()))
print(N-sum(A) if N-sum(A) >= 0 else -1)
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n,m = inm()
a = inl()
sm = sum(a)
x = n - sm
if x>=0:
    print(x)
else:
    print(-1)
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())
As=[int(i) for i in input().split()]

ans=N-sum(As)

if ans<0:
    print(-1)
else:
    print(ans)
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()))
print(max(n-sum(a),-1))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
N=a[0]
M=a[1]
sum_day = 0
for i in range(M):
    sum_day += b[i]
ans = N - sum_day
if ans < 0:
    print(-1)
else:
    print(ans)
N, M = map(int, input().split())
A = map(int, input().split())
A_sum = sum(A)

if (N - A_sum) >= 0:
    print(N - A_sum)
else:
    print(-1)
N,M = map(int,input().split())
A = list(map(int,input().split()))
count = 0
for i in range(0,M):
	count += A[i]
print(N-count if N-count >= 0 else "-1")
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()
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)
#B
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())
l = list(map(int, input().split()))
S = sum(l)
if N - S < 0:
    print(-1)
else:
    print(N - S)
N,M=map(int,input().split())
list=list(map(int,input().split()))
n=0
while n<M:
  N = N-list[n]
  n=n+1

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

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

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

s = sum(tasks)

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

ans=n-sum(a_list)

if ans<0:
    print(-1)
else:
    print(ans)
import numpy as np
N, M = map(int, input().split())
A_l = np.array(list(map(int, input().split()))).sum()
if N>=A_l:
    print(N-A_l)
else:
    print(-1)
import math
import queue

def readInt():
	return int(input())

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

def readChars():
	return input().split()


x = readInts()
n = x[0]
m = x[1]
a = readInts()

x = sum(a)

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

if N - cnt >= 0:
    print(N-cnt)
else:
    print(-1)
x = input()
space_index1 = x.index(' ')

n = int(x[0:space_index1])
m = int(x[space_index1+1:])

x = input()
tmp_space_idx = 0
Ajs = x.split(' ')

sum_ = 0
for aj in Ajs:
  sum_ += int(aj)

if sum_ <= n:
  print(n - sum_)
else:
  print(-1)
n,m = map(int,input().split())
A = list(map(int,input().split()))
h = sum(A)
ans = n-h
print(max(ans,-1))
n, m = map(int, input().split())
ans = n - sum(list(map(int, input().split())))
print(ans if ans >= 0 else -1)
n, m = map(int, input().split())
al = list(map(int, input().split()))

a = sum(al)

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

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

homework_day = 0
for i in range(M):
    homework_day += homework[i]

if homework_day <= N :
    print(N - homework_day)
else:
    print("-1")
n,m = 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)
mn = input().split()

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

ms = input().split()

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

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

else:
    print(n)
Day = list(map(int,input().split()))

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

for i in range(Day[1]):
  Day[0] = Day[0] - work[i]
  
if(Day[0] >= 0):
  print(Day[0])
elif(Day[0] < 0):
  print("-1")
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)
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()))

print(n-sum(a) if n-sum(a)>=0 else "-1")
import numpy as np
n,m=map(int,input().split())

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

s=np.sum(a)

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

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

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

if n<a:
    print(-1)
else:
    print(n-a)
input1 = input().split(" ")
n = int(input1[0])
m = int(input1[1])
assignlist = input().split(" ")
con1 = n>=1 and n<=1000000
con2 = m>=1 and m<=1000000
numassign = 0
holiday = 0
if con1 == True and con2 == True:
    for i in assignlist:
        i = int(i)
        if i >= 1 and i <= 10000:
            numassign = numassign + i
        else:
            numassign = numassign
    holiday = n - numassign
    if holiday >= 0:
        print(holiday)
    else:
        print(-1)
else:
    print()
N, M = input().split()
x = list(map(int, input().split()))
if int(N) - sum(x) < 0:
    print('-1')
else:
    print(int(N) - sum(x))
N,K = map(int,input().split())
a = list(map(int,input().split()))

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

T = sum(List)

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

t = 0

for i in A:
    t += i

a = N - t

if a<0:
    print("-1")
else:
    print(a)
import numpy as np

N,M = input().split()
N = int(N)
A = np.array(input().split()).astype(int)

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

hw = sum(a)

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


answer = n - sum(a)

if answer < 0:
    print("-1")
else:
    print(answer)
N,M=map(int,input().split())
A=list(map(int,input().split()))
ALL=sum(A)
if(ALL<=N):
    print(N-ALL)
else:
    print(-1)
n, m = map(int, input().split())
a = list(map(int, input().split()))
print(max(n-sum(a), -1))
n, m = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

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