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

import sys
input = sys.stdin.readline

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

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

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

sum_ = sum(A)

a = N - sum_

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

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

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

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

print(ans)

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

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


if __name__ == "__main__":
    resolve()

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

Solution (Python):

import sys


def solve(N: int, M: int, A: "List[int]"):
    s = sum(A)
    print(max(-1, N-s))
    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()))

s = sum(a)

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

Solution (Python):
import sys
from collections import *
import heapq
import math
from math import gcd
import bisect
import copy
from itertools import permutations,accumulate,combinations,product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

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):
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

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

Solution (Python):
def main():
    M,N=map(int,input().split())
    A=[int(_) for _ in input().split()]
    print(-1 if sum(A)>M else M-sum(A))
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()))

s = sum(a)

n -= s

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

Solution (Python):
import sys
from collections import deque
input = lambda: sys.stdin.readline().rstrip()
Yes = lambda boolean: print('Yes') if boolean else print('No')
YES = lambda boolean: print('YES') if boolean else print('NO')
aint = lambda: int(input())
ints = lambda: list(map(int, input().split()))
is_even = lambda x: True if x%2==0 else False
zeros2d = lambda r,c: [[0 for col in range(c)] for row in range(r)]

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

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

Solution (Python):

import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
from math import gcd
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') 
def lcm(a,b):return (a*b) // gcd(a,b) 
def iin(): return int(sys.stdin.readline()) 
def ifn(): return float(sys.stdin.readline()) 
def isn(): return sys.stdin.readline().split() 
def imn(): return map(int, sys.stdin.readline().split()) 
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) 
def fmn(): return map(float, sys.stdin.readline().split()) 
def iln(): return list(map(int, sys.stdin.readline().split())) 
def iln_s(): return sorted(iln()) 
def iln_r(): return sorted(iln(), reverse=True) 
def fln(): return list(map(float, sys.stdin.readline().split())) 
def join(l, s=''): return s.join(l) 
def perm(l, n): return itertools.permutations(l, n) 
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) 
def comb(l, n): return itertools.combinations(l, n) 
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) 
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 
def m_add(a,b): return (a+b) % MOD
def lprint(l): print(*l, sep='\n')
def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N,M = imn()
A = iln()

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

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

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

SUMA = sum(A)

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

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()

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

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

if __name__ == '__main__':
    main()

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(int(1E+7))
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())
Alist = list(map(int, input().split()))
A = sum(Alist)

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

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

Solution (Python):
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


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


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def debug(table, *args):
    ret = []
    for name, val in table.items():
        if val in args:
            ret.append('{}: {}'.format(name, val))
    print(' | '.join(ret), file=sys.stderr)


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False



def main():
    N, M = MI()
    A = LI()
    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()))

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

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

Solution (Python):
import sys
input = sys.stdin.readline
def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    SUM = sum(A)
    if N >= SUM:
        print(N-SUM)
    else:
        print(-1)

if __name__ == '__main__':
    main()

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

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

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

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

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

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

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

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

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

Solution (Python):


def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    

    
    

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

if __name__ == '__main__':
    main()

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

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

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

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):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque

from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [LI()for i in range(n)]




n,m=MI()
A=LI()
ans=max(n-sum(A),-1)
print(ans)

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N, M = LI()
    A = LI()
    if N < sum(A):
        print(-1)
    else:
        print(N - sum(A))

main()

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

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

print(n-suma if suma <= n else -1)

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

resolve()

Solution (Python):

def inputlist(): return [int(k) for k in input().split()]

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

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

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

sum = 0

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

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

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 = list(map(int,input().split()))
ans = n
for a in A:
    ans = ans-a
    if ans<0:
        print('-1')
        exit()
print(ans)

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

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

Solution (Python):


import sys
from itertools import accumulate

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

N, M = MAP()
A = LIST()

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

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

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

Solution (Python):

import sys
input = sys.stdin.readline


def answer(N,M,A):
    total = N
    for a in A:
        total -= a
    return total if(total >= 0) else -1

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

if __name__ == '__main__':
   main()

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

L  = list(map(int,input().split()))
S=sum(L)
if N-S>=0:
    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 = [int(i) for i in input().split()]
S = sum(A)
print(max(-1,N-S))

Solution (Python):



def inp():
    return(int(input().rstrip()))
def inlt():
    return(list(map(int,input().rstrip().split())))
def insr():
    s = input().rstrip()
    return(s[:len(s) - 1])
def invr():
    return(map(int,input().rstrip().split()))

n,m = invr()
nums = inlt()
s = sum(nums)
print(n - s if s <= n else -1)

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

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    print(max(-1, N-sum(A)))

if __name__ == '__main__':
    main()

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline

N, M, *A = map(int, read().split())
answer = N - sum(A)
if answer < 0:
    print(-1)
else:
    print(answer)

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

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

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


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

Solution (Python):
import sys
sys.setrecursionlimit(10**8)
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 li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]




N, M = mi()
A = li()

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)
if S > N:
    print(-1)
else:
    print(N - S)

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

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

    t = 0
    for x in a:
        t += x

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

if __name__ == '__main__':
    main()

Solution (Python):
import sys
import math

from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]
def exit():
    import sys
    sys.exit(0)
def perm_sub(li, used):
    if len(li) == len(used):
        return [deque()]
    k = []
    for i in range(len(li)):
        if i in used:
            continue
        used.add(i)
        sub_list = perm_sub(li, used)
        for sub in sub_list:
            sub.appendleft(li[i])
        k.extend(sub_list)
        used.discard(i)
    return k
def perm_li(li):
    return perm_sub(li, set())
def perm_n(n):
    return perm_sub(list(range(n)), set())
def join_i(li, sep=""):
    return sep.join([str(e) for e in li])
def li2n(li):
    n, base = 0, 1
    for i in range(len(li)-1, -1, -1):
        n += li[i] * base
        base *= 10
    return n
def sli2ili(li):
    return [int(s) for s in li] 
def prime_list(n):
    li = [i for i in range(2, n+1)]
    for i in range(len(li)):
        if li[i] >= int(math.sqrt(n)):
            break
        if li[i] == -1:
            continue
        for j in range(i+1, len(li)):
            if li[j] % li[i] == 0:
                li[j] = -1
    return [n for n in li if n != -1]
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while True:
        r = a % b
        if r == 0: return b
        a, b = b, r
def lcm(a, b):
    return int(a * b / gcd(a,b))
def all_subset(li):
    s = []
    n = len(li)
    for bit in range(0, (1<<(n+1))):
        ss = set()
        for i in range(0, n):
            if (bit & (1 << i)):
                ss.add(li[i])
        s.append(ss)
    return s
def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n-1)
def mCn(m, n):
    def factorial_ntimes(m, n):
        r = 1
        while n:
            r *= m
            m -= 1
            n -= 1
        return r
    return int(factorial_ntimes(m, n) / factorial(n))

n, m = load_list()

A = load_list()

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

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

fun = N - sum(AA)

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

Solution (Python):
import sys,os
from collections import defaultdict, deque
from math import ceil, floor
if sys.version_info[1] >= 5:
    from math import gcd
else:
    from fractions import gcd
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    MOD = 10**9+7

    

    N,M = LMIIS()
    A = LMIIS()
    if N - sum(A) < 0:
        print(-1)
    else:
        print(N-sum(A))
if __name__ == '__main__':
    main()

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):
'''بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ'''

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

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

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

Solution (Python):
from collections import *
import sys
try: inp = raw_input
except: inp = input
def err(s):
    sys.stderr.write('{}\n'.format(s))

def ni():
    return int(inp())

def nl():
    return [int(_) for _ in inp().split()]
N, M = nl()
A = nl()

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

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

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

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

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

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

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

Solution (Python):
import sys, bisect, math, itertools, string, queue, copy


from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd

sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    n,m = inpm()
    a = inpl()
    ans = n-sum(a)
    if ans >= 0:
        print(ans)
    else:
        print(-1)
    
if __name__ == "__main__":
    main()

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

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

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

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

Solution (Python):
import sys
import math
import collections
from collections import deque
from functools import reduce
import heapq

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

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

x = sum(a)

print(max(n-x, -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(n)
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(ans)
else:
    print(-1)

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

ans = n
for i in a:
    ans -= i

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

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

As = sum(A)
if As <= N:
    print(N - As)
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):
import sys

input = sys.stdin.readline


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











import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log 
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,M=MI()
    A=sum(LI())
    if(A>N):
        print(-1)
    else:
        print(N-A)

if __name__ == '__main__':
    main()

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

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

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, m = list(map(int, readline().split()))
    a = list(map(int, readline().split()))
    s = sum(a)

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


if __name__ == '__main__':
    main()

Solution (Python):
import numpy as np
import math

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

a = sum(A)

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

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

sumA = sum(listA)
if n-sumA >= 0:
    print(n-sumA)
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, raw_input().split())
arr=map(int, raw_input().split())
s=sum(arr)
if s>n:
  print -1
else:
  print n-s

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


if __name__ == '__main__':
    main()

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

"""
Created on Sun Apr 19 20:41:10 2020

@author: Kanaru Sato
"""

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

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

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

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

Solution (Python):

import numpy as np
n, m = list(map(int, input().split()))
a = list(map(int, input().split()))

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

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

total = sum(a)

ans = max(-1, n - total)
print(ans)

Solution (Python):


import sys
import math
import collections
import itertools
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def lcm(x, y) : return (x * y) // math.gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

N, M = LI()
A = LI()
a = sum(A)

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

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

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

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

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

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

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

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

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