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



Sample input:
41 2
5 6


Sample output:
30

Submission status: Accepted

Solution code:
import numpy as np

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

sum = np.sum(a)

day = n - sum

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

Submission status: Accepted

Solution code:
n, m = map(int,input().split())
a = list(map(int,input().split()))
flag = 0
for i in a:
    n -= i
if n < 0:
    print(-1)
else: print(n)

Submission status: Accepted

Solution code:


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



if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
l = list(map(int, input().split()))
total = sum(l)
if total > N:
    ans = -1
else:
    ans = N - total
print(ans)

Submission status: Accepted

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

list_A_int = [int(s) for s in list_A]

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

Submission status: Accepted

Solution code:
from sys import stdin

holiday_count, task_count = stdin.readline().rstrip().split()
holiday_count = int(holiday_count)
tasks_days = sum([int(x) for x in stdin.readline().rstrip().split()])

remain = holiday_count - tasks_days
if remain < 0:
  print(-1)
else:
  print(remain)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n,m = map(int,(input().split()))
amount = list(map(int,input().split()))
day = 0
for i in amount:
    day = day + i
if n - day >=0:
    print(n-day)
else:
    print(-1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int,input("").split(" "))
elms = list( map(int,input("").split(" ")))

total = N
for elm in elms:
   N -= elm

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

Submission status: Accepted

Solution code:
x, y = map(int, input().split())

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

for single in range(y):
  sumDays += days[single]

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

Submission status: Accepted

Solution code:
inputLine=input()
N = int(inputLine.split(" ")[0])
M = int(inputLine.split(" ")[1])

inputLine=input()
A = inputLine.split(" ")

for i in range(len(A)):
    A[i] = int(A[i])

result = N - sum(A)

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
import math
n, m = map(int, input().split())
li = list(map(int, input().split()))
cnt = 0
for i in range(m):
    cnt += li[i]
if (cnt <= n):
    print(n-cnt)
else:
    print(-1)

Submission status: Accepted

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


main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math
a = input().split()
b = map(int,input().split())
c = int(a[0])-sum(b)
if (c < 0):
    print("-1")
else:
    print(c)

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
arr = list(map(int,input().split()))
s = sum(arr)
if (n-s >= 0):
  print(n-s)
else:
  print(-1)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
a=list(map(int,input().split()))
cnt=sum(a)
if N>=cnt:
    print(N-cnt)
else:
    print("-1")

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
M_list = list(map(int,input().split()))

syuku_sum = sum(M_list)

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

Submission status: Accepted

Solution code:
# coding: utf-8
N, M = map(int, input().split())
A = list(map(int, input().split()))
homeworkDays = sum(A)
if homeworkDays > N:
    print("-1")
else:
    print(N - homeworkDays)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N, M = map(int,input().split())
l = list(map(int,input().split()))
su = sum(l)
if N < su:
    print('-1')
else:
    print(N - su)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    n, m = mi()
    a = lmi()
    s = sum(a)
    print(n-s) if n-s>=0 else print(-1)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

vocation = N - sum(A)

print("{}".format(vocation) if vocation>=0 else -1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

num_days = n
num_hw = m
costs = a

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
A = list(map(int, input().split()))
A = sum(A)
ans = n-A
if ans<0:
  ans = -1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

diff = N - sum(A)

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# B - Homework
# 標準入力の取得
N,M = list(map(int, input().split()))
A = list(map(int, input().split()))

# 求解処理
result = N - sum(A)
if result >= 0:
    print(result)
else:
    print(-1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

l = n-sum(A)
if l < 0:
  l = -1

print(l)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-


def run():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))[:m]
    print(max(n - sum(a), -1))


if __name__ == '__main__':
    run()

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
times = list(map(int, input().split()))
if (sum(times) <= N):
    print(N-sum(times))

else:
    print(-1)

Submission status: Accepted

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

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

a_sum = sum(a_list)

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

Submission status: Accepted

Solution code:
N,M = (int(i) for i in input().split())  
A = [int(i) for i in input().split()] 
res = N - sum(A)
if res > -1:
  print(res)
else:
  print(-1)

Submission status: Accepted

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

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

S = N - sum(A)

if S < 0:
    print("-1")
    exit()

print(S)

Submission status: Accepted

Solution code:
K_s,M_s = input().split()
A = map(int, input().split())
K = int(K_s)
M = int(M_s)
ans=K-sum(A)
if ans<-1:
    ans=-1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

temp = sum(list(map(int,input().split())))

if N - temp > -1:
  print(N - temp)
else:
  print("-1")

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
def print_ans(N, M, ar):
    """Test Case
    >>> print_ans(41, 2, [5, 6])
    30
    >>> print_ans(10, 2, [5, 6])
    -1
    >>> print_ans(11, 2, [5, 6])
    0
    """
    tmp = N -sum(ar)
    if(tmp >= 0):
        print(tmp)
    else:
        print("-1")



if __name__ == '__main__':
    N, M = map(int, input().rstrip().split())
    ar = list(map(int, input().rstrip().split()))
    print_ans(N, M, ar)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
arr = list(map(int, input().split()))

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

Submission status: Accepted

Solution code:
n , m  = map(int , input().split())
vac = 0
numbers = list(map(int ,input().split()))
for i in numbers:
	vac += i
if n < vac:
	print(-1)
else:
	print(n-vac)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if ans > N:
    print('-1')
else:
    print(N-ans)

Submission status: Accepted

Solution code:
NM = list(map(int, input().split()))
N = NM[0]
M = NM[1]
A = list(map(int, input().split()))

days_for_work = 0

for i in A:
    days_for_work += i

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np


n, m = (int(x) for x in input().split())
a = [int(x) for x in input().split()]

hw_days = n - np.sum(a)
if hw_days < 0:
    print("-1")
else:
    print(hw_days)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
a = list(map(int,input().split()))
result = sum(a)
if N-result < 0 :
  print(-1)
else :
  print(N-result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
list1 = list(map(int , input().split()))
list2 = list(map(int , input().split()))

z = 0

for i in list2:
  z+=i
  
enjoy = list1[0] - z

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

Submission status: Accepted

Solution code:
#! /usr/bin python3
N, M = map(int, input().split())
A = list(map(int, input().split()))

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
A=list(map(int,input().split()))
for i in range(M):
    N=N-A[i-1]
    if N<0:
        N=-1
        break

print(N)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int,input().split())
A = list(map(int, input().split()))
holiday = N - sum(A)

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

Submission status: Accepted

Solution code:
s = input().split()
n = int(s[0])
m = int(s[1])
a = [m]
a = list(map(int, input().split()))
ans =0
for i in a:
    ans = ans + i

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

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

Submission status: Accepted

Solution code:
N,M = map(int, input().split())
list_1 = list(map(int, input().split()))
 
i=0
sum=0
 
while i<M:
  sum=sum+list_1[i]
  i=i+1
  
if sum>N:
  print("-1")
  
else:
  print(abs(sum-N))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
if __name__ == "__main__":
	r = [ int(i) for i in input().split(" ")]
	n = r[0]
	m = r[1]

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

	sm = 0
	for i in range(m):
		sm += ass[i]

	print(max( -1, n-sm))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
lists = list(map(int, input().split()))

sum_home_day = sum(lists)

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

Submission status: Accepted

Solution code:
n, m = [int(i) for i in input().split()]
a = [int(j) for j in input().split()]

sum = sum(a)

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

print(n - sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,M=(int(x) for x in input().split())
list=list(map(int,input().split()))
counter=0
for i in range(0,M):
    counter+=list[i]
if counter>N:
    print(-1)
else:
    print(N-counter)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    nm = list(map(int, input().rstrip().split()))
    days = list(map(int, input().rstrip().split()))

    n = nm[0]
    total = sum(days)
    val = n - total

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())  #数字
A = list(map(int, input().split()))  #リスト

B = sum(A)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
h      =  list(map(int, input().split()))

rest = N - sum(h)

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

Submission status: Accepted

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

d = N - sum(A)

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
d,h=map(int,input().split())
da=list(map(int,input().split()))
ans = d - sum(da)
if ans >= 0:print(ans)
else:print(-1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
A = []
A = map(int,input().split())

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
import sys
from functools import lru_cache
input = sys.stdin.readline
sys.setrecursionlimit(2 * 10**6)


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


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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
A=list(map(int,input().split()))
a=sum(A)
b=N-a
if b<0:
    print("-1")
else:
    print(b)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
s=sum(tuple(map(int,input().split())))
print(-1 if s>n else n-s)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
l_a = list(map(int, input().split()))

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,Q = map(int ,input().split())
A = list(map(int ,input().split()))

hw_days = sum(A)

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

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
aa = map(int, input().split())
total = 0
for a in aa:
    total += a
    if total > n:
        total = -1
        break

print(-1 if total == -1 else n - total)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
hw = []
hw = list(map(int, input().split()))

vacation_day = n - sum(hw)

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

Submission status: Accepted

Solution code:
import math

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))
n,m = iim()
A = iil()

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

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
aList = list(map(int, input().split()))

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
import numpy as np


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


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(M)]  # type: "List[int]"
    solve(N, M, A)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
## 2
#N, M = 314, 15
#A = [9, 26, 5, 35, 8, 9, 79, 3, 23, 8, 46, 2, 6, 43, 3]
N, M = map(int, input().split())
A = list(map(int, input().split()))


rest = N
for i in range(M):
    rest -= A[i]
    
if rest<0:
    print('-1')
else:
    print(rest)

Submission status: Accepted

Solution code:
M, N = map(int, input().split())
A = list(map(int, input().rstrip().split()))
sums = 0
for day in A:
    sums += day
if sums < M:
    result = M - sums
elif sums > M:
    result = -1
elif sums == M:
    result = 0
print(result)

Submission status: Accepted

Solution code:
mylist = []
n, m = map(int, input().split())
mylist += (map(int, input().split()))
if sum(mylist) > n:
    print(-1)
else:
    print(n - sum(mylist))

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, m = tuple(map(int, input().split(" ")))
print(max(n - sum(map(int, input().split(" "))), -1))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin,stdout

for _ in range(1):
	#n,shift,ch=stdin.readline().split()
	days,ass=map(int,stdin.readline().split())
	s=sum(map(int,stdin.readline().split()))
	ans=-1 if days-s<0 else days-s
	stdout.write(str(ans)+'\n')

Submission status: Accepted

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

count = sum(A)

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

Submission status: Accepted

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

a = sum(int(i) for i in a)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    n,m = map(int,input().split())
    arr = list(map(int,input().split()))
    total = sum(arr)
    if total > n:
        print(-1)
    else:
        print(n-total)
        

main()

Submission status: Accepted

Solution code:
a = input()
b = input()

days,home = [int(i) for i in a.split(" ")]
cost = [int(n) for n in b.split(" ")]
#print(days,home)
#print(cost)

validdate = int(days) - sum(cost)
if validdate >= 0:
    print(validdate)
else:
    print(-1)