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

from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")


def solve():
    n, m = LI()
    a = LI()
    a = sum(a)
    print(-1 if a > n else n - a)
    return



if __name__ == '__main__':
    solve()

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()))
x=n-sum(a)
if(x>=0):
  print(x)
elif(x<0):
  print("-1")

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

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

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

Solution (Python):

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

sum = sum(A)
print(max([N-sum, -1]))

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

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

Solution (Python):
import numpy as np
import math
import scipy as sp
import queue
import collections

MOD = 10 ** 9 + 7
INF = 10 ** 9

def main(kwargs):
    n = kwargs["n"]
    m = kwargs["m"]
    A = kwargs["A"]
    res = max(-1, n - sum(A))
    return res

if __name__ == "__main__":
    kwargs = {}

    cin = input().split()
    
    
    
    kwargs["n"], kwargs["m"] = [int(i) for i in cin]
    cin = input().split()
    kwargs["A"] = [int(i) for i in cin]

    cout = main(kwargs)
    print(cout)

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

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

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

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

Solution (Python):
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 (N)
else:
	print (-1)

Solution (Python):


from sys import stdin, stderr

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

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

   return 0

if __name__ == '__main__': main()

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

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

Solution (Python):
from sys import stdin


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


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)

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

ans = max(n - sum(A), -1)

print(ans)

Solution (Python):

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


total=sum(al)
if total>n:
    ans=-1
else:
    ans=n-total
print(ans)

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()))
    print(max(-1,n-sum(a)))
    return

if __name__ == "__main__":
    main()

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

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

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

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

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

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

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

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

for i in range(M):
    cal+=home[i]


if cal>N:
    print("-1")
else :
    ans=N-cal
    print(ans)

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

a = [int(i) for i in 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()))

t = sum(a)

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

Solution (Python):
N, M = map(int, 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 = map(int,input().split())

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

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

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

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

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

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

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

LEISURE = N - sum(A)

if LEISURE >= 0:
    print(LEISURE)

else:
    print(-1)

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

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

Solution (Python):
N, M = map(int,input().split())
A = list(map(int, input().split()))
asoberu = N - sum(A)
if asoberu >= 0:
    print(asoberu)
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()))

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()))
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()))
for i in a:
    n -= i
    if n<0:
        print(-1)
        exit()
print(n)

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

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

Solution (Python):

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

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

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

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

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

if N-days>=0:
    print(N-days)
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 = list(map(int, input().split()))

ans = n - sum(a)
if ans <= -1:
    ans = -1

print(ans)

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

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

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

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

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

for v in A:
	n -= v

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

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

Solution (Python):
n,m =(int(x) for x in input().split())
s = 0
a = input('').split()
for j in range(m):
    s =s+ int(a[j])
if (n>=s):
    print(n-s)
else:
    print('-1')

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

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

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

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

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

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

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

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

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

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):
import sys
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n, m = na()
a = na()

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

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

s = sum(times)

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(n-sum(a),-1))

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

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

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


dxdy=((1,0),(0,1))

def pin(type=int):
    return map(type,input().rstrip().split())
from math import gcd


def resolve():
    N,M=pin()
    A=(pin())
    t=(N)-sum(A)
    
    ans=t if t>-1 else -1
    print(ans)

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """41 2
5 6"""
        output = """30"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """10 2
5 6"""
        output = """-1"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """11 2
5 6"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """314 15
9 26 5 35 8 9 79 3 23 8 46 2 6 43 3"""
        output = """9"""
        self.assertIO(input, output)


if __name__ == "__main__":
    


    resolve()

Solution (Python):
n, _ = list(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 = sum(list(map(int, input().split())))
if n >= a:
    print(n - a)
else:
    print("-1")

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

for i in range(m):
  eq+=lista[i]

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

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



def in_int():
    return (int(input()))


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


def in_str():
    s = input()
    return (list(s[:len(s) - 1]))


def in_ints():
    return (map(int, input().split()))

mod = 7 + 10**9

n, m = in_ints()

a = in_list()

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()]
rem = n-sum(a)
print(rem if rem>=0 else -1)

Solution (Python):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n, m = map(int,input().split())
    A = list(map(int,input().split()))
    res = n - sum(A)
    res = max(res, -1)
    print(res)
resolve()

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

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

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):
arr=list(map(int,input().rstrip().split()))
N=arr[0]
M=arr[1]
arr=list(map(int,input().rstrip().split()))
summ=0
for i in range(M) :
    summ+=arr[i]
if summ>N :
    print(-1)
else :
    print(N-summ)

Solution (Python):
Days,works=map(int,input().split())
Time=list(map(int,input().split()))
Daysum=int(0)
for i in range(works):
  Daysum+=Time[i]
if Daysum<=Days:
  print(Days-Daysum)
else :
  print(-1)

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

counter = 0

for i in A:
    counter += i

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

Solution (Python):
a1, b = [int(s) for s in input().split(" ")]
S=0
a= [int(s) for s in input().split(" ")]
for k in range(0,b):
    S=S+a[k]
if a1-S>= 0:
    print(a1-S)
else:
    print(-1)

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())
nums = map(int, input().split())
ans = n - sum(nums)
print(ans if ans >= 0 else -1)

Solution (Python):

"""
Created on Sun Apr 19 21:57:00 2020

@author: Kashem Pagla
"""


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

Solution (Python):
n,m,*l=[int(i) for i in open(0).read().split()]
print(max(-1,n-sum(l)))

Solution (Python):
a,b=map(int,input().split())
c=[int(x) for x in input().split()]
s=sum(c)
print(max(a-s,-1))

Solution (Python):
n,m,*a=map(int,open(0).read().split())
if (k:=n-sum(a))<0:print(-1)
else:print(k)

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

Solution (Python):
A,B=(int(x) for x in input().split())
S=list(map(int, input().split()))
C=sum(S)
if A>=C:
  print(A-C)
else:
  print(-1)

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


if __name__ == '__main__':
    solve()

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

Solution (Python):
n,k = [int(x) for x in input().strip().split()]
a = [int(x) for x in input().strip().split()]
print(max(-1, n - sum(a)))

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

for i in A:
    N -= i

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

Solution (Python):
a, _ =map(int,input().split())
li = [int(x) for x in input().split()]
s = sum(li)
print(max(a-s, -1))

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

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

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

d = sum(c)
if a > d:
  print(a-d)
elif a == d:
  print("0")
else:
  print("-1")

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

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

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

Solution (Python):
n,m=map(int,input().split())
A=list(map(int,input().split()))
for i in range(m):
    n-=A[i]
print(max([n,-1]))

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

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

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

Solution (Python):

from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,m = LI()
    a = LI()
    ans = n-sum(a)
    if ans < 0:
        print(-1)
    else:
        print(ans)
    return


if __name__ == "__main__":
    solve()

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

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

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

Solution (Python):
a,b=[int(i) for i in input().split()]
arr=[int(i) for i in input().split()]
print(max(a-sum(arr),-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 = (int(i) for i in input().split())

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

ans = N

for a in A:
  ans -= a

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

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

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

Solution (Python):
S,N=input().split()
p=input().split()
s=0
i=1
while(i<=int(N)):
    s=s+int(p[i-1])
    i=i+1
x=int(S)-s
if(x>=0):
    print(x)
else:
    print(-1)

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

Solution (Python):
n, m, *A = map(int, open(0).read().split())
ans = n-sum(A)
print(ans if ans >= 0 else -1)

Solution (Python):
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N,M = map(int, readline().split())
    A = [int(i) for i in readline().split()]

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


if __name__ == "__main__":
    main()

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

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

Solution (Python):
input_list = list(map(int, input().split(" ")))

n = input_list[0]
m = input_list[1]
a_i_list = list(map(int, input().split(" ")))


a_i_sum = sum(a_i_list)

result = n - a_i_sum

if result < 0:
    result = -1

print(result)

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

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

Solution (Python):
j=list(map(int,input().split())) 
n=j[0]
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())
A = list(map(int,input().split()))
free = n - sum(A)
if free < 0:
  print(-1)
else:
  print(free)

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

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

Solution (Python):
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    n, m = nm()
    a = nl()

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

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

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

c = sum(arr)

if a-c >=0:
  print(a-c)
else:
  print(-1)

Solution (Python):

def resolve():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    ans = N - sum(A)
    if ans < 0:
        print(-1)
    else:
        print(ans)


if __name__ == "__main__":
    resolve()

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

Solution (Python):
N, M = map(int, input().split())
A = list(map(int, input().split()))
days = 0
for a in A:
    days += a
result = N - days
if result < 0:
    print("-1")
else:  
    print(str(result))

Solution (Python):
if __name__ == "__main__":
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    ret = -1
    A_sum = sum(A)
    if not N - A_sum < 0:
        ret = N - A_sum
    print(int(ret))

Solution (Python):
i = list(map(int, input().split()))
s = list(map(int, input().split()))
N = i[0]
A = sum(s)
d = N - A
if d < 0:
  print("-1")
else:
  print(d)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, m, *a = map(int, read().split())
print(max(-1, n - sum(a)))

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

Solution (Python):
import math

def Next(): return input()
def NextInt(): return int(Next())
def NextInts(): return map(int,input().split())
def Nexts(): return map(str,input().split())
def NextIntList(): return list(map(int,input().split()))
def RowInts(n): return [input() for i in range(n)]

n,m = NextInts()
a = NextIntList()
ans = 0
for i in range(m):
    ans += a[i]
print(max(-1, n-ans))

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

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

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

if k-a >= 0:
    print(k - a)
else:
    print(-1)

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

Solution (Python):
import math
a=input().split()
n,m=int(a[0]),int(a[1])
f=list(map(int,input().split()))
s=0
fl=0
s=sum(f)
if(n>=s):
  print(n-s)
else:
  print("-1")

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

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

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

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

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

Solution (Python):

import sys


def solve(N: int, M: int, A: "List[int]"):
    a_sum = N
    for x in A:
        a_sum -= x

    if a_sum < 0:
        print(-1)
    else:
        print(a_sum)
    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()))
print('-1' if sum(a)>n else n-sum(a))

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

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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N, M = map(int, rl().split())
    A = list(map(int, rl().split()))
    
    ans = N - sum(A)
    print(ans if 0 <= ans else -1)


if __name__ == '__main__':
    solve()

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

Solution (Python):
(a,b) = input().split()

a = int (a)
b = int (b)

num_list =[]

num_list.extend(list(map(int,input().split())))

x = num_list
c = sum(x)

d = a - c

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

Solution (Python):
N,M = (input()).split()
task = input().split()
list1 = []
sum = 0
for i in task:
    list1.append(i)
for j in list1:
    sum = sum + int(j)
result = int(N) - sum
if result < 0:
    print(-1)
else:
    print(result)

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