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

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

mylist = list(map(int,input().split()))
mysum = sum(mylist)

if mysum > M:
    print(-1)
else:
    print(M-mysum)

Solution (Python):
i = list(map(int,input().split()))
work = list(map(int,input().split()))
day = i[0]
sumwork = sum(work)
play = day-sumwork
if play < 0:
	print(-1)
else:
	print(play)

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):
def slove(n, a):
    tmp = sum(a)
    if n < tmp:
        return -1
    else:
        return n - tmp
    return ans

if __name__ == "__main__":
    n, m = [int(i) for i in input().split()]
    a_list = [int(i) for i in input().split()]
    print(slove(n, a_list))

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

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

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

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

Solution (Python):

import sys
input = sys.stdin.buffer.readline


from collections import defaultdict

con = 10 ** 9 + 7

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


def main():
	N, M = getlist()
	A = getlist()
	s = sum(A)
	if N >= s:
		print(N - s)
	else:
		print(-1)
	


if __name__ == '__main__':
	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):
N,M = map(int,input().split())
A = [int(x) for x in input().split()]

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

Solution (Python):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip() 

def main():
    n,m = na()
    a = na()
    ans = n - sum(a)
    if ans < 0:
        print(-1)
        return
    print(ans)
    return


if __name__ == '__main__':
    main()

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

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):
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1

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

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

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

s = sum(A)
ans = N-s
if ans >= 0:
  print(ans)
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()))
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()))

sum_A = sum(A)

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

else:
    play = N - sum_A
    print(play)

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

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

answer = n-sum(a_list)
if answer < 0:
    print(-1)
else:
    print(answer)

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

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

amount = sum(arr)
ret = n-amount
if ret < 0:
    print(-1)
else:
    print(ret)

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

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

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

else:
    print(n - wa)

Solution (Python):
n, m = (int(x) for x in input().split())
seq = sorted([int(x) for x in input().split()])
print(max(-1, n-sum(seq)))

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

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

Solution (Python):

import sys
input = sys.stdin.readline





def main():
    n, m = map(int, input().split())
    A = list(map(int, input().split()))
    a = 0
    for i in range(m): 
        a += A[i]
    ans = n - a
    if ans >= 0:
        print(ans)
    else:
        print(-1)
    
if __name__ == '__main__':
    main()

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

Solution (Python):


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

    for b in a:
        n -= b

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

if __name__ == '__main__':
    main()

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

Solution (Python):
def main(n,m,a):
    d = sum(a)
    res = n-d
    return res if res >= 0 else -1

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

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

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

Solution (Python):
import sys
sys.setrecursionlimit(10**9)

INF = 110110110
_INFL = -INF * INF

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

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

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

n, m = map(int, input().split())
A = [int(a) for a in input().split()]
A_sum = sum(A)

amari = n - A_sum
if amari < 0:
    print("-1")
else:
    print(amari)

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

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

Solution (Python):


N, M = list(map(int,input().split()))
a = [int(_) for _ in input().split()]
sum = sum(a)

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

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

if __name__ == "__main__":
    main()

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

Solution (Python):
n,m = map(int,input().split())
a = sum(list(map(int,input().split())))
if n -a >= 0:
  print(n-a)
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=list(map(int,input().split()))
s=sum(a)
print(max(n-s,-1))

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,M=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__':
    main()

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

Solution (Python):
n, m = [int(x) for x in input().strip().split()]
a = [int(x) for x in input().strip().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()))
ans = n - sum(A)

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

Solution (Python):
n, m = map(int, input().split())
a = 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_a = sum(a)
print(n - sum_a if n - sum_a >= 0 else -1)

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

ans = n - sum(ai)

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

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

a = sum(A)

res = 0

if a > N:
    res = -1
else:
    res = N - a

print(res)

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

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

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

total = N - sum(map(int, input().strip().split()))
if total >= 0:
	print(total)
else:
	print(-1)

Solution (Python):

''':'
docker run --rm -it -v $(cd $(dirname $0) && pwd):/vo:ro pypy:3-2.4.0 \
   /bin/bash -c "pypy3 /vo/$(basename $0) < /vo/input.txt"
exit $?
'''
import sys


def _ia(): return map(int, sys.stdin.readline().strip().split())


def main():
    n, _ = _ia()
    tot = sum(_ia())
    return max([n-tot, -1])


if __name__ == "__main__":
    print(main())

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()))
H = 0
for i in range(0,len(A)):
    H = H + A[i]
if H <= N:
    print(N-H)
else:
    print(-1)

Solution (Python):
import math

if __name__ == "__main__":
    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()))

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

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

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

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

s=sum(a)

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

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

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

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

sum_ = sum(A)

if sum_ > N:
    print(-1)
else:
    answer = N - sum_
    print(answer)

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()))
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()))
h = sum(A)
ans = n-h
print(max(ans,-1))

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

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

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

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


if __name__ == "__main__":
    main()

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

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

hw = sum(A)

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

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

b = sum(a)

c = max(n - b, -1)

print(c)

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

homework_date = sum(aa)
play_date = n - homework_date

if play_date >= 0:
    print(play_date)
else:
    print('-1')

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


def ZIP(n): return zip(*(MAP() for _ in range(n)))


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


def main():
    n, m = MAP()
    a = LIST()
    print(max(n - sum(a), -1))


if __name__ == '__main__':
    main()

Solution (Python):

import numpy as np
n, m = map(int, input().split())
li = list(map(int, input().split()))
ans=n-sum(li)
if ans>=0:
    print(ans)
else:
    print('-1')

Solution (Python):
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial
from bisect import bisect_left 
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

N, K = 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 = [int(i) for i in input().split()] 
ans = n - sum(nums)
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=[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())
a = list(map(int, input().split()))

import numpy as np
a = np.array(a)
s = a.sum()
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()))

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

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 6)  
to_index = lambda x: int(x) - 1  
print_list_in_2D = lambda x: print(*x, sep="\n")  


def input_int(): return int(input())

def map_int_input(): return map(int, input())

MII = map_int_input

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

def MII_to_index(): return map(to_index, input())

def MII_split_to_index(): return map(to_index, input().split())


def list_int_inputs(): return list(map(int, input()))

LII = list_int_inputs

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


def LII_2D(rows_number): return [LII() for _ in range(rows_number)]

def LII_split_2D(rows_number): return [LII_split() for _ in range(rows_number)]

N, M = MII_split()
As = LII_split()

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

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

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

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

Solution (Python):
"""
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)


inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""
from collections import Counter
import math
import sys
sys.setrecursionlimit(10 ** 7)


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



def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]


def ws(): return sys.stdin.readline().split()


def si(): return int(sys.stdin.readline())  


def ss(): return input()


def hi(n): return [si() for _ in range(n)]


def hs(n): return [ss() for _ in range(n)]  


def s_list(): return list(input())


def mi(n): return [wi() for _ in range(n)]  


def mip(n): return [wip() for _ in range(n)]


def ms(n): return [ws() for _ in range(n)]


def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[
    0]] for _ in range(n)]  


def grid(n): return [s_list() for _ in range(n)]


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    """a,bの最小公倍数"""
    return a * b // gcd(a, b)


def main():
    N, M = wi()
    A = wi()
    a = sum(A)
    if a <= N:
        print(N-a)
    else:
        print(-1)


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):
import math
import fractions
import sys
import itertools
import numpy as np
from collections import Counter
import datetime

def input1():
	return int(input())


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


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

def keta(N):
	return len(str(N))


def input_daytime(input_time):
	time,distance=input_time.split()
	t=time.split(":")
	se=str(t[-1]).split(".")
	dt1 = datetime.timedelta(hours=int(t[0]),minutes=int(t[1]),seconds=int(se[0]),milliseconds=int(se[1]))
	return dt1

def combinations(n,r):
	return list(itertools.combinations(n,r))




n,m=input2()
A=input_array()

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

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

result = N - sum(A)

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

Solution (Python):

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

Solution (Python):
N,M = map(int,input().split())
li = list(map(int,input().split()))
if N>=sum(li):
    print(N-sum(li))
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 = [int(str) for str in input().strip().split()]
A = [int(str) for str in input().strip().split()]

nissu = sum(A)

print(N - nissu if N >= nissu else -1)

Solution (Python):
import sys 
import math
try:
	sys.stdin = open('input.txt', 'r') 
	sys.stdout = open('output.txt', 'w')
except:
	pass
input = sys.stdin.readline
for tt in range(1):
	
	n,m = map(int,input().split())
	l = list(map(int,input().split()))
	print(-1 if sum(l)>n else n-sum(l))

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

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

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

Solution (Python):
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

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

print(-1 if S > N else N - S)

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

if n < sum(a_lst):
    print(-1)
else:
    print(n-sum(a_lst))

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

sum_A = 0
for i in A:
  sum_A += i
else:
  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 N < sum(A): print(-1)
else: print(N - sum(A))

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

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

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

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

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):
import sys
input = sys.stdin.readline
N,M = map(int,input().split())
A= list(map(int,input().split()))
a=0
for i in range(M):
 a+=A[i]
print(max(N-a,-1))

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

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

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

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

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

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):
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):
import sys
input = sys.stdin.readline

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

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

Solution (Python):
day,enemy=map(int,input().split())
li = list(map(int,input().split()))
Q=sum(li)
if Q>day:
    print(-1)
else:
    print(day-Q)

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

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

ALLWORK =sum(H)

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

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

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

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

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()))
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(map(int, input().split()))
print(max(-1, n - sum(a)))

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

total = sum(data)

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

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

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

Solution (Python):
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    N, M = lr()
    A = lr()
    s = sum(A)
    print(max(-1, N-s))
resolve()

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

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

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

Solution (Python):
a=input().split(" ")
n=int(a[0])
s=input().split(" ")

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

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

Solution (Python):
t=1

for _ in range(t):
    m,n = map(int,input().split(' '))
    ls = list(map(int,input().split(' ')))
    tt = sum(ls)
    m = m-tt
    if(m<0):
        print(-1)
    else:
        print(m)

Solution (Python):


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

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

Solution (Python):
def resolve():
    n,m=map(int,input().split())
    a=list(map(int,input().split()))
    total=0
    for i in a:
        total+=i
    if n<total:
        print(-1)
    else:
        print(n-total)
resolve()

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

def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())

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

def LLI(rows_number): return [LI() for _ in range(rows_number)]

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

Solution (Python):
N,M=map(int,input().split())
A=list(map(int,input().split()))
a=0
for i in range(M):
    a+=A[i]
ans=N-a
if ans>=0:
    print(ans)
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):
n, m = map(int, input().split())

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

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