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

Solution (Python):
def sep():
    return map(int,input().strip().split(" "))
def lis():
    return list(sep())


n,m=sep()
ar=lis()
k=sum(ar)
if k>n:
    print(-1)
else:
    print(n-k)

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

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

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

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

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

def main(n,m,a):
    days=sum(a)
    if days>n:
        return -1
    else:
        return n-days

if __name__=='__main__':
    n,m,a=readinput()
    ans=main(n,m,a)
    print(ans)

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 = list(map(int, input().split()))
a_total = sum(a_list)
ans = n - a_total

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

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

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

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

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

Solution (Python):
import math
from math import gcd,pi,sqrt
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    n,m = i_map()
    a = sum(i_list())
    if a > n:
        print(-1)
    else:
        print(n-a)




if __name__=="__main__":
    main()

Solution (Python):
list = []
n, m = map(int, input().split())
a = input().split()[0:m]
for num in a:
    num = int(num)
    list.append(num)

answer = n - sum(list)
if n < sum(list):
    answer =  -1

print(answer)

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

total_days = sum(A)

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

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

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

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

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

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

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

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

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

x = 0
for day in days:
    x = x + int(day)

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

Solution (Python):
"""
高橋君の夏休みは N 日間です。
夏休みの宿題が M 個出されており、
i 番目の宿題をやるには Ai 日間かかります。
複数の宿題を同じ日にやることはできず、また、宿題をやる日には遊ぶことができません。
夏休み中に全ての宿題を終わらせるとき、最大何日間遊ぶことができますか？
ただし、夏休み中に全ての宿題を終わらせることができないときは、かわりに -1 を出力してください。
"""

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



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

Solution (Python):
import sys

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

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

sum_day = sum(A)

ans = N - sum_day

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

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

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

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

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

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

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

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

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

Solution (Python):





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

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

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

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

Solution (Python):

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

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

def answer(N: int, M: int, A: list) -> int:
    A = sum(A)
    if N < A:
        return -1
    else:
        return N - A

print(answer(N, M, A))

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

answer = N - sum(A)

if N >= sum(A):
    print(answer)

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

Solution (Python):





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

answer = N - sum(A)

if N >= sum(A):
    print(answer)

else:
    print('-1')

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

Solution (Python):
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, m = list(map(int, readline().split()))
    a = list(map(int, readline().split()))
    print(n - sum(a) if sum(a) <= n else -1)


if __name__ == '__main__':
    solve()

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=0
for i in range(0,len(a)):
	s+=a[i]
if(s>n):
	print(-1)
	
elif(s<n):
	hangout=n-s
	print(hangout)
		
elif(s==n):
	print(0)

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

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

d = 0
flag = True
for a in A:
    d += a

    if(d > n):
        flag = False
        break

print(n-d if flag else -1)

Solution (Python):
N, M = map(int, input().split())
A_list = []
for i in range(1, M+1):
    A_list.append("A_" + str(i))
A_list = map(int, input().split())

answer = N - sum(A_list)

if answer >= 0 :
    print(answer)
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())
home = list(map(int,input().split()))

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

Solution (Python):




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


if n - sum(days) >= 0:
    print(n - sum(days))

else:
    print(-1)

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

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

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 = 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())
list01 = input().split()
list02 = [int(a) for a in list01]
if sum(list02) <= n:
    print(n - sum(list02))
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 個出されており、i 番目の宿題をやるには Ai 日間かかります。

    複数の宿題を同じ日にやることはできず、また、宿題をやる日には遊ぶことができません。
    夏休み中に全ての宿題を終わらせるとき、最大何日間遊ぶことができますか？
    ただし、夏休み中に全ての宿題を終わらせることができないときは、かわりに -1 を出力してください。
'''

'''
制約：
    1 ≦ N ≦ 1000000
    1 ≦ M ≦ 10000
    1 ≦ Ai ≦ 10000
'''


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


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


result = 0
if n >= work_days:
    result = n - work_days
else:
    result = -1

print(result)

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

Solution (Python):



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

if N < sum(my_list):
    answer = -1
else:
    answer = N - sum(my_list)

print(answer)

Solution (Python):
a, b = map(int, input().split())
c = list(map(int, input().split()))
if a >= sum(c):
  print(a - sum(c))
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()))
a_sum = sum(A)

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

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

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

Solution (Python):
N, M = map(int, input().split())
task = []
for i in range(1, M + 1):
    task.append("A_" + str(i))

task = map(int, input().split())
task_total = sum(task)

if task_total <= N:
    print(N - task_total)

else:
    print(-1)

Solution (Python):

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

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

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

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

Solution (Python):

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

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

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






total_study_days = sum(study_days)

answer = (N - total_study_days)

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

Solution (Python):







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






total_study_days = sum(study_days)

answer = (N - total_study_days)

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

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

Solution (Python):

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

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





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

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

hell = sum(homework)

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

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

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

Solution (Python):

from sys import stdin, stdout



def input():
	a = stdin.readline()
	if a[-1] == "\n": a = a[:-1]
	return a
def print(*argv, end="\n", sep=" "):
	n = len(argv)
	for i in range(n):
		if i == n-1: stdout.write(str(argv[i]))
		else: stdout.write(str(argv[i]) + sep)
	stdout.write(end)

mod = 10**9+7
def lcm(x, y): return (x * y) / (gcd(x, y))
def fact(x, mod=mod):
	ans = 1
	for i in range(1, x+1): ans = (ans * i) % mod
	return ans
def arr2D(n, m, default=0):
	lst = []
	for i in range(n): temp = [default] * m; lst.append(temp)
	return lst
def sortDictV(x): return {k: v for k, v in sorted(x.items(), key = lambda item : item[1])}

def solve(n, lst):
	if sum(lst) > n: return -1
	return n - sum(lst)

n, a = list(map(int, input().split()))
lst = list(map(int, input().split()))
print(solve(n, lst))

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

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

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

Solution (Python):
summer_vacation, homework = map(int, input().split())
days = list(map(int, input().split()))

if summer_vacation < sum(days):                 
    print(-1)
else:
    print(summer_vacation-sum(days))

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

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

Solution (Python):
sv,m = input().split(" ") 
sv = int(sv)
m = int(m)

day = input().split(" ") 
days = 0 

for i, new in enumerate(day): 
    days += int(day[i]) 

if days > sv: 
    print("-1")
else: 
    print(sv - days)

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

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

if n >= sum(homework):
  print(n-sum(homework))

else:
  print(-1)

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

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

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

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

else:
    print("-1")

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

a = list(input().split())

a_int = [int(i) for i in a]

if n >= sum(a_int):
    print(n - sum(a_int))

else:
    print("-1")

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

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

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

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

Solution (Python):

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

answer = N - sum(A)

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

Solution (Python):
S_list = [(input()) for i in range(2)]
n,m = map(int,S_list[0].split())
S_list_1 = list(map(int,S_list[1].split()))
sum_homework = sum(S_list_1)
if  sum_homework > n:
    result = -1
else:
    result = n - sum_homework
print(result)

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

work_days = 0

for i in range(M):
    work_days += int(A[i])

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

Solution (Python):



n, m = map(int, input().split())
a = input().split()
a_sum = 0
for b in a:
    a_sum += int(b)
if a_sum > n:
    print(-1)
else:
    print(n - a_sum)

Solution (Python):







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


play_day = N - sum(A)

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

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


answer = n - sum(a)

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

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

for i in range(0, 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()))

enjoy = N - sum(A)

if N >= sum(A):
    print(enjoy)

else:
    print('-1')

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

day = N - sum(A)

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

elif N - sum(A) < 0:
    print(-1)

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

answer = N - sum(A)

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

Solution (Python):
summer_vacation, amount_of_homework = map(int, input().split())
a = map(int, input().split())
homework_list = list(a)

total_days = 0

for i in homework_list:
    total_days += i

if summer_vacation >= total_days:
    print(summer_vacation - total_days)
else:
    print(-1)

Solution (Python):





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

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

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

for i in range(M):
    homework += a[i]

play = N - homework

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

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

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

Solution (Python):










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



answer = n - sum(a)

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

Solution (Python):
N, M = map(int, input().split())
task = []
for i in range(1,M + 1):
    task.append("A_" + str(i))

task = map(int, input().split())
task_total = sum(task)

if task_total <= N:
    print(N - task_total)

else:
    print(-1)

Solution (Python):
days_summer_vacation, amount_homework = map(int, input().split())
a = map(int, input().split())
schedule_hw = list(a)

need_days_hw = 0

for i in schedule_hw:
    need_days_hw += i


if days_summer_vacation > need_days_hw:
    print(days_summer_vacation - need_days_hw)
elif days_summer_vacation == need_days_hw:
    print(0)
else:
    print(-1)

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

answer = N - sum(A)

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

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

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

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

if N >= sum(work):
    answer = N - sum(work)
else:
    answer = '-1'
print(answer)

Solution (Python):
def answer(n: int, m: int, a: []) -> int:
    return max(-1, n - sum(a))


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


if __name__ == '__main__':
    main()

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

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

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

answer = N - sum(A)

if N >= sum(A):
    print(answer)

else:
    print('-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 s > n:
    print(-1)
elif s <= n:
    print(n - s)

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 s>n:
    print(-1)
elif s<=n:
    print(n-s)

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

A_list = []
for i in range(1, M+1):
    A_list.append("A_" + str(i))
A_list = map(int,input().split())

answer = N - sum(A_list)

if answer >= 0:
    print(answer)
else:
    print(-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 = list(map(int, input().split()))


x = sum(A)

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

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

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

Solution (Python):
summer_vacation, homework = map(int, input().split())
days = list(map(int, input().split()))

if summer_vacation < sum(days):                 
    print(-1)
else:
    print(summer_vacation-sum(days))

Solution (Python):
N, M = map(int, input().split())
A_list = []
for i in range(1, M+1):
    A_list.append("A_" + str(i))
A_list = map(int, input().split())

answer = N - sum(A_list)

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

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

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

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

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

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

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

Solution (Python):






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

answer = N - sum(A)

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

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

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()))
def answer(N: int, M: int, A: list) -> int:
    homework_days = 0
    for i in range(0, M):
        homework_days += int(A[i])
        i += 1
    if homework_days <= N:
        return N - homework_days
    else:
        return -1

print(answer(N, M, A))

Solution (Python):
summer_vacation, homework = map(int, input().split())
days = list(map(int, input().split()))

if summer_vacation < sum(days):                 
    print(-1)
else:
    print(summer_vacation-sum(days))

Solution (Python):

N,M=map(int,input().split())
A=input().split()
for i in range(len(A)):
    A[i]=int(A[i])
if (1<=N and N<=10**6)and(1<=M and M<= 10**4):
    for j in range(len(A)):
        N-=A[j]
    if N >= 0:
        print(N)
    if N < 0:
        print('-1')

Solution (Python):
import numpy as np
 
N, M = map(int, input().split())
A = []
A = map(int, input().split())
 
dif = N - sum(A)
 
if dif >= 0:
  print(dif)
else:
  print('-1')

Solution (Python):
N, M = map(int, input().split())
list1 = (input()).split(' ')
def answer(N: int, M: int, list1: list) -> int:
    homework_days = 0
    for i in range(0, M):
        homework_days += int(list1[i])
        i += 1
    if homework_days <= N:
        return N - homework_days
    else:
        return -1
print(answer(N, M, list1))

Solution (Python):
n,m=map(int,input().split())
*a,=map(int,input().split())
ans=n-sum(a)
print([-1,ans][ans>=0])

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

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

if N>=day:
    print(N-day)
else:
    print(-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):
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()))

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

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

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):
sv,hm=map(int,input().split())
i=list(map(int,input().split()))
sum=0

for j in range(hm):
  sum+=i[j]
  
if sv-sum>=0:
  print(sv-sum)
else:
  print("-1")

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

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

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

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

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

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

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

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

Solution (Python):

import sys
from itertools import chain


def solve(N: int, M: int, A: "List[int]"):
    answer = N - sum(A)
    if answer < 0:
        answer = -1
    return answer


def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    N = int(next(tokens))  
    M = int(next(tokens))  
    A = [int(next(tokens)) for _ in range(M)]  
    answer = solve(N, M, A)
    print(answer)


if __name__ == "__main__":
    main()

Solution (Python):
def atc_163b(a: str, b: str) -> int:
    NM = a.split(" ")
    N = int(NM[0])
    M = int(NM[1])

    A = b.split(" ")
    A_int = [int(ai) for ai in A]
    play_days = N - sum(A_int)

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

a = input()
b = input()

print(atc_163b(a, b))

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

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

Solution (Python):
import sys
import math

N, M = map(int, input().split())
a = map(int, input().split())
A = 0
for i in a:
    A += i

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

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

ANS = N - sum(A)

if ANS < 0:
    ANS = -1

print(ANS)

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

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

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

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

for i in range(M):
  sum += A[i]
  
if N >= sum:
  print(N - sum)
  
else:
  print(-1)

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

Solution (Python):

holi,hw = map(int,input().split())
hw_day = list(map(int,input().split()))


hw_sum = sum(hw_day)
if hw_sum <= holi:
    print(holi - hw_sum)
else:
    print("-1")

Solution (Python):
mn = input().split()

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

ms = input().split()

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

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

Solution (Python):

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

if __name__ == "__main__":
    main()

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

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 = 0

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