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
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

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

def print_l(l):
    print(' '.join(map(str, l)))

class Interval():
    def __init__(self, li):
        self.li = li
        self.n = len(li)
        self.sum_li = [li[0]]
        for i in range(1, self.n):
            self.sum_li.append(self.sum_li[i-1] + li[i])

    def sum(self, a, b=None):
        if b is None:
            return self.sum(0, a)

        res = self.sum_li[min(self.n-1, b-1)]
        if a > 0:
            res -= self.sum_li[a-1]
        return res


n,m = l_in()
A = l_in()

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

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

C=0
for i in A:
    C+=i
if N-C>=0:
    print(N-C)
else:
    print(-1)

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

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

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

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

Solution (Python):
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n,m=n1()
a=n1()

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

Solution (Python):


MOD = 10**9
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

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

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

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

Solution (Python):


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

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


if __name__ == "__main__":
    solve()

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

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

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

Solution (Python):

"""
Created on Sun Apr 19 20:57:48 2020

@author: black
"""


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

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

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

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

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

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians

from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

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


def main():
    N, M = MAP()
    A = LIST()

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


if __name__ == '__main__':
    main()

Solution (Python):

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


ans = N - sum(A)


print(-1 if ans < 0 else ans)

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

sa = sum(a)
diff = n - sa

print(max(diff, -1))

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

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

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

Solution (Python):

import sys
sys.setrecursionlimit(10**8)
INF = float("inf")

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

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

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

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

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

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

ans = N - sum(A)

if ans < 0:
    ans = -1

print(ans)

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

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

Solution (Python):
num_holiday, num_homework = map(int, input().split())
days_required = sum(map(int, input().split()))

print(max(-1, num_holiday - days_required))

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

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

N, M  = i_l()
A = i_l()


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

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

Solution (Python):



debug=1
def pront(*n):
    if debug==1:
        print(n)
        


base=10**9+7

def add(a,b):
    return (a+b)%base

def sub(a,b):
    return (a-b)%base

def multi(a,b):
    return (a*b)%base

def exp(a,b):
    x=1
    c=a
    d=b
    while d!=0:
        if d%2==1:
            x=multi(x,c)
        c=(c**2)%base
        d=d//2
    return x

def div(a,b):
    return(multi(a,exp(b,base-2)))


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

total=sum(A)
if total<=N:
    print(N-total)
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 = list(map(int, input().split()))
A_list = list(map(int, input().split()))

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

Solution (Python):




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

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


if __name__ == '__main__':
    main()

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

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

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

for i in range(M):
    N -= AList[i]
if N >= 0:
    print(N)
else:
    print('-1')

Solution (Python):


from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt, floor, ceil, log2
from fractions import gcd
from itertools import permutations, combinations
from operator import itemgetter
from functools import cmp_to_key


INF=1001001001
__MOD__=(10**9)+7
yn = 'YNeos'
judge = False
cnt = 0
ans = None


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

def intinput():
    return int(input())

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

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas

class ModInt():
    def __init__(self, x):
        self.__x = (x % __MOD__)
    def __add__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x + other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x + other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __sub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x - other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x - other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __mul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __truediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __pow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(self.__x, other.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(self.__x, other.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")
    def __modinv(self, m=__MOD__):
        a = self.__x
        if a == 0:
            raise ZeroDivisionError()
        if gcd(a, m) != 1:
            raise Exception("%sの逆数は求まりません。" % a)
        b, u, v = m, 1, 0
        while b != 0:
            t = a//b;
            a -= t*b
            a, b = b, a
            u -= t * v
            u, v = v, u
        u %= m
        if u < 0:
            u += m
        return u
    def __int__(self):
        return self.__x



if __name__ == '__main__':
    N, M = mulinputs()
    total = sum(list(mulinputs()))

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

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

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

Solution (Python):
import collections
import math
import operator as op
from functools import reduce
from collections import Counter
import numpy as np
import math
import bisect
import heapq


def get_inputs(cast_func=None):
    if cast_func is None:
        return input().split()
    else:
        return list(map(cast_func, input().split()))


def get_input(cast_func=None):
    if cast_func is None:
        return input()
    else:
        return cast_func(input())


def main():
   N, M = get_inputs(int)
   A = get_inputs(int)
   print(max(-1, N - sum(A)))





if __name__ == '__main__':
    main()

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

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

Solution (Python):
k = list(map(int, input().split()))
l = list(map(int, input().split()))
g = sum(l)

if k[0] >= g:
  print(k[0] - g)
else:
  print(-1)

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

asum=sum(alist)
print(max(-1,N-asum))

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

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

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

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

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

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

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

Solution (Python):
import math

if __name__ == '__main__':
    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):
summer, homework = list(map(int, input().split()))
A = list(map(int, input().split()))
if summer-sum(A)>=0:
    print(summer-sum(A))
else:
    print(-1)

Solution (Python):
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n,m=INTM()
    a=LIST()
    print(max(n-sum(a),-1))
if __name__ == '__main__':
    do()

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

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

Solution (Python):
import math

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

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

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

Solution (Python):
N, M = [int(x) for x in input().split()]
A_list = [int(a) for a in input().split()]
r = N - sum(A_list)
if r >= 0:
    print(r)
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()))
s=sum(a)
if s>n:print(-1)
else:print(n-s)

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

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):
from math import gcd

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

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

yes = "Yes"
no = "No"

def main():
    n,m = mi()
    a = li()
    s = sum(a)
    print(max(n-s,-1))

main()

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

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

Solution (Python):
def main():
    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()))
day = sum(a)
result = n - day  
if result >=0:
    print(result)
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()))
r=sum(a)
if n-r<0:
    print(-1)
else:
    print(n-r)

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

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

if res < 0:
    res = -1

print(res)

Solution (Python):

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


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

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

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

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

Solution (Python):

from sys import stdin
from operator import itemgetter
from collections import deque
import math
import pprint
from functools import reduce


def keta(kazu):
    kazu_str = str(kazu)
    kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]
    return kazu_list

def gcd(*numbers):
    return reduce(math.gcd, numbers)

N, M = [int(x) for x in stdin.readline().rstrip().split()]
A = list(map(int,[int(x) for x in stdin.readline().rstrip().split()]))
sum_A = sum(A)

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

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

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

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

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

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

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

for i in range(a[1]):
  a[0] = a[0] - b[i]
if(a[0] < 0):a[0]=-1
print(a[0])

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

if n>=sa:
    print(n-sa)
else:
    print("-1")

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

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

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

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

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

Solution (Python):
import sys,math,copy,queue,itertools,bisect
sys.setrecursionlimit(10**7)
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
INF = 10**18
MOD = 10**9 + 7
DD = ((1,0),(0,1),(-1,0),(0,-1))

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

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

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

s = sum(res)

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

Solution (Python):

from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    n, m = map(int, input().split())
    a = [int(i) for i in input().split()]

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




BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")



if __name__ == "__main__":
    main()

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

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

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

Solution (Python):
import numpy as np

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

As = np.asarray(input().split(), dtype=np.int32)

ans = n - np.sum(As)

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

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

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

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()))
assert len(a) == m

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

Solution (Python):
n, m = list(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=0
for i in a:
    s+=i
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 sum_a > n:
    print(-1)
else:
    print(n-sum_a)

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = True

n, m = MAP()
a = LIST()
s = sum(a)
if n < s:
    print(-1)
else:
    print(n - s)

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

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

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

syukudai = sum(Ai)
nokori = N - syukudai
if nokori >= 0:
    print(nokori)
else:
    print(-1)

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

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

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

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

msum = sum(A)

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

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

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

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

w=sum(a)

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

Solution (Python):
N,M=list(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 = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

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

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

print(max(-1,n))

Solution (Python):

import sys


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

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

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

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

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

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

    if sum(a) > n:
        print(-1)
        return
    print(n-sum(a))
if __name__=='__main__':
    main()

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

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

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

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

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

sum = 0
for i in range(len(A)):
    sum += A[i]
if sum <= N:
    print(N - sum)
else:
    print(-1)

Solution (Python):
nm = input('')
n = int(nm.split(' ')[0])
m = int(nm.split(' ')[1])

alist = input('').split(' ')

d=0
for a in alist:
    d+=int(a)

if n >= d:
    print(n-d)
else:
    print('-1')