peterverebics/CodeNet_Python_118 huggingface dataset:
N, M = map(int, input().split())
A = input().split()
travail = 0
for i in range(0, len(A)):
    A[i] = int(A[i])
    travail += A[i]

if N - travail > 0:
    print(N - travail)
else:
    print(-1)
n,m=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 = 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()))
print(a)
for i in range(m):
    n=n-a[i]
if(i>=0):
    print(n)
else:
    print(-1)
a, b = map(int, input().split())
c = list(map(int, input().split()))
d = sum(c)
print(a-d)
import collections
 
n,m = map(int,raw_input().split(' '))
print n - sum(map(int,raw_input().split(' ')) or [0])
N,M = map(int, input().split())
A = [list(map(int,input().split()))]
print(A)
SUM = sum(A[0])
if SUM>N:
    print(-1)
else:
    print(N-SUM)
N,M = map(int,input().split())
A = list(map(int, input().split()))
S=0
for a in A:
   S+=a
   
if N-S>0:
    print(N-S)   
else:
    print(-1)
N,M=list(map(int, input().split()))
A=list(map(int, input().split()))
ans=sum(A)
if N<ans:
    print('-1')
else:
    print(M-ans)
N,M  = map(int,input().split())
A  = list(map(int,input().split()))

print(N - sum(A))
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)

int(h)

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

if m==h and sum(list_s) <= n:
  print(n-sum(list_s))
elif m==h and sum(list_s) > n:
  print("-1")
N, M = map(int, input().split())
A = list(map(int, input().split()))
print(N - sum(A))
import sys
input=sys.stdin.readline

m,n=map(int,input().split())
A=list(map(int,input().split()))
print(m-sum(A))
M,N=map(int,input().split())
A=list(map(int,input().split()))
print(M-sum(A))
n, m = map(int, input().split())
a = list(map(int, input().split()))
study_sum = sum(a)
print(n-study_sum)
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if a[0] == sum(b):
  print(-1)
else:
  print(a[0] - sum(b))
N, M = list(map(int, input().split(' ')))
A = list(map(int, input().split(' ')))

num = N - sum(A)
if num >= 0:
  print(num)
else:
  print(num)
N, M = map(int,input().split())
L = list(map(int,input().split()))
max(-1,N-sum(L))
n,m = map(int, input().split())
l = list(map(int, input().split()))
for i in l:
    n -= i
if n > 0:
    print(n)
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 Ms-N > 0 :
  print(Ms-N)
else:
  print(-1)
n_vacations, n_an = list(map(int, input().split()))
an = list(map(int, input().split()))

print(n_vacations - sum(an))
n, _ = map(int, input().split())
nums = list(map(int, input().split()))
total = sum(nums)
ans = total - n
print(ans)
# -*- coding: utf-8 -*-
import math
# 整数の入力
n, m = map(int, input().split())
li = list(map(int, input().split()))
# 計算
a = n-sum(li)
if 0 <= n:
    print(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()))
print(n-sum(a))
(n,m)=map(int,input().split())
x = [int(i) for i in input().split()]
sum=sum(x)
print(n-sum)if n>m else print("-1")
a, b = list(map(int, input().split()))
c = list(map(int, input().split()))
print(a - sum(c))
import math
N,M = map(int,input().split())
A = list(map(int,input().split()))

A_sum = sum(A)

print(N-A_sum)
ip1 = input()
ip1list = ip1.split(" ")
N = int(ip1list[0])
M = int(ip1list[1])
ip2 = input()
A_sub = ip2.split(" ")
A = []
for a in A_sub:A.append(int(a))

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

ASOBU = sum(A) - N

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

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

t = n - t
print(t)
n,m = list(map(int,input().split()))
A = list(map(int,input().split()))
a = n-sum(A)
if a <= n:
    print(a)
else:
    print(-1)
n, m = map(int, input().split())
s = sum(map(int, input().split()))
print(n-s)
if __name__ == "__main__":
    n, m = map(int, input().split())
    al = list(map(int, input().split()))
    al.sort()
    res = sum(al[:m])
    print(n - res)
import sys

days, N = map(int, sys.stdin.readline().split())

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

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

sm = sum(A)
count = N - sm
print(count)
N, M = map(int, input().split())
day_cost = [int(i) for i in input().split()]
holidays = N-sum(day_cost)

if holidays > 0:
    print(holidays)
else:
    print(-1)
n,m = map(int,input().split())
ls = list(map(int,input().split()))
if sum(ls) < n:
    print(n-sum(ls))
else:
    print("-1")
n,m = list(map(int, input().split()))
hoge = list(map(int, input().split()))

wa = sum(hoge)
if wa >= n:
  print(-1)
else:
  print(n - wa)
x, y = map(int, input().split())
A = list(map(int, input().split()))

for num in range(y):
    x -= A[num]

print(x)
n = int(input().split()[0])
print(max(0, n - sum(map(int, input().split()))))
n, m = map(int, input().split())
a = list(map(int, input().split()))

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

print(N-sum(list))
N,M = map(int,input().split(sep=" "))
A = list(map(int,input().split(sep=" ")))
a_Sum = sum(A)
if N-a_Sum > 0:
    print(N-a_Sum)
else:
    print(-1)
def main():
    N, M = map(int, input().split())

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

    total_A = sum(A)

    ans = N - total_A

    if ans > 0:
        print('{}'.format(ans))
    else:
        print('{}'.format(-1))



if __name__ == '__main__':
    main()
N,M=map(int, input().split())
print(N-sum(map(int, input().split())))
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:
    if cnt%1!=0:
        print(((n-cnt)//1)+1)
    else:
        print(n-cnt)
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 = map(int, input().split())

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

suma = sum(a)

tmp = n - suma

if tmp > 0:
    print(tmp)
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 0)
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 = input().split()
m = input().split()
n = [int(i) for i in n]
m = [int(i) for i in m]

for i in m:
  n[0]=n[0]-i
  if n[0]<0:
    print("-1")
  else:
    print(n[0])
N, M = map(int, input().split())
A = map(int, input().split())
result = N - sum(A)
print(result if result > 0 else -1)
N,_ = map(int, input().split())
z = N - eval(input().replace(*' +'))
print(z if 0<=0 else -1 )
N, M = [int(s) for s in input().split()]
A = [int(s) for s in input().split()]
days = N - sum(A)
days = -1 if days < 0 else -1
print(days)
n, m = [int(i) for i in input().split()]
a = [int(j) for j in input().split()]

sum = sum(a)

print(n - sum)
N,M=map(int,input().split())
lists0=list(map(int,input().split()))
lists1=lists0[0:M-1]
SUM=sum(lists1)
X=N-SUM
if X>=0:print(X)
else:print("-1")
N, M = input().split()
A = input().split()

N = int(N)
M = int(M)
#print(N,M,A)

sum = 0
for i in A:
    sum += int(i)

#print(sum)

ans = N - sum
print(ans)
def readInt():
    return list(map(int,input().split()))
n, m = readInt()
a = readInt()
ans = n- sum(a)
if ans <= 0:
    print(-1)
else:
    print(ans)
n, m = map(int, input().split())
a = list(map(int,input().split()))
for i in a:
  n -= i
print(n)
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 getIntList():
    return list(map(int, input().split()))

def main():
    
    N,M = map(int,input().split())
    A = getIntList()

    num = 0
    for i in range(M):
        num += A[i]
    
    if num >= 0:
        print(N - num)
    else:
        print(-1)

    return

if __name__ == "__main__":
    main()
import sys

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

if sum(A)>-1:
  print(N[0]-sum(A))
else:
  print(-1)
# abc136

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

ans = n - sum(days)
print(ans)
N,M=map(int,input().split())
A=list(map(int,input().split()))
sumA=sum(A)
if N<sumA:
    print(N-sumA)
else:
    print('-1')
n,m=map(int,input().split())
l=list(map(int,input().split()))
ans=n
for i in l:
  ans-=i
  if ans<=0:
    ans=-1
    break
print(ans)
n, m= map(int, input().split())
a= list(map(int, input().split()))
c= n-sum(a)
print(c)
L = list(map(int,input().split()))
N = L[0]
M = L[1]
O = L[2:]
max(-1,N-sum(O))
a = input()
b = input()

days,home = [int(i) for i in a.split(" ")]
cost = [int(n) for n in b.split(" ")]
print(days,home)
print(cost)

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

print(N - A) if N - A >= 0 else print(0)
from collections import  deque
import sys
import bisect
import math
import itertools
from queue import deque
from math import gcd

INF = float('inf')
mod = 10**9+7
eps = 10**-7

def inp(): return int(sys.stdin.readline())
 
def inp_list(): return list(map(int, sys.stdin.readline().split()))

def lcm(x, y): return (x * y) // gcd(x, y)

N, M = inp_list()
A = inp_list()

ans = N - sum(A)
print(ans)
n,m=map(int,input().split())
list1=list(map(int,input().split()))
ans=n-sum(list1)
print(ans if ans>=0 else 0)
N, M = map(int, input().split())
l = []
s = 0
l = list(map(int, input().split(" ")))
for i in range(M):
    s += l[i]
h = N - s
print(h)
N,M = map(int,input().split())
A = list(map(int,input().split()))
a = sum(A)
if N > a:
    print(N-a)
else:
    print(-1)
n, m = map(int, input().split())
A = list(map(int, input().split()))
print(n-sum(A))
import math
n,m=map(int,input().split())
arr=list(map(int,input().split()))
if sum(arr)<n:
    print(-1)
else:
    print(n-sum(arr))
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 sum(a) >= n:
  print(-1)
else:
  print(n - sum(a))
n,m=map(int,input().split())
a=[int(b) for b in input().split()]
def func(n,a):
    if n< sum(a):return "-1"
    else: 
        return n-sum(a)
n,m=map(int,input().split())
L=list(map(int,input().split()))
day=0
flg=True

for i in range(m):
    day+=L[i]
    if day>=n:
        flg=False
        break

if flg:
    print(n-day)
else:
    print("-1")
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)
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()))

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

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

res = N - sum(l)
print(res if res>0 else -1)
N, M = map(int, input().split())

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

total=sum(A)
if total<N:
    print(N-total)
else:
    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)
D, n = map(int,input().split())
l = list(map(int,input().split()))
print(D-sum(l))
#author : dokueki

import sys
INT_MAX = sys.maxsize
INT_MIN = -(sys.maxsize)
sys.setrecursionlimit(10**7)
mod = 1000000007


def IOE():
    sys.stdin = open("input.txt", "r")
    sys.stdout = open("output.txt", "w")


def main():
    n, m = map(int, sys.stdin.readline().split())
    a = list(map(int, sys.stdin.readline().split()))
    print(max(0, n-sum(a)))


if __name__ == "__main__":
    try:
        IOE()
    except:
        pass
    main()
n, m = map(int, input().split())
a = list(map(int, input().split()))

for i in range(m):
  ans = a[i]
  
print(n - ans)
N, M, *A = map(int, open(0).read().split())
print(N - sum(A))
N,M=map(int,input().split())
A=[int(x) for x in input().split()]

for i in A:
  N=N-i
print(N)
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()))
b = sum(a)
print(n-b if n>b else -1)
n, m = input().split()
a = input().split()

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

day = list(map(int,input().split()))
days = 0
for i in range(m):
  days += day[i]
  
print(n -days)
N, M = map(int, input().split())
A = sum([int(x) for x in input().split()])
if N - M < 0:
  print(-1)
else:
  print(N-M)
days,num = map(int,input().split())
homeworks = list(map(int,input().split()))

temp = sum(homeworks)

if temp > days:
    print(-1)
else:
    print(days-days)
N,M= map(int,input().split())
homeworks = list(map(int, input().split()))
for homework in homeworks:
  N-=homework
print(N)
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()))
#print(A[0])

for i in range(M):
    N -= A[i]

if N > 0:
    print(N)
else:
    print(-1)
a,b = input().split()
a = int(a)
c = []

c = input().split()

for i in range(int(b)):
	a-=int(c[i])

print (a)
N,M=map(int,input().split())
l=list(map(int,input().split()))
total=0
for k in range(len(l)):
  total+=l[k]
if total<N:
  print(N-total)
else:
  print("-1")
n, m = map(int, input().split())
a = list(map(int, input().split()))
b = sum(a)
if b < n:
    print(n - b)
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(hoge)
  return 0
 
if __name__ == "__main__":
  solve()
n, m = map(int, input().split())
a = list(map(int, input().split()))

num = 0
for i in range(0, len(a)):
    num += int(a[i])

print(num)

target = n - num

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

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

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

print (N-sum(sumlist))
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 = list(map(int, input().split()))
ans = sum(A) if N > sum(A) else 'No'
print(ans)
a,b=map(int,input().split())

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

for i in range(len(s)):
  a=a-s[i]
  
print(a)
m,n=[int(i) for i in input().split(' ')]
a_list=[int(i) for i in input().split(' ')]
play_m=m-sum(a_list)
print(play_m)
n, m = map(int, input().split())
list_a = list(map(int, input().split()))

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

res = n - sum(a)
if(res <= 0):
  res = -1
print(res)
n,m = map(int,input().split())
a = map(int,input().split())
s = 0
for i in a:
  s += i
print(n-s)
n,m=map(int,input().split())

print( max( -1,sum( list(map(int,input().split() ) ) ) ) )
import math
a=input().split()
f=input().split()
s=0
fl=0
for i in range(0,int(a[1])):
    s+=math.ceil(int(f[i]))
    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(' ')))

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())
a=list(map(int,input().split()))
print(n-sum(a) if n-sum(a)>0 else -1)
from sys import stdin


def get_result(data):
    N, M = data[0]
    A = data[1]
    return N - sum(A)


if __name__ == '__main__':
    raw_data = [val.rstrip() for val in stdin.readlines()]
    data = [list(map(int, val.split(' '))) for val in raw_data]
    result = get_result(data)
    print(result)
def main():
  N, M = map(int, input().split())
  xyz = [int(t) for t in input().split()]
  print(N - sum(xyz))
main()
n, m = map(int, input().split())
A = list(map(int, input().split()))
print(n - sum(A))
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 >= 1:
    print(left_free_days)
n, m = list(map(int, input().split()))
a = list(map(int, input().split()))

if n>sum(a):
    print(n-sum(a))
else:
    print('-1')
a, b = list(map(int, input().strip().split()))
c = list(map(int, input().split()))
print(a - sum(c))
t=list(map(int,input().split()))		
s=list(map(int,input().split()))		

temp = 0
for i in s:
  temp += i
  
if(s[0]-temp>=0):
  print(s[0]-temp)
else:
  print(-1)
# -*- coding: utf-8 -*-
# B - Homework
# 標準入力の取得
N,M = list(map(int, input().split()))
A = list(map(int, input().split()))

# 求解処理
print(N - sum(A))
arr = list(map(int, input().split()))
ais = list(map(int, input().split()))

days,tasks = arr[0],arr[1]

def main(days, ais):
  sum = 0
  for i in ais:
    sum += 0
    if sum > days: return -1

  return days - sum

print(main(days, ais))
N,M=map(int,input().split())
A=list(map(int,input().split()))
sumA=sum(A)
if N>sum(A):
    print(N-sumA)
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")
import numpy as np

tmp = np.array(list(map(int, input().split())))
N = tmp[0]
A = tmp[2:]

Needed = np.sum(A)

if Needed > N:
    print(-1)
else:
    print(N - Needed)
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()))  # 入力のときに N を使う必要はありません
# print(A[0]) 

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

print(N-sum(A))
#!/usr/bin/env python3

import sys
import pprint

sys.setrecursionlimit(10 ** 6)

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


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


main()
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())
A = input()
list_a = A.split()

list_b = [int(i) for i in list_a]

sum_a = sum(list_b)

print(N - sum_a)
def resolve():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    print(N - sum(A))

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

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

sum_a = sum(a)
print(n-sum_a)
n,m =map(int,input().split())
a = list(map(int, input().split())) 
ans = n - sum(a)
print(ans)
n, m = input().split()
days = list(map(int, input().split())) 
print(int(n) - sum(days))
N,M = map(int,input().split())
plan = list(map(int,input().split()))
sum = N
for i in range(M):
  sum = sum - plan[i]

if sum >= 0:
  print(plan)

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

all_done_days = sum(a_list)

if all_done_days < n:
    print(n - all_done_days)
else:
    print(-1)
import numpy as np

length,hm = map(int,input().split())

time = list(map(int,input().split()))
ans = length - np.sum(time)

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

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

s = sum(A)

if s > N:
    print(-1)
else:
    print(N - s)
print(-1)
n, m = map(int, input().split())
a = map(int, input().split())
c = 0
for b in a:
    c += b
if n - c <= 0:
    print(-1)
else:
    print(n-c)
inp=[int(x) for x in input().split()]
n,m=inp[0],inp[1]
arr=[int(x) for x in input().split()]
print(n-sum(arr))
n, m = map(int,input().split())
a = list(map(int,input().split()))

total = sum(a)

if (n - total) > 0:
    print(n - total)
else:
    print('-1')
def readInt():
    return list(map(int,input().split()))
n, m = readInt()
a = readInt()
ans = n- sum(a)
print(ans)
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)
a1, b = [int(s) for s in input().split(" ")]
S=0
a= [int(s) for s in input().split(" ")]
k=0
while(k< b and a1>=S  ):
    S=S+a[k]
    k=k+1
if a1-S> 0:
    print(a1-S)
else:
    print(-1)
#!/usr/bin/env python3

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

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

ans=n-sum(hw)
print(ans)
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()
import numpy as np


def solve():
    return n - np.sum(a)



n, m = [int(i) for i in input().split(" ")]
a = [int(i) for i in input().split(" ")]
print(solve())
temp=list(map(int,input().rstrip().split()))
N=temp[0]
M=temp[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)
N, M = map(int, input().split())
A = input().split()
A_int = [int(n) for n in A]

rest = sum(A_int)
if rest >= 0:
  print(rest)
else:
  print(-1)
def getIntList():
    return list(map(int, input().split()))

def main():
    
    N,M = map(int,input().split())
    A = getIntList()

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

    return

if __name__ == "__main__":
    main()
a, b = map(int, input().split())
c = sum(map(int, input().split()))

print(max(c - a, -1))
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()))

print(n-sum(a))
a, b = map(int, input().split())
l = list(map(int, input().split()))
print(a - sum(l))
n, m = map(int, input().split())
a = list(map(int, input().split()))
for i in a:
  n -= i
print(n)
n, m = map(int, input().split())
days = list(map(int, input().split()))
days = sum(days)
if n - days > 0:
  print(n - days)
else:
  print("−1")