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

Solution (Python):
import sys
import numpy as np
import math
from collections import deque 
from functools import reduce



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

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

h = n - sum(a) 

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

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

Solution (Python):
N,M = map(int,input().split())
A = list(map(int,input().split()))
s = 0
for i in range(len(A)):
    s = 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()))
if (res := N - sum(A)) < 0:
    print(-1)
else:
    print(res)

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

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

if sum(a) > n:
    print('-1')

else:
    play = n - sum(a)
    print(play)

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

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

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

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

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

sumday = sum(a)

if sumday > n:
  print('-1')
else:
  print(n-sumday)

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

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

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

a_sum = sum(a)
if n>=a_sum:
    print(n-a_sum)
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 = tuple(int(n) for n in input().split())

As = [int(n) for n in input().split()]

for A in As:
    N -= A

print(max(N, -1))

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

a_sum = sum(a)
ans = n-a_sum

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

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

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

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

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

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

ans = N

for A in Aj:
	ans -= A 
	if ans < 0:
		ans = -1
		break
print(ans)

Solution (Python):
import math
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())
s =input().split()
num = 0
Sum = 0
for i in range(m):
    num = int(s[i])
    Sum += num
if n - Sum >=0:
    print(n-Sum)
else:
    print('-1')

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

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

tot=0
for i in a:
  tot+=i

if tot<=n:
  print(str(n-tot))
else:
  print("-1")

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

homework=0

for a in A:
    homework+=a

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

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

a = [0]*m

a = [int(s) for s in input().split()]



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

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

Solution (Python):
import numpy as np
N,M = map(int,input().split())

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

A_sum = np.sum(A)

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

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

Solution (Python):


import sys




import numpy as np



"""Template"""


class IP:
    """
    入力を取得するクラス
    """

    def __init__(self):
        self.input = sys.stdin.readline

    def I(self):
        """
        1文字の取得に使います
        :return: int
        """
        return int(self.input())

    def S(self):
        """
        1文字の取得(str
        :return: str
        """
        return self.input()

    def IL(self):
        """
        1行を空白で区切りリストにします(int
        :return: リスト
        """
        return list(map(int, self.input().split()))

    def SL(self):
        """
        1行の文字列を空白区切りでリストにします
        :return: リスト
        """
        return list(map(str, self.input().split()))

    def ILS(self, n):
        """
        1列丸々取得します(int
        :param n: 行数
        :return: リスト
        """
        return [int(self.input()) for _ in range(n)]

    def SLS(self, n):
        """
        1列丸々取得します（str
        :param n: 行数
        :return: リスト
        """
        return [self.input() for _ in range(n)]

    def SILS(self, n):
        """
        Some Int LineS
        横に複数、縦にも複数
        :param n: 行数
        :return: list
        """
        return [self.IL() for _ in range(n)]

    def SSLS(self, n):
        """
        Some String LineS
        :param n: 行数
        :return: list
        """
        return [self.SL() for _ in range(n)]


class Idea:
    def __init__(self):
        pass

    def HF(self, p):
        """
        Half enumeration
        半分全列挙です
        pの要素の和の組み合わせを作ります。
        ソート、重複削除行います
        :param p: list : 元となるリスト
        :return: list : 組み合わせられた和のリスト
        """
        return sorted(set(p[i] + p[j] for i in range(len(p)) for j in range(i, len(p))))

    def Bfs2(self, a):
        """
        bit_full_search2
        bit全探索の改良版
        全探索させたら2進数のリストと10進数のリストを返す
        :return: list２つ : １個目 2進数(16桁)  2個目 10進数
        """
        
        
        
        value = []
        for i in range(1 << len(a)):
            output = []

            for j in range(len(a)):
                if self.bit_o(i, j):
                    """右からj+1番目のiが1かどうか判定"""
                    
                    output.append(a[j])
            value.append([format(i, 'b').zfill(16), sum(output)])

        value.sort(key=lambda x: x[1])
        bin = [value[k][0] for k in range(len(value))]
        val = [value[k][1] for k in range(len(value))]
        return bin, val

    def S(self, s, r=0, m=-1):
        """
        ソート関係行います。色々な設定あります。
        :param s: 元となるリスト
        :param r: reversするかどうか 0=False 1=True
        :param m: （2次元配列）何番目のインデックスのソートなのか
        :return: None
        """
        r = bool(r)
        if m == -1:
            s.sort(reverse=r)
        else:
            s.sort(reverse=r, key=lambda x: x[m])

    def bit_n(self, a, b):
        """
        bit探索で使います。0以上のときにTrue出します
        自然数だからn
        :param a: int
        :param b: int
        :return: bool
        """
        return bool((a >> b & 1) > 0)

    def bit_o(self, a, b):
        """
        bit探索で使います。1のときにTrue出すよ
        oneで1
        :param a: int
        :param b: int
        :return: bool
        """
        return bool(((a >> b) & 1) == 1)

    def ceil(self, x, y):
        """
        Round up
        小数点切り上げ割り算
        :param x: int
        :param y: int
        :return: int
        """
        return -(-x // y)

    def ave(self, a):
        """
        平均を求めます
        :param a: list
        :return: int
        """
        return sum(a) / len(a)

    def gcd(self, x, y):
        if y == 0:
            return x
        else:
            return self.gcd(y, x % y)

    def lcm(self, x, y):
        return (x * y) // self.gcd(x, y)


"""ここからメインコード"""


def main():
    
    r, e = range, enumerate
    ip = IP()
    id = Idea()

    """この下から書いてね"""
    
    
    
    
    
    n, m = ip.IL()
    a = ip.IL()
    if sum(a) <= n:
        print(n - sum(a))
    else:
        print(-1)


main()

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

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

if sum(x) > a:
    print(-1)
else:
    print(a-sum(x))

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

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

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

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

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

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

if __name__ == '__main__':
    resolve()

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

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

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

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

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

Solution (Python):
import sys

IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))

INIT_VAL = 0
DP2 = lambda d1, d2: [[INIT_VAL]*d2 for _ in range(d1)]
DP3 = lambda d1, d2, d3: [[[INIT_VAL]*d3 for _ in range(d2)] for _ in range(d1)]

def main():
    a, b = MII()
    dd = MII()
    total = sum(dd)
    if total > a: print(-1); exit(0)
    else: print(a-total)

if __name__ == '__main__':
    main()

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

Solution (Python):
import sys
input = lambda: sys.stdin.readline().rstrip()
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())
n = list(map(int,input().split()))

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

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

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

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

Solution (Python):


line = list(map(int,input().split()))
day = line[0]
work = line[1]
line2 = list(map(int,input().split()))
haveto=0
for i in line2:
    haveto+= i

answer = day - haveto
if answer<0:
    print("-1")
else:
    print(answer)

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

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

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

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

work = n - sum(a)

if work >= 0:
    print(work)
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 = list(map(int, input().split(" ")))
a = list(map(int, input().split(" ")))
a_sum = sum(a)
ans = n - a_sum

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

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

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

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

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

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

play = n - sum(a)

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

Solution (Python):

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

A = list(map(int, input().split()))
for a in A:
    N -= a

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

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

for i in L:
    N-=i

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

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

ans = N-sum(A)

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

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

Solution (Python):
import sys

N, M = map(int, sys.stdin.readline().rstrip().split())
A = list(map(int, sys.stdin.readline().rstrip().split()))

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

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

Solution (Python):
import math
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(mi())
n,m = mi()
a = li()
if (n - sum(a) < 0):
    print("-1")
else:
    print(n - sum(a))

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

Solution (Python):

import sys
from collections import Counter
from itertools import permutations, combinations
from fractions import gcd
from math import ceil, floor
import bisect
sys.setrecursionlimit(10 ** 6)

def input():
    return sys.stdin.readline()[:-1]

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

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

if __name__ == '__main__':
    main()

Solution (Python):
N,M,*A = map(int,open(0).read().split())
play = N - sum(A)
print(play if play >= 0 else -1)

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

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

sum = 0
for i in A:
    sum += i

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

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

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

Solution (Python):
def input_one_number():
    return int(input())

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

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


N, M = input_multiple_number()

listA = input_multiple_number_as_list()

hw = 0

for a in listA:
	hw += a

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

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

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

Solution (Python):
if __name__ == '__main__':
    b, c = map(int, input().split())
    a = [int(i) for i in input().split()]

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

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

workday = sum(a)

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

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

rest = N - sum(As)
if rest < 0:
    print(-1)
else:
    print(rest)

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

Solution (Python):
input_line1 = input()
input_line2 = input()

n, m = map(int, input_line1.split())
a_list = map(int, input_line2.split())

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

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

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

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

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:
	N = -1

print(N)

Solution (Python):

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

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

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

if __name__ == '__main__':
    main()

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

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

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

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

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

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

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

for aa in a:
  n -= aa

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

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

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

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

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

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

tot = sum(a)

ans = N - tot

if ans < 0:
  ans = -1

print(ans)

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

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

Solution (Python):
i,j = list(map(int, input().split()))
s = list(map(int, input().split()))
z=sum(s)
if i<z:
    print(-1)
else:
    print(i-z)

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

sum=sum(a)

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

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

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

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

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

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

Solution (Python):
nm = input().split()
d = input().split()

n = int(nm[0])
m = int(nm[1])

di = [int(i) for i in d]

for i in di:
	n = n - i

if n < 0:
	n = -1

print(n)

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

Solution (Python):
import math

S =  list(map(int,input().split()))
N = S[0]
M = S[1]
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()))

play = n - sum(a)

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

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

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

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

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

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

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

Solution (Python):

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

ans = N - sum(a_list) if N >= sum(a_list) else -1

print(ans)

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

Solution (Python):
import math

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

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

Solution (Python):
inp1 = list(map(int, input().split()))
n = inp1[0]
m = inp1[1]

inp2 = list(map(int, input().split()))
sum2 = sum(inp2)
ans =  n - sum2
if (n - sum2) >= 0:
  print(n - sum2)
else:
  print("-1")

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

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

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

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

Solution (Python):
def Main(N, M, A):
    return max(N - sum(A), -1)    

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

if __name__ == '__main__':
    main()

Solution (Python):


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

nums = [int(x.strip()) for x in input().split(' ') ]
count = 0

for num in nums:
    count = count + num

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

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

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

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

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

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

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

sum = 0
for e in l:
    sum += e

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

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

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

Solution (Python):
import numpy as np

def main():
    args = input().rstrip().split(' ')
    N, M = int(args[0]), int(args[1])
    args = input().rstrip().split(' ')
    hw = np.array([int(i) for i in args])
    sum_hw = np.sum(hw)
    if(sum_hw > N):
        print('-1')
    else:
        print(N - sum_hw)
    
    
if __name__ == "__main__":
    main()

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

nokori = n - sum(data)

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

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

d = sum(a)
ans = n - d

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

Solution (Python):
import sys

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

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

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

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

if sum(a)<=n:
    print(n-sum(a))

else:
    print("-1")

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

work = 0
for i in range(len(A)):
    work += A[i]

if (NM[0] - work >= 0):
    print(NM[0] - work)
else:
    print(-1)

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

sum_a = sum(A)
day = n - sum_a

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

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

Solution (Python):
N, _ = map(int, input().split())
data = list(map(int, input().split()))
data_sum = sum(data)
if data_sum <= N:
    print(N - data_sum)
else:
    print("-1")

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

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

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

Solution (Python):
def b163(n, m, al):


    return n - sum(al) if n - sum(al) >= 0 else "-1"

def main():
    n , m = map(int, input().split())
    al = list(map(int, input().split()))
    print(b163(n, m, al))

if __name__ == '__main__':
    main()

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

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

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

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

p = sum(a)

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