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 = list(map(int, input().split(' ')))
am = list(map(int, input().split(' ')))

r = n - sum(am)

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

Solution (Python):
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,m = mi()
a = li()

ans = n-sum(a)

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

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

    summary = sum(A)
    left = n - summary
    if left < 0:
        print(-1)
    else:
        print(left)


if __name__ == '__main__':
    main()

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

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

Solution (Python):
import numpy as np

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

sum=0
for i in range(m):
	sum += a[i]
    
if sum>n:
	print("-1")
else:
	print(n-sum)

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

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

w = sum(a)

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

Solution (Python):
import math

(n, m) = [int(s) for s in input().split()]
a = [int(s) for s in input().split()]

b = sum(a)

ans = n - b if (n - b) >= 0 else -1

print(ans)

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

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

total = sum(a)
if total > n:
    print(-1)
    sys.exit(0)

print(n - total)

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

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

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):
import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

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

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

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

ans = n - sum([int(i) for i in input().split()])
if ans < 0:
    print(-1)
else:
    print(ans)

Solution (Python):




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

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

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

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

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

Solution (Python):
N, M = map(int, input().split())
require_days = sum(map(int, input().split()))
remaining = N-require_days
print(max(remaining, -1))

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

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

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

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

Solution (Python):

import math
import sys
input = sys.stdin.readline


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

    total = 0
    for i in range(m):
        total += a[i]

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


if __name__ == '__main__':
    main()

Solution (Python):
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True 
BIG = 10**18
R = 10**9 + 7

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

n,m = inm()
a = inl()
sm = sum(a)
x = n - sm
if x>=0:
    print(x)
else:
    print(-1)

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

sum_a = 0
for ai in a:
    sum_a += ai

result = n - sum_a
if result < 0:
    print(-1)
else:
    print(result)

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):
n, m = map(int, input().split())
a = list(map(int, input().split()))
print((n-sum(a)) if n >= sum(a) else -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())
lst = list(map(int, input().split()))

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

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

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

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

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,M=MI()
    A=LI()
    for i in range(M):
        N-=A[i]
        
    print(max(N,-1))

main()

Solution (Python):
[n,m] = list(map(int, input().strip().split()))
arr = list(map(int, input().strip().split()))

s = sum(arr)

if s <= n:
  print(n-s)
else:
  print(-1)

Solution (Python):










import math
import numpy as np
import statistics
import string
import sys
from array import array
from collections import deque
from functools import wraps
import time

def intinput():
    return int(input())
def listintinput():
    return list(map(int, input().split()))
def splitintinput():
    return map(int, input().split())
def factorialsurplus(x, y, z):  
    ret = 1
    for i in range(x, y + 1):
        ret = (ret * i) % z
    return (ret)
def isprime(x):
    if x == 1:
        return False
    if x == 2:
        return True
    sq = int(math.sqrt(x))
    for i in range(2,sq+1):
        if x % i == 0:
            return False
    return True
def hcfnaive(a,b):
    if(b==0):
        return a
    else:
        return hcfnaive(b,a%b)

N, M = splitintinput()
A = listintinput()

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

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,m=map(int,input().split())
    A=[int(_) for _ in input().split()]
    sum_a=sum(A)
    if sum_a>n:
        print(-1)
    else:
        print(n-sum_a)

if __name__=='__main__':
    main()

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


if __name__ == "__main__":
    main()

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

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

result = N - sum(A)

if result > -1:
  print(result)
else:
  print(-1)

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

for a in A: N -= a
print(N if N >= 0 else -1)

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

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

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

Solution (Python):
a,b=map(int,input().split())
nums=list(map(int,input().split()))
ans=a-sum(nums)
if ans>=0:
    print(ans)
else:
    print('-1')

Solution (Python):
import math
import queue

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

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

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


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

x = sum(a)

if x<=n:
	print(n-x)
else:
	print(-1)

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

Solution (Python):
N, K = 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()))

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

Solution (Python):
N, M = list(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()))

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

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

Solution (Python):
N, M = map(int, input().split())
A_list = [int(i) for i in input().split()]

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

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

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

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

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

ans=N-sum(A)

if ans < 0 :
    ans = -1

print(ans)

Solution (Python):
n,m=list(map(int,input().split()))
H = list(map(int,input().split()))
ans = n
for i in H:
    ans -= i
if ans<0:
    print("-1")
else:print(ans)

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

Solution (Python):
def main(n: int, m: int, a: list) -> None:
    s = sum(a)

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


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

    main(n, m, 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):
n, m = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

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

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

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

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

for i in L:
    N = N - i

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

Solution (Python):


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


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

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

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

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

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

total = 0
for a in a_l:
    total += a

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

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

sum_a = sum(A)

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

Solution (Python):
import time
startTimeProblem=time.time()

import fileinput, sys, itertools
from math import *
from bisect import *
from heapq import *
from collections import *

def lcm(a, b):  
    return (a*b)/gcd(a, b)

class InputHelper:
    def __init__(self):
        self.myinput = fileinput.input()

    def isLocal(self):
        return not fileinput.isstdin()

    def int(self):
        return int(self.myinput.readline().rstrip())

    def ints(self):
        return [int(_) for _ in self.myinput.readline().rstrip().split()]

    def str(self):
        return self.myinput.readline().rstrip()

    def strs(self):
        return [_ for _ in self.myinput.readline().rstrip().split()]

class OutputHelper:
    def int(self, a):
        print(a)    

    def ints(self, a):  
        print(" ".join([str(_) for _ in a]))
    
    def intsNL(self, a):
        for _ in a:
            print(_)
    
    def str(self, s):
        print(s)

    def strs(self, s):
        print(" ".join([_ for _ in s]))

    def strsNL(self, s):
        for st in s:
            print(st)

class ListNode:
    def __init__(self, val):
        self.val = val
        self.next = None
        self.prev = None

In = InputHelper()
Out = OutputHelper()



N, M = In.ints()
A = In.ints()

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

Out.int(res)




if len(sys.argv)>2 and sys.argv[2]=="TIMEIT":
    fin = (time.time()-startTimeProblem)*1000
    print("{:.2f}".format(fin) + "ms")

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

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

t = 0

for i in A:
    t += i

a = N - t

if a<0:
    print("-1")
else:
    print(a)

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

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

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

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

sum = 0

for i in range(m):
    sum += a[i]

ans = n - sum
if ans < 0:
    print("-1")
else:
    print(ans)

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 = 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()))

sumA = sum(A)

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

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

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

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

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

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

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

Solution (Python):
def main():
    N, _ = [int(x) for x in input().split()]
    A_sum = sum([int(x) for x in input().split()])
    diff = N - A_sum
    if diff >= 0:
        print(diff)
    else:
        print(-1)

if __name__ == "__main__":
    main()

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

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

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

d = a - sum(c)


if d < 0 :
    print("-1")
else:
    print(d)

Solution (Python):




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


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





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

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

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

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

Solution (Python):

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

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

Solution (Python):
N, M = map(int, input().split())
As = [int(i) for i in input().split()]

task_day = sum(As)

if task_day <= N:
    print(N-task_day)
else:
    print('-1')

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

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

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

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

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

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

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

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

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

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

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

Solution (Python):
n, m = map(int, input().split())
sum_a = sum(map(int, input().split()))
print(max(n - sum_a, -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):
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007



def main():
	
	b , c = IN()
	al=list(IN())
	a=b-sum(al)
	ret = a if a >= 0 else -1
	return ret
	
	
	
	

isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		
			
	ret = main()
	if ret is not None:
		print(ret)

Solution (Python):
import numpy as np

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

ans = -1 if n < np.sum(a) else n - np.sum(a)
print(ans)

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

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

Solution (Python):


import sys

DEBUG = False

def read(t):
    return t(sys.stdin.readline().rstrip())


def read_list(t, sep = " "):
    return [t(s) for s in sys.stdin.readline().rstrip().split(sep)]


def dprint(*args, **kwargs):
    if DEBUG:
        print(*args, **kwargs)
    return


def main():
    n, m = read_list(int)
    a = read_list(int)
    work_days = sum(a)
    if work_days > n:
        print("-1")
        return
    print(n - work_days)


if __name__ == "__main__":
    main()

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

Solution (Python):
N, M = list(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) < 0:
    print(-1)
else:
    print(N - sum(A))

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

p = sum(lst)

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

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

Solution (Python):
import sys
sys.setrecursionlimit(1000000)

def solve(N, M , A):
    s = sum(A)
    if N - s < 0:
        return -1
    return N - s

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

    print(solve(N, M, A))

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())
li = list(map(int, input().split()))
wa = sum(li)
if wa > n:
    print(-1)
elif wa == n:
    print(0)
else:
    print(n-wa)

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

Solution (Python):
n,m = map(int,input().split())
r = n - sum(int(x) for x in input().split())
print(-1 if r < 0 else r)

Solution (Python):

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

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

ans = 0

if n < sum(a_list) :
    ans = -1
else :
    ans = n - sum(a_list)

print(ans)

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

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

print(N-sum(A))

Solution (Python):
import sys
import re
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
from functools import reduce
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()

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

Solution (Python):
n, m, *a = map(int, open(0).read().split())
num = sum(a)

if num <= n:
    print(n - num)
else:
    print(-1)

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

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

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

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

Solution (Python):
N,M = list(map(lambda x: int(x), input().split()))
A_list = list(map(lambda x: int(x), input().split()))

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

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

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

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

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



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

for i in range(M):
    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()))

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()))
s=sum(A)
print(N-s if N>=s else -1)

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

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

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

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

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

Solution (Python):
import numpy as np
import math as mt
N,M=map(int, input().split())
A=list(map(int,input().split()))
day=N-sum(A)
if day<0:
    print(-1)
else:
    print(day)

Solution (Python):
i = input()
j = input()
lista = i.split()
listb = j.split()
nokori = int(lista[0])
for i in range(int(lista[1])):
    nokori -= int(listb[i])
if nokori >= 0:
    print(nokori)
else:
    print(-1)

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

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

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

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