peterverebics/CodeNet_Python_118 huggingface dataset:
N,M=map(int,input().split())
A=list(map(int,input().split()))
ans=N-sum(A)
print(ans if ans>=0 else -1)
# coding: utf-8
N, M = map(int, input().split())
A = list(map(int, input().split()))
homeworkDays = sum(A)
if homeworkDays > N:
    print("-1")
else:
    print(N - homeworkDays)
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)
n, m = map(int, input().split())
a = list(map(int, input().split()))
print(max(n - sum(a), -1))
n,m = [int(e) for e in input().split()]
a = [int(e) for e in input().split()]
for i in range(m):
    n -= a[i]
if n < 0:
    print(-1)
else:
    print(n)
import math

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

b=input()
b=b.split()

z=0

for x in b:
  z=z+int(x)

w=N-z

if w<0:
  print("-1")
else:
  print(w)
n, m = map(int, input().split())
sequence = list(map(int, input().split()))
a = sum(sequence)
if a > n:
    print(-1)
else:
    print(n - a)
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())
day = list(map(int, input().split()))
aso = n-sum(day)
print(aso if aso >= 0 else "-1")
n,m = map(int, input().split())
x = n-sum(list(map(int, input().split())))

if x < 0: 
    print(-1)
else:
    print(x)
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))
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()))
for i in range(m):
    n -= a[i]
print(n if n >= 0 else -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())
l = list(map(int, input().split()))

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

play_days = n - cost_days
if play_days < 0:
    print(-1)
else:
    print(play_days)
N, M = map(int, input().split(" "))

li_a = list(map(int, input().split(" ")))
days = 0

for i in range(M):
  days += li_a[i]

if N >= days:
  print (N - days)
else:
  print(-1)
N,M = map(int,input().split())
list_A = list(map(int,input().split()))

sum = sum(list_A)
if N-sum>=0:
    print(N-sum)
else:
    print('-1')
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(max(-1,N-wa))
import numpy as np

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

As = np.asarray(input().split(), dtype=np.int32)

ans = n - np.sum(As)

if ans < 0:
    print(-1)
else:
    print(ans)
n, m = map(int, input().split())
a = list(map(int, input().split())) # list()でリスト化、それを変数に代入。

print(max(n-sum(a),-1))
N,M = map(int, input().split())
a = map(int,input().split())
goukei = sum(a)

if N-goukei<0:
    r=-1
else:r = N-goukei
print(r)
n, m = list(map(int, input().split()))
homework = [int(i) for i in input().split()]
for i in homework:
  n -= i
if n >= 0:
  print(n)
else:
  print(-1)
N,M=map(int,input().split())
list = [int(i) for i in input().split()]
Sum=sum(list)

if(N-Sum < 0):
  print(-1)
else:
  print(N-Sum)
import sys
input = sys.stdin.readline

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


if __name__ == "__main__":
    main()
def q2():
    days, _ = [int(i) for i in input().split(" ")]
    hw = [int(i) for i in input().split(" ")]

    play = days - sum(hw)
    if play < 0:
        play = -1
    print(play)
    
q2()
n,m=map(int,input().split())
a=list(map(int,input().split()))
print(max(-1,n-sum(a)))
N, M = map(int, input().split())

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

if N - sum(data) >= 0:
    print(N-sum(data))
else:
    print(-1)
d,n = map(int,input().split())
a = list(map(int,input().split()))
print(max(-1,d-sum(a)))
N,M = map(int,input().split())
A = input().split()
for i in range(M):
    N -= int(A[i])
if N >= 0:
    print(N)
else:
    print(-1)
def main():
    n,m = tuple([int(t)for t in input().split()])
    a = tuple([int(t)for t in input().split()])

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

if __name__ == "__main__":
    main()
N,M=map(int,input().split())
c=input().split()
if sum(int(i) for i in c)>N:
    print(-1)
else:
    print(N-sum(int(i) for i in c))
N,M = map(int, input().split())

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

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

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

b=sum(a)
if n<b:
    print("-1")
else:
    print(n-b)
n,m=map(int,input().split())
L=list(map(int,input().split()))
total = sum(L)
ans = n-total
if ans <0:
	print(-1)
else:
	print(ans)
N,M = map(int, input().split()) 
A = list(map(int, input().split()))
S =sum(A)

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

sum = 0
for e in l:
    sum += e

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

if N >= sum(A):
  print(N - sum(A))
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)
n,m = input().split()
N = int(n)
L1 = list(map(int,input().split()))
ans=-1
if sum(L1)<=N:
    ans = N-sum(L1)
print(ans)
n, m = map(int, input().split(" "))
arr = list(map(int, input().split(" ")))

amount = sum(arr)
ret = n-amount
if ret < 0:
    print(-1)
else:
    print(ret)
# coding: utf-8
# Your code here!
input_line = input().split()
N = int(input_line[0])
M = int(input_line[1])
count = 0
line = input().split()
for i in range(M):
    count+=int(line[i])
    
if N - count <= -1:
    print(-1)
    
    
else:
    print(N - count)
n, m = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
for i in range(m):
    ans += a[i]

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

if x > N:
    print(-1)
else:
    print(N - x)
n, m = map(int, input().split())
a = list(map(int, input().split()))
days = sum(a)
# print(-1) if n - days < 0 else print(n-days)
print(max(-1, n-days))  # ←賢い
n, m = map(int, input().split())
a_list = map(int, input().split())
for a in a_list:
    n -= a

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

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

diff=n-sum
if(diff<0):
    print(-1)
else:
    print(diff)
N, M = [int(x) for x in input().split()]
A = [int(a) for a in input().split()]
tmp = N - sum(A)
if tmp >= 0:
    print(tmp)
else:
    print(-1)
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
N, M = map(int, input().split())
# 文字列の入力
s = input()
t = s.split(" ")
sum = 0
for u in t:
    sum += int(u)
if sum > N:
    print(-1)
else:
    print(N-sum)
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))
N,M=map(int,input().split())
A=list(map(int, input().split()))

r = N-sum(A)
if r < 0:r=-1
print(r)
N,M = map(int, input().split())
A = list(map(int, input().split()))  # 入力のときに N を使う必要はありません
# print(A[0]) 
F=N-sum(A)
if F>=0:
    print(F)

if F<0: 
    print(-1)
line=input().split(' ')
N=int(line[0])
M=int(line[1])

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

res=N-sum(A)

if res<0:
    print(-1)
else:
    print(res)
#!/usr/bin/env python3

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

if __name__ == "__main__":
    main()
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

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

resolve()
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())
s=0
for i in input().split():
    s=s+int(i)
if s>n:
    print("-1")
else:
    print(n-s)
N,M = map(int,input().split())
A = list(map(int,input().split()))
output = N - sum(A)
if output >= 0:
    print(output)
else:
    print(-1)
N, M = map(int, input().split())
A = list(map(int, input().split()))

homework = sum(A)

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


if __name__ == '__main__':
    solve()
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
if N - sum(A) >= 0:
     print(N - sum(A))
else:
    print(-1)
#高橋君の夏休みは N 日間です。
#夏休みの宿題が M 個出されており
#i 番目の宿題をやるには Ai 日間かかります。
#夏休み中に全ての宿題を終わらせるぉとができないときは、かわりに '-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=[int(i) for i in input().split()]
print(max(N-sum(A),-1))
if __name__ == '__main__':
    x=list(map(int,input().split(" ")))
    y = list(map(int, input().split(" ")))
    num=0
    for i in y:
        num+=i
    if x[0]<num:
        print(-1)
    else: print(x[0]-num)
N, M = map(int, input().split())
*A, = map(int, input().split())
rem = N - sum(A)
print(rem if rem >= 0 else -1)
n,m=map(int, input().split())
a=list(map(int, input().split()))
print(max(-1,n-sum(a)))
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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

if __name__ == '__main__':
    resolve()
N, M = map(int, input().split())
a_list = list(map(int, input().split()))
days = sum(a_list)
if N >= days:
    print(N-days)
else:
    print(-1)
a,b=map(int,input().split())

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

for i in range(len(s)):
  a=a-s[i]
  
if a>=0:
  print(a)
else:
  print("-1")
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(' '))

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

result = N - sum(syuku)

print(result) if result >= 0 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")
# -*- coding: utf-8 -*-

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

     a_sum = sum(a_list)
     if n >= a_sum:
          print(n - a_sum)
     else:
          print(-1)

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

s = sum(A)

ans = N - s

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

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

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

total = sum(A)
if N < total:
    print(-1)
else:
    print(N-total)
n, m = [int(i) for i in input().split(' ')]
s = sum(int(i) for i in input().split(' '))
x = max(n - s, -1)
print(x)
n,m = map(int,input().split())
a=list(map(int,input().split()))
sam =  sum(int(i) for i in a)
SAM = n-sam
if SAM >=0:
  print(SAM)
else:
  print(-1)
a=input().split(' ')
#print(a[0])
b=int(a[0])
d=int(a[1])
c=input().split(' ')
count=0
for i in c:
    count+=int(i)
    
#print(count)
if b-count>=0:
    print(b-count)
else:
    print(-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()))
D = sum(A)
if N < D:
    print(-1)
else:
    print(N-D)
n, m = map(int, input().split())
homework_cost = list(map(int, input().split()))
sum = 0
for i in range(len(homework_cost)):
    sum += homework_cost[i]
if n - sum >= 0:
    print(n - sum )
else:
    print(-1)
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()))
if N-sum(A)>=0:
    print(N-sum(A))
else:
    print(-1)
N, M = map(int, input().split())
A = list(map(int, input().split()))
 
days = sum(A)
 
if days <= N:
    print(N-days)
else:
    print(-1)
n,m=map(int, raw_input().split())
arr=map(int, raw_input().split())
s=sum(arr)
if s>n:
  print -1
else:
  print n-s
A,B = map(int,input().split())
s = list(map(int,input().split()))
if sum(s) <= A:
  print(A-sum(s))
else:
  print("-1")
from sys import stdin
import math
import fractions

n, m = [int(x) for x in stdin.readline().rstrip().split()]
a = [int(x) for x in stdin.readline().rstrip().split()]

count = 0
for aa in a:
    count += aa

if n - count < 0:
    print(-1)
else:
    print(n - count)
N, M = map(int, input().split())
a = list(map(int, input().split()))
homework = 0

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

play = N - homework

if play < 0:
    print(-1)
else:
    print(play)
# coding:utf-8
n,m =map(int,input().split())
a=list(input().split())

for i in range(len(a)):
    n=n- int(a[i])

if n>=0:
    print(n)

else:
    print(-1)
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)
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(max(n-sum(a),-1))
if __name__ == '__main__':
    do()
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)
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
A = [int(i) for i in input().split()]
del A[m:len(A)]
print(n - sum(A)) if sum(A) <= n else print(-1)
N, M = map(int, input().split())
A = list(map(int, input().split()))

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

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

for i in A:
    sumStudyDay += int(i)
    
leftDay = int(N)-sumStudyDay

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

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

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

if x > N:
    print(-1)
else:
    print(N - x)
N, M= map(int,input().split())
numbers = list(map(int, input().split()))

amount = 0
for i in range(M):
    amount = amount + numbers[i]

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

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 = list(map(int, input().split()))
print(N - sum(A) if N - sum(A) >= 0 else -1)
# input
inp_ls = input().split(" ")
n,m = [int(e) for e in inp_ls[:2]]
inp_a_ls = input().split(" ")
a_ls = [int(e) for e in inp_a_ls[:m]]

# calc
rest = n - sum(a_ls)
out = rest if rest >= 0 else -1

# result
print(out)
N, M = tuple(int(n) for n in input().split())

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

for A in As:
    N -= A

print(max(N, -1))
N,M = map(int,input().split())
plan = list(map(int,input().split()))
sum = N
for i in range(M):
  sum = sum - plan[i]

if 0 <= sum <= N:
  print(sum)

else:
  print('-1')
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)
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())
A = sum(map(int, input().split()))

print(N - A) if N - A >= 0 else print(-1)
n,m = list(map(int,input().split()))
l = list(map(int,input().split()))
ans = n - sum(l)
if ans < -1:
    print(-1)
else:
    print(ans)
N,M = map(int,input().split())
A = list(map(int,input().split()))
days=sum(A)
if (days>N):
  print(-1)
else:
  print(N-days)
n, m = map(int, input().split())
a = list(map(int,input().split()))
for i in a:
  n -= i
if n >=0:
  print(n)
else:
  print(-1)
import sys

lines = sys.stdin.readlines()

X = lines[0].split(' ')
Y = lines[1].split(' ')

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

d = 0
for i in range(M):
    d = d + int(Y[i])

if d > N:
  print(-1)
else:
  print(N-d)
i = list(map(int, input().split()))
j = list(map(int, input().split()))

jj = sum(j)

if i[0]-jj < 0:
    print(-1)
else:
    print(i[0]-jj)
n,m = map(int, input().split())
a = sum(list(map(int, input().split())))
if n >= a:
  print(n-a)
else:
  print(-1)
import numpy as np
n, m=map(int,input().split())
a = np.array(list(map(int, input().split())))
days = n - np.sum(a)
if days < 0:
    print(-1)
else:
    print(days)
n, m = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
for ai in a:
  n -= ai
n = -1 if n < 0 else n
print(n)
import sys
N, M = map(int, sys.stdin.readline().split())
li = list(map(int, sys.stdin.readline().split()))
if sum(li) > N:
  print(-1)
else:
  print(N - sum(li))
n,m = map(int,input().split())
a_list = list(map(int,input().split()))
if n - sum(a_list) < 0:
  print(-1)
else:
  print(n - sum(a_list))
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 = list(map(int,input().split()))
num = 0
for i in range(m):
    num += a[i] 
if num > n:
    print("-1")
else:
    print(n - num)
N, M = map(int, input().split())
A = list(map(int, input().split()))
ans = N
for i in range(0, M):
  ans -= A[i]
if ans >=0:
  print(ans)
else:
  print(-1)
import math

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

tot = sum(Ai)

a = N-tot
if(a>=0):
  print(a)
else:
  print('-1')
def submit():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    print(max(-1, n - sum(a)))


submit()
l=[int(i) for i in input().split()]
m=[int(i) for i in input().split()]
print(max(-1,l[0]-sum(m)))
#!/usr/bin/env python3

from sys import stdin


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

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


if __name__ == "__main__":
    main()
N,M,*A = map(int,open(0).read().split())

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

x = N-(sum(A))

print(-1 if x < 0 else x)
import sys
stdin = sys.stdin

     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
N,M=nm()
A=nl()

h_sum=sum(A)
print(N-h_sum if N-h_sum>=0 else -1)
# coding: utf-8
init = [int(s) for s in input().rstrip().split(' ')]
data = [int(s) for s in input().rstrip().split(' ')]

days_homework = sum(data)
left_time = init[0] - days_homework
if left_time < 0:
    print(-1)
else:
    print(left_time)
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    print(max(-1, N - sum(A)))


if __name__ == "__main__":
    main()
n,m=map(int,input().split())
arr=list(map(int,input().split()))
va=n-sum(arr)
if va<0:
  print("-1")
else:
  print(va)
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)
def resolve():
    '''
    code here
    '''
    N, M = [int(item) for item in input().split()]
    A_list = [int(item) for item in input().split()]

    all_sum = sum(A_list)

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

if __name__ == "__main__":
    resolve()
n,m = map(int,input().split())
l = list(map(int,input().split()))
left = n - sum(l)
if left < 0 :
    print(-1)
else :
    print(left)
import math
import time
from collections import defaultdict,deque
from sys import stdin,stdout
from bisect import bisect_left,bisect_right
n,k=map(int,stdin.readline().split())
a=list(map(int,stdin.readline().split()))
ans=n
ans-=sum(a)
print(max(-1,ans))
# -*- coding: utf-8 -*-

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

if 0<=N-sum(A):
  print(N-sum(A))
else:
  print(-1)
NM = input()
day, num = NM.split(' ')
day, num = int(day), int(num)
assignments = input().split(' ')

for i in range(num):
    day -= int(assignments[i])

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

if sum(k) > int(n):
    print("-1")
    exit()

kekka = int(n) - sum(k)

print(kekka)