peterverebics/CodeNet_Python_118 huggingface dataset:
N,M = map(int, input().split())
A = map(int, input().split())
if N >= sum(A):
    print((N)-(sum(A)))
else:
    print("-1")
N, M = map(int, input().split())
task = []
for i in range(1, M + 1):
    task.append("A_" + str(i))

task = map(int, input().split())
task_total = sum(task)

if task_total <= N:
    print(N - task_total)
n,m=map(int,input().split())
a=list(map(int,input().split()))

if(sum(a)<n):
	print(-1)
else:
	val=n-sum(a)
	print(val)
def solution():
    return 1

def main():
    N , M = list(map(int , input().split()))
    assignments = list(map(int , input().split()))
    for a in assignments:
        N -= a 
    print(N)       
   
if __name__ == "__main__":
    main()
def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    count = 0
    for i in a:
        count += i
    print(n - count)


if __name__ == "__main__":
    main()
import sys
import numpy as np
N,M = map(int,input().split())
homeworks = np.asarray(list(map(int,input().split())))

for homework in homeworks:
    if N >= 0 :
        N -= homework 
    else:
        print('-1')
        sys.exit()

print(N)
def solve():
  n, m = map(int, input().split())
  a = list(map(int, input().split()))
  print(max(0, n-sum(a)))
  return 0
 
if __name__ == "__main__":
  solve()
[n, m] = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
print(n - sum(a))
n,m = map(int, input().split())
a = map(int, input().split())
print(n-sum(a))
n,m= map(int, input().split())
a= list(map(int, input().split()))
if m == len(a):
    c= n-sum(a)
print(c)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


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

    r = n - sum(a_list)
    print(r)


if __name__ == '__main__':
    main()
n,m=map(int,input().split())
l=list(map(int,input().split()))
print(n-sum(l))
n,m=map(int,input().split())
L=list(map(int,input().split()))
if sum(L)<n:
  print(n-sum(L))
else:
  print(-1)
#In[]:
day, cnt = map(int, input().split())
homework = list(map(int,input().split()))

for i in homework:
    if day < 0:
        print(-1)
        break
    day -= i
print(day)
day, cnt = map(int, input().split())
homework = list(map(int,input().split()))

for i in homework:
    day -= i
    
    if day < 0:
        print(-1)
        break
print(day)
#!/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()))

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

print (n-sum(l))
def solution():
    return 1

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

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

ans1 = sum(A)
ans2 = N - ans1

if N < ans2:
    print(int("-1"))
else:
    print(ans2)
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 > x:
    print(-1)
elif re == x:
    print(0)
else:
    print(re)
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read
 
 
n,m = map(int,input().split())

a = list(map(int, input().split()))  # n個の文字列がリストに格納される

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()))
cnt=sum(a)
print(N-cnt)
print(sum([int(r) for r in input().split(" ")])-sum([int(r) for r in input().split(" ")]))
n, m = map(int, input().split())
a = input().split() 

a = sum(int(i) for i in a)

asobi = n -a
if asobi > 0:
  print(asobi)
else:
  print(-1)
def main(N, M, A):
    memo = N - sum(A)
    if memo >= 0:
        return memo
    else:
        return memo

if __name__ == '__main__':
    N, M = list(map(int, input().split()))
    A = list(map(int, input().split()))
    # N = 314
    # M = 15
    # A = list(map(int, "9 26 5 35 8 9 79 3 23 8 46 2 6 43 3".split()))
    # print(N, M, A)
    print(main(N, M, A))
n, m = map(int, input().split())
a = list(map(int, input().split()))

if sum(a) < n:
    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(-1)
  else:
    print(a)
  return 0
 
if __name__ == "__main__":
  solve()
N,M = map(int,input().split())
homework = list(map(int,input().split()))

hell = sum(homework)

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

total = sum(a)
if total < n:
    print(total)
else:
    print(-1)
n, m= map(int,input().split())
lista=[]
eq2=0
eq=0
#lista= list(map(int,input().split()))

for x in input().split():
	x= int(x)
	lista.append(x)
	eq2+=x

eq= n-eq2
if eq<=n:
	print(eq)
else:
	print('-1')
n, m = map(int, input().split())
a = list(map(int, input().split()))
study_sum = sum(a)
tem_ans = n - study_sum
print(tem_ans) if tem_ans > 0 else print(-1)
LI = lambda: list(map(int,input().split()))
MI = lambda: map(int,input().split())
yes = lambda: print("YES")
no = lambda: print("NO")
I = lambda: list(input())
J = lambda x: "".join(x)
II = lambda: int(input())
SI = lambda: input()
#---khan17---template
n,m = MI()
a = LI()
c = n-sum(a)
print(c if c>0 else -1)
N, M = map(int, input().split())
A = A = map(int, input().split())
 
if(sum(A) == N):
  print('0')
elif(sum(A) > N):
  print(N - sum(A))
else:
  print('-1')
# 夏休みN日
# 宿題M
# i番目の宿題をやるにはAi日間かかります。

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

S = 0

for i in range(M):
  S += A[i]
  
print(N - S)
N, M = map(int,input().split())
l = list(map(int,input().split()))
su = sum(l) + 1
if N < su:
    print(-1)
else:
    print(N - su)
N, M = map(int, input().split())
A = map(int, input().split())
 
if(sum(A) == N):
  print('0')
elif(sum(A) < N):
  print(N - sum(A))
else:
  print('-1')
#ABC163B
n,m = map(int,input().split())
a = list(map(int,input().split()))
print(-1 if sum(a) >= n else n-sum(a))
N,M=map(int,input().split())
A=[int(x) for x in input().split()]

if sum(A)==N:
  print(-1)
else:
  for i in A:
    N=N-i
  print(N)
n, m = map(int, input().split())
a = list(map(int, input().split()))

sum = 0

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

homework=0

for a in A:
    homework+=a

if N>homework:
    print(N-homework)
else:
    print(-1)
N,M = map(int,input().split())
A = list(map(int,input().split()))
x = sum(A)
print(N-x)
str = input().split()
line = input().split()

num = 0
for i in range(int(str[1])):
    num = num + int(line[i])

if (int(str[0]) - num)  > 0:
    print(int(str[0]) - num)
else:
    print(-1)
N,M=map(int,input().split())
task=list(map(int,input().split()))
print(N-sum(task))
N, M = map(int, input().split())
A = input().split()
A_int = [int(n) for n in A]

rest = sum(A_int)
if N - rest >= 0:
  print(rest)
else:
  print(-1)
N, M = map(int,input().split())
li = list(map(int,input().split()))	
ans = 0
for i in range(M):
  ans += li[i]
  
answer = N-ans
print(answer)
n,m=map(int,input().split())
a=sum(list(map(int,input().split())))
if n-a<=0:
    print(n-a)
else:
    print(-1)
A,B=map(int,input().split())
Lis=list(map(int,input().split()))

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

else:
    print(-1)
#!/usr/bin/env python3

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

sum_a = sum(a)
if sum_a > n:
    print(-1)
else:
    print(sum_a-n)
N, M = map(int, input().split())
A = list(map(int, input().split())) 
homework = sum(A)
playday = N - homework
if playday > 0:
  print(playday)
else:
  print(-1)
N, M = map(int, input().split())
A = list(map(int, input().split()))
SumA = sum(A)
if 1 <= N <= 10^6 and 1 <= M <= 10^4 and 1 <= SumA <= 10^4:
  R = N - SumA
  print(R)
n, m = [int(x) for x in input().split()]
l = list(map(int, input().split()))
study = 0
for i in range(m):
    study += l[i]
print(n-study)
N,M=map(int ,input().split())
A=input().split()

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

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

playdays=N-total
if playdays>0:
    print(playdays)
else:
    print(-1)
N, M = map(int, input().split())
A = list(map(int, input().split()))
print(N-sum(A) if N-sum(A)>0 else -1)
# N: 夏休みの日数，M: 宿題の数
N, M = list(map(int, input().split()))
# i番目の宿題にかかる日数
A = list(map(int, input().split()))

free_days = N - sum(A)

if (free_days > 0):
    print(free_days)
else :
    print('-1')
N,K=map(int,input().split())
s=list(map(int,input().split()))
S=0
for i in range(K):
    S+=s[i]
print (N-S)
N=[int(x) for x in input().split()]
A=[int(x) for x in input().split()]
sum=0
for a in range(N[1]):
    sum=sum+A[a]
if sum>=0:
   print(N[0]-sum)
else:
   print(-1)
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)
n,m = (int(x) for x in input().split())
take = list(map(int, input().split()))
for per in take:
    n -= per

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

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

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

if n > sum(l):
  print(n-sum(l))
else:
  print(-1)
n,m=map(int,input().split(" "))
a=list(map(int,input().split(" ")))
print(min(-1, n-sum(a)))
N,M = map(int,input().split())
n = list(map(int,input().split()))
asobi = N - sum(n) 
print(asobi)
n,m = map(int,input().split())
a = list(map(int,input().split()))
ans = n - sum(a)
if ans <= n:
    print(ans)
else:
    print(-1)
t=list(map(int,input().split()))		
s=list(map(int,input().split()))		
 
temp = 0
for i in s:
  temp += i

# print(temp)
if(t[0]-temp>=0):
  print(s[0]-temp)
else:
  print(-1)
N,M=map(int,input().split())
A=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()))
assert len(A) == M
# M個の宿題, それぞれAi日かかる
yasumi = N - sum(A)
if yasumi > 0:
  print(yasumi)
else:
  print(-1)
N, M = map(int, input().split())
A = [int(i) for i in input().split()]

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


sumA = sum(A)

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

else:
    print("-1")
N,M = map(int, input().split())
a = list(map(int, input().split()))
N -= sum(a)
if N > 0:
  print(N)
else:
  print(-1)
NM = str(input()).split()
work = str(input()).split()
SV = int(NM[0])
for i in range(len(work)):
	SV -= int(work[i])

print(SV)
a=[int(x) for x in input().split()]
b=[int(x) for x in input().split()]
c=sum(b)

if(c > a[0]):
    print(-1)
else:
    print(c - a[0])
n, m = map(int, input().split())
A = list(map(int, input().split()))

if sum(A) < 0:
    print("-1")
else:
    print(n - sum(A))
x, y = map(int,input().split())
arr = list(map(int, input().split()))
s = 0
for i in arr:
    s += i
print(x-s)
n,m=map(int,input().split())

a=[]
a=list(input().split())


for k in range(m):

    n=n-int(a[k])

    if n < 0:
        break

print(n)
#先にAの合計値を出してもよい
N, M = map(int, input().split())
A = list(map(int, input().split()))
suma = sum(A)
if N-suma>=0:
    print(N)
else:
    print(-1)
a1, b = [int(s) for s in input().split(" ")]
a = [int(h) for h in input().split()]
c=sum(a)
if a1-c> 0:
    print(a1-c)
else:
    print(-1)
n,m=(int(x) for x in input().split())
a=[int(x) for x in input().split()]
s=sum(a)
if (s<n):
     ans=n-s
else:
    ans=-1
    
print(ans)
a,b  = list(map(int,input().split()))
print(a - sum(list(map(int,input().split()))))
N , M  = input().split()
A   = input().split()
N , M  = int(N) , int(M)
for i in range(M):
    A[i] = int(A[i])
print(A , M , N)
for i in range(M):
    N -= A[i]
if N < -1:
    N = -1
print(N)
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 = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
wa = 0
for i in range(M):
    wa += a[i]
print(N-wa)
#スペース区切りの整数の入力
N,M = map(int, input().split())
#スペース区切りの整数の入力リスト
A_list = list(map(int, input().split()))

sum_ = 0
for i in range(len(A_list)):
  sum_ = sum_ + A_list[i]
  
ans = N - sum_

print(ans)
n, m = map(int, input().split())
a = [int(i) for i in input().split()]
x = n - sum(a)
print(x) if x else print(-1)
n,m=map(int, input().split(' '))
a = list(map(int, input().split()))
print(n-sum(a))
n, m= map(int,input().split())
lista=[]
sum=0
eq=0
#lista= list(map(int,input().split()))

for x in input().split():
	x= int(x)
	lista.append(x)
	sum+=x

eq= n-sum
if eq<<n:
	print(eq)
elif eq==0:
	print('0')
else:
	print('-1')
arr=list(map(int,input().rstrip().split()))
N=arr[0]
M=arr[1]
arr=list(map(int,input().rstrip().split()))
summ=0
for i in range(M) :
    summ+=arr[i]
if summ>=N :
    print(-1)
else :
    print(N-summ)
a=list(map(int,input().split()))
b=list(map(int,input().split()))
if sum(b)>a[0]:
  print(-1)
elif sum(b)==a[0]:
  print(1)
else:
  print(a[0]-sum(b))
N, M = map(int, input().split())
A = map(int, input().split())

B = sum(A)

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

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

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

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

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

print("{}".format(N - sum(A)))
n, m = map(int, input().split())
a = list(map(int, input().split()))

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

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

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

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

if n > 0:
    print(n)
else:
    print(-1)
n, m = map(int, input().split())
print(n - sum(list(map(int, input().split()))))
n,m= map(int, input().split())
a= list(map(int, input().split()))
if m == len(a):
    c= n-sum(a)
    print(c)
else:
    pass
N,M=map(int,input().split())
A=list(map(int,input().split()))
print(N-sum(A) if N-sum(A) >0 else -1)
N,M=map(int,input().split())
A=list(map(int,input().split()))
ans=N
for i in A:
  if ans<0:
    print("-1")
    exit()
  else:
    ans-=i
print(ans)
n, m = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
s = sum(a)
print(n - s)
n,m = map(int,input().split())
a = list(map(int,input().split()))
sum = 314
for i in a:
  sum -= i
if sum < 0:
  print(-1)
else:
  print(sum)
n, m= map(int,input().split())
lista=list(map(int, input().split()))
eq2=0
eq=0
#lista= list(map(int,input().split()))

eq2= sum(lista)
eq= n-eq2
if eq<=n:
	print(eq)
else:
	print('-1')
n,m= map(int, input().split())
a = list(map(int, input().split()))
if m != len(a):
    pass
else:
    print(n-sum(a))
# -*- coding: utf-8 -*-
# 整数の入力
# a = int(input())
# スペース区切りの整数の入力
# 文字列の入力
# s = input()
# 出力
# print("{} {}".format(a+b+c, s))
# b, c = map(int, input().split())

N, M = map(int, input().split())
array = list(map(int, input().strip().split()))
for value in array :
  N -= value
print(N)
n, m = map(int, input().split())
a = list(map(int, input().split()))
b = sum(a)
print(n-b)
n,m = (int(x) for x in input().split())
a = (int(x) for x in input().split())
for node in a:
	n = n - node
print(n if n > 0 else -1)
n,m=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())
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()))
rest = n - sum(a)
if rest <= 0:
    print(-1)
else:
    print(rest)
d,h=map(int,input().split())
da=list(map(int,input().split()))
ans = d - sum(da)
if ans > 0:print(ans)
else:print(-1)
n, m = map(int, input().split())
a = map(int, input().split())

print(n-sum(a))
N, M = map(int, input().split())
A = list(map(int, input().split()))

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

a = 0
for i in range(n):
    a += a_list[i]

print(k - a)
x, y = map(int,input().split())
arr = list(map(int, input().split()[:y]))
s = 0
for i in arr:
    s += i
print(x-s)
n, m=map(int, input().split())
a = list(map(int, input().split()))
ans =  n - sum(a)
if 0 < ans:
    print(ans)
else:
    print('-1')
N,M = map(int, input().split())
A = list(map(int, input().split()))
N -= sum(A)
if N > 0:
  print(N)
else:
  print(-1)
n,m=map(int,input().split())
hoge=list(map(int,input().split()))

if(sum(hoge)>=n):
  print(-1)
else:
  print(n-sum(hoge))
n,m = map(int,input().split())
a = list(map(int,input().split()))
if sum(a) < n:
    print(n - sum(a))
else:
    print(-1)
if __name__ == "__main__":
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    ret = -1
    A_sum = sum(A)
    if not (A_sum < 0):
        ret = N - A_sum
    print(int(ret))
day, assignment = map(int, input().split())
assignment_time = map(int, input().split())
if sum(assignment_time) > day:
    print(-1)
else:
    print(day - sum(assignment_time))
N, M = map(int, input().strip().split())
A = list(map(int, input().strip().split()))

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

if (sum <= 0):
    print("-1")
else:
    print(N - sum)
N,b=map(int,input().split())
a_list=list(map(int,input().split()))

s=0

for a in a_list:
    s+=a


if N-s <0:
    ans=0
else:
    ans=N-s

print(ans)
a,b = map(int,input().split())
c = [int(x) for x in input().split()]
print(c,len(c))
csum = 0
for i in range(len(c)):
    csum = csum + c[i]
if a>=csum:
    print(a-csum)
else:
    print(-1)
n, m = map(int,input().split())
a = list(map(int,input().split()))

a_sum = sum(a)
ans = n-a_sum

if n > m and ans > 0:
    print(ans)
else:
    print(-1)
N, M = map(int, input().split())
A = map(int, input().split())

ans1 = sum(A)
ans2 = N - ans1

if N < ans2:
    print("-1")
else:
    print(ans2)
n, m= map(int,input().split())
lista=[]
eq2=0
eq=0
#lista= list(map(int,input().split()))

for x in input().split():
	x= int(x)
	lista.append(x)

eq2= sum(lista)
eq= n-eq2
if eq<=n:
	print(eq)
else:
	print('-1')
n,m= map(int, input().split())
a = list(map(int, input().split()))
if m == len(a):
    print(n-sum(a))
N,M = map(int,input().split())
A_lis = map(int,input().split())

can_play = N - sum(A_lis)
print(can_play if can_play > 0 else -1)
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)
N,M =map(int,input().split())
a =list( map(int,input().split()) )
if sum(a)-N >=0:
    print(sum(a)-N)
else :
    print('-1')
n, m = map(int, input().split())
a = list(map(int, input().split()))
x = 0
for i in range(m):
    x = x + a[i]
print(int(n - x))
N, M = map(int,input().split())
l = list(map(int,input().split()))
su = sum(l) + 1
if N < su:
    print('-1')
else:
    print(N - su)
(n,m)=map(int,input().split())
x = [int(m) for m in input().split()]
sum=sum(x)
print(n-sum)if n>m else print("-1")
N,M = map(int,input().split())
A = list(map(int,input().split()))

days = 0
for a in A:
    days+=a

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

if __name__ == '__main__':
    main()
N, M = map(int, input().split())
A = list(map(int, input().split()))

sum = 0
for i in range(M):
  sum += A[i]
print(str(N - sum))
a, b = map(int, input().split())
c = list(map(int, input().split()))
d = sum(c)
print(a-d if a >= 0 else "-1")
import math

ex = []
N, M = map(int, input().split())
ex = [exi for exi in map(int, input().split())]

rem = N - sum(ex)
print(rem) if rem > 0 else print('-1')
N, M = map(int, input().split())
a = list(map(int, input().split()))
total_a = 0
for i in range(M):
    total_a = total_a + a[i]
print(N-total_a)
user = list(eval(input().replace(" ",",")))
print(user)
sum = 0
for i in user:
    if i == user[0]:
        continue
    elif i == user[1]:
        continue
    sum = sum + i
print(sum - user[0])
n, m = map(int, input().split())
a = [int(i) for i in input().split()]
if sum(a) > n: b = n - sum(a)
else: b = -1
print(b)
n,m=map(int, input().split())
a=list(map(int, input().split()))
for x in range(len(a)):
    n-=a[x]
if n<0:
    k='-1'
print(n)
n, m = map(int, input().split())
A = list(map(int, input().split()))
flg = 0
cnt = sum(A)
if n > cnt:
  print(n-cnt)
else:
  print('-1')
X, Y  = input().split()
sum = 0
Y2 = input().split()
for i in range(0, int(Y)):
  sum += int(Y2[i])

if int(X)-sum > 0:
  print(int(X)-sum)
else:
  print(-1)
n,m = map(int,input().split())
a = list(map(int,input().split()))
print(n-sum(a))
#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    N, M = iim()
    A = sum(iim())

    print(N-A)

if __name__ == "__main__":
    resolve()
N, M = map(int, input().split())
A = list(map(int, input().split()))
if N - sum(A) > 0:
  days = N- sum(A)
else:
  days = 0
print(days)
N, M = map(int, input().split())
A = map(int,input().split())
sa = N - sum(A)


if N >= sum(A):
  print(sa)
else:
  print(-1)
NM = str(input()).split()
work = str(input()).split()
total = 0
for i in range(len(work)):
  total += int(work[i])
  
ans = int(NM[0]) - total

print(ans)
days_summer_vacation, amount_homework = map(int, input().split())
a = map(int, input().split())
schedule_hw = list(a)

left_free_days = days_summer_vacation

for i in schedule_hw:
    left_free_days -= i
    if left_free_days == 0:
        print(0)
        break
    if left_free_days < 0:
        print(-1)
        break

if left_free_days > 0:
    print(left_free_days)
nm = list(map(int, input().split()))
am = list(map(int, input().split()))
x = 0
for i in range(len(am)):
    x += am[i]
if x > nm[0]:
    print('-1')
else:
    print(x)
import math
a=input().split()
f=input().split()
s=0
fl=0
for i in range(0,int(a[1])):
    if(s>=int(a[0])):
        break
        fl+=1
if(fl!=1):
    print(int(a[0])-s)
else:
    print("-1")
n, m = map(int, input().split())
a = list(map(int, input().split()))
total = sum(a)
if total <= n:
    print(total)
else:
    print(-1)
n, m = map(int, input().split())
a = [i for i in 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().strip().split()))
s=0
for i in range(0,M):
  s+=A[i]
if s>=0:
  print(N-s)
else:
  print('-1')
n, m = input().split()
n = int(n)

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