Problem:
 Score : 200 points    Problem Statement Takahashi has N days of summer vacation.  His teacher gave him M summer assignments. It will take A_i days for him to do the i -th assignment.  He cannot do multiple assignments on the same day, or hang out on a day he does an assignment.  What is the maximum number of days Takahashi can hang out during the vacation if he finishes all the assignments during this vacation?  If Takahashi cannot finish all the assignments during the vacation, print -1 instead.      Constraints  1 \leq N \leq 10^6  1 \leq M \leq 10^4  1 \leq A_i \leq 10^4         Input Input is given from Standard Input in the following format:  N  M  A_1  ...  A_M       Output Print the maximum number of days Takahashi can hang out during the vacation, or -1 .        Sample Input 1 41 2
5 6      Sample Output 1 30  For example, he can do the first assignment on the first 5 days, hang out on the next 30 days, and do the second assignment on the last 6 days of the vacation. In this way, he can safely spend 30 days hanging out.       Sample Input 2 10 2
5 6      Sample Output 2 -1  He cannot finish his assignments.       Sample Input 3 11 2
5 6      Sample Output 3 0  He can finish his assignments, but he will have no time to hang out.       Sample Input 4 314 15
9 26 5 35 8 9 79 3 23 8 46 2 6 43 3      Sample Output 4 9

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

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

ans=N-sum(A)

if ans<0:
    print(-1)
else:
    print(ans)

Solution (Python):
inp1=list(map(int,input().strip().split()))[:2]
n,m=inp1[0],inp1[1]
arr=list(map(int,input().strip().split()))[:m]
sum1=sum(arr)
if(sum1 > n):
	print(-1)
else:
	print(n-sum1)

Solution (Python):



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


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

a = sum(A)

if a > N:
  print(-1)
else:
  print(N-a)

Solution (Python):
x, y = map(int,input().split())
a = list(map(int,input().split()))
b = sum(a)
if x >= b:
    print(x - b)
else:
    print(-1)

Solution (Python):
m,n=map(int,input().split())

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

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

if sum(a) > n:
    print("-1")
else:
    print(n-sum(a))

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

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

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

print(ans)

Solution (Python):



import math

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

sum = 0
for a in As:
    sum += a

print(max(N - sum, -1))

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

Solution (Python):
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)

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

_sum = sum(a)

if _sum > n:
    print(-1)

else:
    print(n - _sum)

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

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

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

Solution (Python):
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)

Solution (Python):
N,M =input().split()
A_list=list(map(int,input().split()))
if int(N)-sum(A_list) <= -1:
    print(-1)
else:
    print(int(N)-sum(A_list))

Solution (Python):
n, m = map(int, input().split())

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

total = sum(a)

if total > n:
    print(-1)
else:
    print(n - total)

Solution (Python):
n, m = map(int, input().split())
a = map(int, input().split())

cnt = 0

for i in a:
    cnt += i

if n >= cnt:
    print(n - cnt)
else:
    print(-1)

Solution (Python):
n,m=map(int,input().split())
a=list(input().split(' '))
sum=0
for i in a:
    sum+=int(i)
print(n-sum if n>=sum else -1)

Solution (Python):
import sys
input = sys.stdin.readline

I = input().split()
N = int(I[0])
M = int(I[1])

I = input().split()
Ai = [0] * M

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

ans = N - sum

if ans < 0:
    print(-1)
else:
    print(ans)

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

Solution (Python):
import sys

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

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


for i in A:
  N-=i
  if N<0:
    print(-1)
    sys.exit()
    
print(N)

Solution (Python):
N,M = input().split()
A = input().split()
for i in range(int(M)):
    N = int(N) - int(A[i])
if N >= 0:
    print(N)
else:
    print("-1")

Solution (Python):


def solve():
    N, M = list(map(int, input().split()))
    As = list(map(int, input().split()))

    total = sum(As)

    if N - total < 0:
        print(-1)
    else:
        print(N-total)


if __name__ == "__main__":
    solve()

Solution (Python):
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)

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

Solution (Python):
n,m=map(int,input().split())
a=list(map(int,input().split()))
result=0
for i in range(0,m):
  result += a[i]
  
if n - result >= 0:
  print(n-result)
else:
  print("-1")

Solution (Python):
def main():
    n, m = [int(e) for e in input().split()]
    A = [int(e) for e in input().split()]

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

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import sys

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

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

maxi = n - sum(nums)
print(max(-1, maxi))

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

Solution (Python):
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N, M = map(int, input().split())
    A = map(int, input().split())

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


main()

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

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


def 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)


main()

Solution (Python):
N, M = map(int, input().split())

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

Sum = sum(int_list)


if Sum > N:
    print("-1")
else:
    print(N - Sum)

Solution (Python):
n, m = map(int, input().split())
a = [int(_) for _ in input().split()]
aa = sum(a)
if n < aa:
    print(-1)
else:
    print(n-aa)

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

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

Solution (Python):
a,b=map(int,input().split())
c=list(map(int,input().split()))
for i in range(b):
    a-=c[i]
if a<0:
    print(-1)
else:
    print(a)

Solution (Python):
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)

Solution (Python):
N,M=map(int,input().split())
A=list(map(int,input().split()))
ans=N-sum(A)

print(ans if ans>=0 else -1)

Solution (Python):
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)

Solution (Python):
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")

Solution (Python):
a=list(input().split(" "))
N=int(a[0])
M=int(a[1])

A=list(input().split(" "))
A = [int(i) for i in A]
goukei=0
for i in range(len(A)):
    goukei+=A[i]

if N-goukei >= 0:
    print(N-goukei)
else:
    print(-1)

Solution (Python):
N,M=map(int,input().split())
A=list(map(int,input().split()))
sum=0
for index, day in enumerate(A):
    sum=day+sum
if sum>N:
    print(-1)
else:
    print(N-sum)

Solution (Python):
a, b = map(int, input().split())
c = list(map(int, input().split()))

sums = 0
for i in c:sums+=i
if(sums > a):print(-1)
else:print(a-sums)

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

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

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

Solution (Python):
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)

Solution (Python):


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

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

Solution (Python):
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)

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

day = 0
for i in a:
    day += i

if n >= day:
    print(n - day)
else:
    print(-1)

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

Solution (Python):
n,m=map(int,input().split())
s=sum(list(map(int,input().split())))
if n>=s:
    print(n-s)
else:print(-1)

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

if n < hw:
    print(-1)
else:
    print(n-hw)

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

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

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

if m < 0:
    m = -1

print(m)

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

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

Solution (Python):
num=input().split(" ")
days=int(num[0])
homework=int(num[1])

sum=0
num=input().split(" ")
for i in range(homework):
    sum+=int(num[i])

if days<sum:
    print(-1)
else:
    print(days-sum)

Solution (Python):
N, M = map(int, input().split())
l = list(map(int, input().split()))
r = [int(i) for i in l]
if N - sum(r) < 0:
    print("-1")
else:
    print(N - sum(r))

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

if N -sum(A) >= 0:
    print(N - sum(A))
else:
    print(-1)

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

total = sum(A)
ans = N-total

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

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

Solution (Python):
N,M = map(int, input().split())
a   = list(map(int, input().split()))

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

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

Solution (Python):
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))

Solution (Python):
n,m=map(int,input().split())
l=[int(i) for i in input().split()]
s=sum(l)
print(max(-1,n-s))

Solution (Python):
n, m = map(int, input().split())
A = list(map(int, input().split())) 
ans = sum(A)

if ans > n:
    ans = -1
else:
    ans = n - ans

print(ans)

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

Solution (Python):

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

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


s = N - sum(A)

if s >= 0:
    ans = s
else:
    ans = -1


print(ans)

Solution (Python):
N, M = map(int,input().split())
A = list(map(int,input().split()))
S = 0
for i in range(0,M):
    S += A[i]
if N >= S:
    print(N-S)
else:
    print(int(-1))

Solution (Python):
n, m = [int(x) for x in input().split()]
a_list = [int(x) for x in input().split()]

temp = n - sum(a_list)
ans = temp if temp >= 0 else -1
print(ans)

Solution (Python):
def homework(n, al):
    for a in al:
        n -= a
    if n>=0:
        print(n)
    else:
        print(-1)

n,m = [int(i) for i in input().split()]
al = [int(i) for i in input().split()]

homework(n, al)

Solution (Python):
n,k,*a,=map(int,open(0).read().split());print(max(-1,n-sum(a)))

Solution (Python):
import math
n, m = list(map(int, input().split()))
time = list(map(int, input().split()))

temp =n - sum(time)
if temp >= 0:
    print(temp)
else:
    print(-1)

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

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

print(N - sum(A) if N>=sum(A) else -1)

Solution (Python):
li0 = list(map(int, input().split()))
li1 = list(map(int, input().split()))
d = li0[0] - sum(li1)
if d >= 0:
    print(d)
else:
    print("-1")

Solution (Python):
def mapint_inp():
    return map(int, input().split())

def intinp():
    return int(input())

N, M = mapint_inp()
A = list(mapint_inp())


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

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

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

Solution (Python):
N, M = map(int, input().split())
A=list(map(int,input().split()))
count=0
for i in range(M):
    count+=A[i]
if count>N:
    print(-1)
else:
    print(N-count)

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

Solution (Python):
import sys, re
import math
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul	
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd	
from heapq import heappush, heappop

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7




n, m = MAP()
a = LIST()

for x in a:
    n -= x

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

Solution (Python):
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)

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

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

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

Solution (Python):
N, M = map(int, input().split())
A = list(map(int, input().split()))
sum_ = sum(A)

ret = max( N - sum_, -1)
print(ret)

Solution (Python):
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)

Solution (Python):
N, M = map(int, input().split())
A_list = list(map(int, input().split()))
total =  sum(A_list)
if N >= sum(A_list):
    print(N-sum(A_list))
else:
    print(-1)

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


total_days = 0

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

if total_days > N:
    print(-1)
else:
    print(N - total_days)

Solution (Python):
N , M = map(int, input().split())
A = list(map(int, input().split()))
task = 0
for i in range(M):
  task = task + A[i]
ans = N - task
if task > N:
  ans = -1
print(ans)

Solution (Python):
N,M=(int(x) for x in input().split())
As=[int(x) for x in input().split()]
A=sum(As)
if N<A:
    print(-1)
else:
    print(N-A)

Solution (Python):
N, M = (int(x) for x in input().split())
A = [int(x) for x in input().split()]
if sum(A) > N:
	print(-1)
else:
	print(N - sum(A))

Solution (Python):
import sys
from math import pi



Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()
 
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
INF = 10 ** 18
MOD = 998244353



n,k  =Ri()
a = Ri()
summ = sum(a)
if summ > n : 
    print(-1)
else:
    print(n-summ)

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

Solution (Python):
import numpy as np
N,M = (int(x) for x in input().split())
A = [int(x) for x in input().split()]

if N-np.sum(A) < 0:
    print('-1')
else:
    print(N-np.sum(A))

Solution (Python):

n, m = [int(x) for x in input().split()]
As = [int(x) for x in input().split()]
s = 0
for a in As:
    s += a
ans = n - s if (n - s) >= 0 else -1
print(ans)

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

if N-sum(A)<0:
  print(-1)
else:
  print(N-sum(A))

Solution (Python):
import sys, math

a, b = map(int, sys.stdin.readline().split())
nums = map(int, sys.stdin.readline().split())
res = a - sum(nums)
if res < 0:
    res = -1

print(res)

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

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

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

if sum(a) <= n:
    print(n - sum(a))
else:
    print(-1)

Solution (Python):
n, m = map(int, input().split())
lis = list(map(int, input().split()))
b = sum(lis)
if b > n:
    print(-1)
else:
    print(n - b)

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

totalWorkDays = sum(a)


if totalWorkDays > n:
	print(-1)
else:
	print(n-totalWorkDays)

Solution (Python):
n,m = map(int,input().split())
line = list(map(int,input().split()))
summ = sum(line)
ans = n - summ
if ans >= 0:
  print(ans)
else:
  print("-1")

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

Solution (Python):
def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    rest = N - sum(A)
    if rest < 0:
        print(-1)
    else:
        print(rest)

if __name__ == '__main__':
    main()

Solution (Python):

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

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

s = sum(A)
if N>=s:
    print(N-s)
else:
    print(-1)

Solution (Python):
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)

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

tot = sum(A)
if tot > N:
    print(-1)
else:
    print(N-tot)

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

if N-sum(A)>=0:
    print(N-sum(A))
else:
    print(-1)

Solution (Python):
n, m = map(int, input().split())
a = map(int, input().split())

sm = sum(a)

if sm > n:
    print(-1)
else:
    print(n - sm)

Solution (Python):
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))

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

Solution (Python):
N, M = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

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

Solution (Python):
a,b =map(int,input().split())
x=list(map(int,input().split()))
ans=sum(x)
res=a-ans
if res<0:
    print(-1)
else:
    print(res)

Solution (Python):

import sys


def solve(N: int, M: int, A: "List[int]"):
    day = 0
    for i in range(0, M):
        day += A[i]
    
    res = N - day
    if res < 0:
        print(-1)
        return
    print(res)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    M = int(next(tokens))  
    A = [int(next(tokens)) for _ in range(M)]  
    solve(N, M, A)

if __name__ == '__main__':
    main()

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

Solution (Python):


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()))
    s = sum(a)
    if s > n:
        print(-1)
    else:
        print(n-s)


if __name__ == "__main__":
    try:
        IOE()
    except:
        pass
    main()

Solution (Python):
N,M=map(int,input().split())
A=list(map(int,input().split()))
ans=0

a=sum(A)
if a>N:
    print(-1)
else:
    ans=N-a
    print(ans)

Solution (Python):
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)
resolve()

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

x = N-(sum(A))

print(-1 if x < 0 else x)

Solution (Python):
def main():
    d, m = tuple([int(e) for e in input().split(' ')])
    d1 = sum([int(e) for e in input().split(' ')])
    if d1 <= d:
        print(d - d1)
    else:
        print('-1')
    return 0

main()

Solution (Python):


import sys
import math
import time

import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools










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

Solution (Python):
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)

Solution (Python):
base = input().split()
n = int(base[0])
m = int(base[1])
hw = input().split()
hw0 = []
for i in hw:
    hw0.append(int(i))
x = sum(hw0)
if x > n:
    print(-1)
else:
    print(n-x)

Solution (Python):
def i(): return [int(x) for x in input().split()]
n,m = i()
c = sum(i())
print(n-c if n>=c else -1)

Solution (Python):
n, m = map(int, input().split())
A = list(map(int, input().split()))

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

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

Solution (Python):

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


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

for i in a:
    N -= i

if N < 0:
    print(-1)
else:
    print(N)

Solution (Python):
N,M=map(int,input().split())
mylist=list(map(int,input().split()))

if sum(mylist)>N:
    print(-1)
else:
    print(N-sum(mylist))

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

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

res = N - sum(A)
if res < 0:
    res = -1
    
print(res)

Solution (Python):

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

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

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

L=sum(A)
if L>N:
    print(-1)
else:
    print(N-L)

Solution (Python):
n, m = map(int, input().strip().split())
sum_a = sum(map(int, input().strip().split()))
ans = n - sum_a
if ans >= 0:
    print(ans)
else:
    print(-1)

Solution (Python):
N,M = map(int,input().split())

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

sumA =  sum(A)

if sumA <= N:
    print(N-sumA)
else:
    print(-1)

Solution (Python):
def main():
    n, m = map(int, input().split())
    a = [int(i) for i in input().split()]
    a.sort(reverse=True)
    for i in range(m):
        n -= a[i]
        if n < 0:
            print(-1)
            return       
    print(n) 
main()

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

Solution (Python):
import math
n,m=list(map(int,input().split()))
a=list(map(int,input().split()))
ans=max(-1,n-sum(a))
print(ans)

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

Solution (Python):

def main():
    N,M = map(int,input().split())
    A = [int(i) for i in input().split()]
    for i in A:
        N -= i
    if N < 0:
        print('-1')
    else:
        print(N)
if __name__ == '__main__':
    main()

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

hw = sum(a)

if n - hw < 0:
    print(-1)
else:
    print(n - hw)

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

ans = N - sum(A)
if ans < 0:
    print(-1)
else: 
    print(ans)

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

if sum(a) > n:
    print("-1")
else:
    print(n-sum(a))

Solution (Python):
N, M = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
if N < sum(a):
    print(-1)
else:
    print(N - sum(a))

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

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

ttt = n - sum(a)

if ttt < 0:
    print(-1)
else:
    print(ttt)

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


result = ''
for days in A:
    N = N - days
    if N < 0:
        N = -1
        break

print(N)

Solution (Python):
import sys
input = lambda: sys.stdin.readline().rstrip()
inp = sys.stdin.buffer.readline                                
def I(): return list(map(int,inp().split()))

n,m=I()
a=I()
print(max(-1,n-sum(a)))

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

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

Solution (Python):




import sys
input = sys.stdin.readline



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

    res = N

    for i in range(M):
        res -= A[i]
        if res < 0:
            res = -1
            break

    print(res)



main()

Solution (Python):

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

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

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

Solution (Python):
a,b = map(int,input().split())
L= list(map(int, input().split()))
sum1 =0
for i in range(b):
    sum1 += L[i]
print(a-sum1 if a-sum1 >= 0 else -1)

Solution (Python):
n, m = list(map(int, input().split()))

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

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

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

Solution (Python):
N, M  = input().split()
A = input().split()

N = int(N)
M = int(M)
S = sum([int(a) for a in A], 0)
if N >= S:
    print(N - S)
else:
    print(-1)

Solution (Python):
n, m = map(int, input().split())
a_map = map(int, input().split())
print(max(-1, n - sum(a_map)))

Solution (Python):
n,m = (int(x) for x in input().split())

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

day = n - sum(a_list)

if day < 0:
  print(-1)
else:
  print(day)

Solution (Python):


from pprint import pprint
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.buffer.readline

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

if sum(a) > n:
    print('-1')
else:
    print(n - sum(a))

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

Solution (Python):
N, M = list(map(int, input().split()))
ARR = list(map(int, input().split()))

total = sum(ARR)

print(max(-1,N-total))

Solution (Python):
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()

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

if sum(A) > N:
    print(-1)
else:
    print(N - sum(A))

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

ans = N - sum(A)
if ans >= 0:
  print(ans)
else:
  print(-1)

Solution (Python):
import bisect
import collections
import sys

sys.setrecursionlimit(100000)
input = sys.stdin.readline
ACMOD = 1000000007
INF = 1 << 62


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


def llmi(n):
    return [lmi() for _ in range(n)]


N, M = lmi()

A = lmi()

x = N - sum(A)
if x >= 0:
    print(x)
else:
    print(-1)

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

if N-sum(A) >= 0:
	print(N-sum(A))
else:
	print(-1)

Solution (Python):
N,M=map(int,input().split())
K=input().split()
s=[]
for i in K:
    s.append(int(i))
if N-sum(s)>=0:
    print(N-sum(s))
else:
    print(-1)