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

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

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

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

Solution (Python):

import sys

import fractions
import copy
import bisect
import math
import numpy as np
import itertools
from itertools import combinations_with_replacement


from operator import itemgetter
from sys import stdin

from operator import mul
from functools import reduce
from collections import Counter





j=0
k=0
n=3
r=1
a=[0]






"1行1つの整数を入力を取得し、整数と取得する"




"12 21 332 とか入力する時に使う"
"1行に複数の整数の入力を取得し、整数として扱う"

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

for i in number_list:
    print(number_list[i-1])

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'''
x=[]
y=[]
for i in range(N):
    x1, y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)
print(x)
print(y)
"複数行に2数値を入力する形式 x座標とy座標を入力するイメージ"
'''

'''
mixlist=[]
for i in range(N):
    a,b=input().split()
    mixlist.append((int(a),b))
print(mixlist)
"複数行にintとstrを複合して入力するやつ，今回はリスト一つで処理している"
'''

'''



"正方行列にstr型の値を入力"
'''




'''
入力
1 2
4 5
7 8
出力結果
[[1, 2], [4, 5], [7, 8]]
'''
"列数に関して自由度の高いint型の値を入力するタイプの行列"


'''
table = [[int(i) for i in input().split()] for m in range(m)]

print(type(N))
print(N)
print(type(M))
print(M)

print(type(table))
print(table)
'''











'''
入力
1234
出力
1
[[1, 2, 3, 4]]
'''




'''
word_list= input().split(" ")
print(word_list[0])
"連続文字列の入力"
"qw er ty とかの入力に使う"
"入力すると空白で区切ったところでlistの番号が与えられる"
'''



'''
A, B, C=stdin.readline().rstrip().split()
print(A)
"リストではなく独立したstr型を入れるなら以下のやり方でOK"
'''




"aという変数に入っているものを大文字にして出力"

















'''
コンビネーションの組み合わせの中身を出力する形式
for i in itertools.combinations(brray, 2)
combinationsをpermutationsにすれば順列になる
今回なら(abc133B)
入力
1 2
5 5
-2 8
出力
[[1, 2], [5, 5], [-2, 8]]
もちろん一次元リストでも使えるし
何よりiもリストのように使えるので便利
'''


'''
def cmb(n,r):
    
    r= min(n-r,r)
    
    if r == 0: return 1
    over = reduce(mul, range(n, n-r, -1))
    
    
    

    under = reduce(mul, range(1, r+1))
    
    
    
    

    return over // under
    
    
    
    
a = cmb(n, r)

'''

'''
import itertools
from itertools import combinations_with_replacement

combinationについて
以下の違いを意識しよう
combinations() p, r 長さrのタプル列、ソートされた順で重複なし

combinations_with_replacement() p, r 長さrのタプル列、ソートされた順で重複あり


使用例 　　　　　　　　　　　                  出力　　
combinations('ABCD', 2)　　　　　　　　　　　　AB AC AD BC BD CD
combinations_with_replacement('ABCD', 2)　　 AA AB AC AD BB BC BD CC CD DD
'''



'''




for i in a.most_common(n):print(i)





 


'''









'''
bisect.bisect_left(a, x, lo=0, h=len(a))
引数
a: ソート済みリスト
x: 挿入したい値
lo: 探索範囲の下限
hi: 探索範囲の上限
(lo, hiはスライスと同様の指定方法)
bisect_leftはソートされたリストaに対して順序を保ったままxを挿入できる箇所を探索します。leftが示す通り、aにすでにxが存在している場合は、挿入箇所は既存のxよりも左側になります。また、lo, hiを指定することで探索範囲を絞り込むことも可能です。デフォルトはaの全体が探索対象です。
'''

'''
素数の判定
'''
def is_prime(n):
    if n == 1: return False

    for k in range(2, int(np.sqrt(n)) + 1):
        
        if n % k == 0:
            return False
            
    return True


'''
npのmaxとmaximumの違い
xs = np.array([1, -2, 3])
np.max(xs, 0)
この出力は3となります．[1, -2, 3]と0の4つの数字のうち，最も大きい値を出力します．

一方で，[max(1, 0), max(-2, 0), max(3, 0)]を出力したい時があります．
その時は，numpyのmaximum関数を用います．

xs = np.array([1, -2, 3])
np.maximum(xs, 0)  

'''

def factorial(x, mod=10**9+7):
    
    
    
    tmp = 1
    for i in range(1, x+1):
        tmp = (tmp * i) % mod
    return tmp
    '''
    Basically, when you do a**d % n, you actually have to calculate a**d, which could be quite large.
    But there are ways of computing a**d % n without having to compute a**d itself, and that is what pow does.
    '''
"
def gcd(a, b):
    while b:
        
        
        a, b = b, a % b
    return a

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

"
def divisor(n):
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table











'''
ascii_letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
digits = '0123456789'
hexdigits = '0123456789abcdefABCDEF'
letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv...\xaf\xb0...
lowercase = 'abcdefghijklmnopqrstuvwxyz'
octdigits = '01234567'
printable = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTU...
punctuation = '!"
uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
whitespace = '\t\n\x0b\x0c\r '
'''
'''
引数endに任意の文字列を指定すると、その文字列が改行の代わりに最後に挿入される。例えば連続するprint()の出力を改行なしで単純に連結したい場合は空文字列''を指定すればよい。

print('abc', end='---')
print('xyz')


print('abc', end='')
print('xyz')

source: print_basic.py
なお、デフォルトで改行されるのは引数endのデフォルト値が改行文字'\n'に設定されているから。
'''

def main():
    n=3
    steps=0
    state=0
    w=1
    j=0
    k=0
    
    
    
    n,m=map(int, input().split(" "))

    
    
    
    al=list(map(int, input().split(" ")))
    if n<sum(al):
        print(-1)
        sys.exit()
    print(n-sum(al))
    
    
    


    
    
     

    l = ['aaa', 'bbb', 'ccc']
    x=l.index('aaa')
    
    
    
    

    
        
    
    

    
    
    
    
    DP = np.zeros(w+1, dtype=int)
    exdp=np.zeros((3,4)) 
    
    
    
        
        
    
    
        
        
    


    
    



    '''
    入力
    1234
    出力
    [1, 2, 3, 4]
    '''
    pin_l=["x" for i in range(10)]
    

    ls = ["a", "b", "c", "d", "e"]


    
    

    
    

    
    
    
    
    
    '''
    lsというリストの場合に、1つ飛びの値を取得したい場合には
    ls[::2]
    のようにします。こうすると、
    ["a", "c", "d"]と出力される
    '''

if __name__ == "__main__":
    main()

Solution (Python):
yasumi,homework=map(int,input().split())
S=list(map(int,input().split()))

for i in range(homework):
    yasumi-=S[i]
    

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

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

d = sum(A)

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

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

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

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

Solution (Python):
import numpy as np
N,M=map(int,input().split())
p=list(map(int,input().split()))
if np.sum(p)>N:
  print(-1)
else:
  print(N-np.sum(p))

Solution (Python):
import math
import numpy as np

def main():
  N,M = (int(x) for x in input().split())
  A = [int(x) for x in input().split()]
  
  for i in range(M):
    N = N - A[i]
  
  if N < 0:
    print('-1')
  else:
    print(N)  
  
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())
L=list(map(int,input().split()))
if N-sum(L)>=0:
  print(N-sum(L))
else:
  print(-1)

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

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

Solution (Python):
n,x = 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):
import numpy as np

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

ans = n - a.sum()

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

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

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

s = sum(a)

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

Solution (Python):
import sys
from io import StringIO
import unittest


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

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

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

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

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


def resolve():
    n, a = read()
    result = think(n, a)
    write(result)


def read():
    n, m = read_int(2)
    return n, read_int(m)


def read_int(n):
    return read_type(int, n, sep=' ')


def read_float(n):
    return read_type(float, n, sep=' ')


def read_type(t, n, sep):
    return list(map(lambda x: t(x), read_line().split(sep)))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(n, a):
    total = sum(a)
    return -1 if n < total else n - total


def write(result):
    print(result)


if __name__ == '__main__':
    
    resolve()

Solution (Python):
N, M = map(int, input().split())
A = list(map(int, input().split()))
r=N
for x in A:
    r-=x
    if r<0:
        r=-1
        break
print(r)

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

    for i in A:
        if i > N:
            print(-1)
            return
        ans = ans - i
        if ans < 0:
            print(-1)
            return
    print(ans)

main()

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

print(max(a - c, -1))

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

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

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

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

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

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

Solution (Python):
x,y = map(int,input().split())	
li = list(map(int,input().split()))

for i in li:
  x = x - i

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

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

print("{}".format(-1 if sum(A) > N else (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()))

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)
rest = n - sum_a

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

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

Solution (Python):
N, M = map(int, input().split())
homework = list(map(int, input().split()))
homework_day = sum(homework)
rest_summer_vacation = N - homework_day
if rest_summer_vacation < 0:
    print('-1')
else:
    print(str(rest_summer_vacation))

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


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

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

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

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

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

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

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

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

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

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

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

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

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

play_days = N - sum(A_list)

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

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

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

Solution (Python):
first = input().split(" ")
n = int(first[0])
m = int(first[1])
second = input().split(" ")

for i in range(m):
    n -= int(second[i])

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

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

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

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

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

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

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

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

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

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

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

Array=map(int,input().split())
A=[]
for i in Array:
    A.append(i)

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

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

Solution (Python):
a=[int(x) for x in input().split()]
b=[int(x) for x in input().split()]
c=sum(b)

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

Solution (Python):
a=[int(x) for x in input().split()]
b=[int(x) for x in input().split()]
c=sum(b)

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

Solution (Python):
def resolve():
    n, m = list(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)
resolve()

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

if sum_A <= N:
  print(str(N-sum_A))
else:
  print("-1")

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


main()

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

s = sum(a)
ans = n - s

print(ans if ans >= 0 else "-1")

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

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

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

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

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

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

for num in a:
    n = n - num

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

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

for i in range(m):
    n -= a[i]

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

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

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

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

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

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

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


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

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

Solution (Python):
holidays, num_of_homework = map(int, input().split())
days = list(map(int, input().split()))

playingdays = holidays - sum(days)
if playingdays < 0:
    print('-1')
else:
    print(playingdays)

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

days = n
for i in range(m):
    days -= a[i]

if(days < 0):
    print('-1')
else:
    print(days)

Solution (Python):
n,m=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(-1)
else:
  print(n-s)

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

total = sum(line)

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

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

work = sum(a)
play = n - work

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

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

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

Solution (Python):
N, M = [int(i) for i in input().split()]
A = list(int(i) for i in input().split())
S = 0
for i in range(M):
    S = S + A[i]

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

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

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

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

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

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

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

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

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

ASOBU = N - sum(A)

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

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

Solution (Python):
x = input().split()
y = input().split()
n = int(x[0])
m = int(x[1])
count = 0
for i in y:
  count += int(i)
if (n - count) >= 0:
  print(n-count)
else:
  print('-1')

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

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

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

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

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

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

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

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

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

ans = N - sum(A)

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

Solution (Python):

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

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

a = n -sum(li)

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

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

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

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

Solution (Python):




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

for i in range(m):
    n -= a[i]

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

Solution (Python):

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

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

Solution (Python):
day , amt = map(int,input().split())

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

for i in hw_list:
  day -= i
  
if day < 0:
  print("-1")
else:
  print(day)

Solution (Python):
N,M=map(int,input().split())
list=list(map(int,input().split()))
n=0
while n<M:
  N = N-list[n]
  n=n+1

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

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 = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
total = 0
for i in range(M):
    total += a[i]
total = N - total
if total>=0:
    print(total)
else:
    print("-1")

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

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

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

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

Solution (Python):
N, M = map(int,input().split())
A = list(map(int,input().split()))
sumA = sum(A)
if N >= sumA:
  print(N-sumA)
else:
  print(int(-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()))
i=0
j=0
while i<m:
    j+=a[i]
    i+=1
ju=n-j
if ju<0:
    print(-1)
else:
    print(ju)

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 = (int(x) for x in input().split())
days = 0
ar = [int(x) for x in input().split()]

for v in ar:
    n-=v

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

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

Solution (Python):
import math

ex = []
N, M = map(int, input().split())
ex = [exi for exi in map(int, input().split())]

rem = N - sum(ex)
print(rem) if rem >= 0 else print('-1')

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

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

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

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

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

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

Solution (Python):
n,m=map(int,input().split())
a=list(map(int,input().split()))
p=0
for i in a:
      p+=i
if(n>=p):
          print("{}".format(n-p))
else:
          print("-1")

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

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

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

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

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

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

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

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

Solution (Python):
import sys

def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())

n, m = ISI()
l=ILI()
if n-sum(l)<0:print(-1)
else:print(n-sum(l))

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

Solution (Python):
n,m=map(int,input().split())
L=list(map(int,input().split()))
day=0
flg=True

for i in range(m):
    day+=L[i]
    if day>n:
        flg=False
        break

if flg:
    print(n-day)
else:
    print("-1")

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

Solution (Python):
import sys
from collections import deque
import copy
def main():
    N, M = map(int, input().split())
    A = [int(i) for i in input().split()]
    count = sum(A)
    if N - count < 0:
        print(-1)
    else:
        print(N - count)


if __name__ == '__main__':
    main()

Solution (Python):
import sys
from collections import deque
import copy
def main():
    N, M = map(int, input().split())
    A = [int(i) for i in input().split()]
    count = 0
    for i in range(M):
        count += A[i]
    if N - count < 0:
        print(-1)
    else:
        print(N - count)


if __name__ == '__main__':
    main()

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

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

sum_A = sum(A)
remain = N - sum_A

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