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:
m, n = map(int, input().split())
A = list(map(int, input().split()))
for i in range(n):
    m -= A[i]
if m < 0:
    print("-1")
else:
    print(m)

Submission status: Accepted

Solution code:
D,N = input().split()
D = int(D)
N = int(N)
A = input().split()
for i in range(N):
    D -= int(A[i])
if D < 0 :
    print('-1')
else:
    print(str(D))

Submission status: Accepted

Solution code:
N,M = 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:
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
a=list(map(int,input().split()))
s=sum(a)
if s>n:
    print(-1)
else:
    print(n-s)

Submission status: Accepted

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

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

suma = sum(a)

tmp = n - suma

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

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
a1 = list(map(int, input().split())) 
ans = n - sum(a1)
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()))
print(max(n - sum(a), -1))

Submission status: Accepted

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

ans  = 0

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, m = [int(e) for e in input().split()]
wd = [int(e) for e in input().split()]

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

Submission status: Accepted

Solution code:
i = list(map(int,input().split()))
j = list(map(int,input().split()))
S=sum(j)

  
if i[0]>=S:
	print(i[0]-S)
else:
	print("-1")

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# summer vacations, number of assignments
N, M = list(map(int, input().split()))
# each entry in A represents number of days to do the assignment
A = list(map(int, input().split()))

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

Submission status: Accepted

Solution code:
yasumi = 0
syukudai = 1
nissu = list(map(int,input().split()))
syukudaiNissu = list(map(int,input().split()))
if sum(syukudaiNissu) > nissu[yasumi]:
  print(-1)
  exit()
print(nissu[yasumi] - sum(syukudaiNissu))

Submission status: Accepted

Solution code:
n, m = [int(m) for m in input().split()]
a = [int(m) for m in 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 = tuple(map(int, input().split()))

s = sum(a)

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

Submission status: Accepted

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

A = [int(i) for i in input().split()]
rest = N - sum(A)
if rest >= 0 :
	print(rest)
else :
	print('-1')

Submission status: Accepted

Solution code:
from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *
from sys import stdin
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
import math

def bin1(l,r,k,t,b,val,ans):
	if(l>r):
		return ans
	else:
		mid=(l+r)//2
		v=k**mid
		if(v==val):
			return v
		elif(v>val):
			ans=mid
			return bin1(mid+1,r,k,t,b,val,ans)
		else:
			return bin1(l,mid-1,k,t,b,val,ans)
		
def bin2(l,r,k,t,b,val,ans):
	if(l>r):
		return ans
	else:
		mid=(l+r)//2
		v=t*(k**mid)+b*(mid)
		if(v==val):
			return v
		elif(v>val):
			ans=mid
			return bin2(l,mid-1,k,t,b,val,ans)
		else:
			return bin2(mid+1,r,k,t,b,val,ans)

def SieveOfEratosthenes(n): 
      
    # Create a boolean array "prime[0..n]" and initialize 
    #  all entries it as true. A value in prime[i] will 
    # finally be false if i is Not a prime, else true. 
    prime = [True for i in range(n+1)] 
    p = 2
    while (p * p <= n): 
          
        # If prime[p] is not changed, then it is a prime 
        if (prime[p] == True): 
              
            # Update all multiples of p 
            for i in range(p * p, n+1, p): 
                prime[i] = False
        p += 1
    return prime
def bin(l,r,ll,val):
	if(l>r):
		return -1
	else:
		mid=(l+r)//2
		if(val>=ll[mid][0] and val<=ll[mid][1]):
			return mid
		elif(val<ll[mid][0]):
			return bin(l,mid-1,ll,val)
		else:
			return bin(mid+1,r,ll,val)
def deci(n):
	s=""
	while(n!=0):
		if(n%2==0):
			n=n//2
			s="0"+s
		else:
			n=n//2
			s="1"+s
	return s
def diff(s1,s2):
	if(len(s1)<len(s2)):
		v=len(s1)
		while(v!=len(s2)):
			s1="0"+s1
			v=v+1
	else:
		v=len(s2)
		while(v!=len(s1)):
			s2="0"+s2
			v=v+1
	c=0
	for i in range(len(s1)):
		if(s1[i:i+1]!=s2[i:i+1]):
			c=c+1
	return c
from sys import stdin, stdout 
if __name__ == '__main__':
	n,m=map(int,stdin.readline().split(" "))
	l=list(map(int,stdin.readline().split(" ")))
	total=sum(l)
	if(total>n):
		stdout.write(str(-1)+"\n")
	else:
		stdout.write(str(n-total)+"\n")

Submission status: Accepted

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


def solve(N: int, M: int, A: "List[int]"):
    if (N-sum(A) < 0):
        print(-1)
    else:
        print(N-sum(A))
    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:
a,b = map(int, input().split())
s = input()
count = 0
nums = s.rstrip().split(' ')
for num in nums:
  count += int(num)
c = a - count
if c >= 0:
  print(c)
else:
  print(-1)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

p = sum(a)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

else:
    print(N-A)

Submission status: Accepted

Solution code:
days, ass = map(int, input().split())
sum=0
List= list(map(int, input().split()))
for i in range(len(List)):
    sum+=List[i]
if sum>days:
    print(-1)
else:
    print(days-sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

B = sum(A)

if N >= B:
  print(N-B)

else:
  print('-1')

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:


def solve():
    N, M = map(int, input().split())
    A = [int(i) for i in input().split()]
    print(max(N - sum(A), -1))


if __name__ == '__main__':
    solve()

Submission status: Accepted

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


def main():
    import sys
    input = sys.stdin.readline
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    diff = n - sum(a)

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,m=map(lambda x:int(x),input().split())
num_list=list(map(lambda x:int(x),input().split()))

num_list_sum=sum(num_list)

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

Submission status: Accepted

Solution code:
n, m = 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()))


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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
import math
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")



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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
def abc(N, M, A):
    # 答えの準備
    ans = N
    
    # 繰返し引き算
    for i in range(0, M):
        ans -= A[i]
    
    # 負数の処理
    if ans < 0:
        ans = -1
    
    # 答え
    return(ans)


# バッチスタート
if __name__ == "__main__":
    # 標準入力処理
    # 1行目の入力を空白で分割された2つの数値として扱う
    N, M = map(int, input().split())
    
    # 2行目の入力を数値のリストとして扱う
    A = list(map(int, input().split()))
    
    # 関数呼び出し
    f = abc(N, M, A)
    
    # 答えの出力
    print(f)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
N,M = map(int,input().strip().split(" "))
A = np.empty(M)
A = np.array(input().strip().split(" ")).astype(np.int32)
res = N - A.sum()
if res >= 0:
    print(res)
else:
    print(-1)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Spyderエディタ

これは一時的なスクリプトファイルです
"""

n, m = map(int, input().split())
nums = [int(s) for s in input().split()]

asobi = n - sum(nums)

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

Submission status: Accepted

Solution code:
import numpy as np

N, M = input().split()

A=[int(x) for x in input().split()]

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

Submission status: Accepted

Solution code:
m,n = map(int,input().split())
l = list(map(int,input().split()))
s = 0
for i in range(n):
  s += l[i]
print(max(m-s,-1))

Submission status: Accepted

Solution code:
m,n = map(int,input().split())
l = list(map(int,input().split()))
s = 0
for i in range(n):
  s += l[i]
print(max(m-s,-1))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
l = list(map(int, input().split()))
n = sum(l)

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

Submission status: Accepted

Solution code:
n,m = input().split()
lists = list(int(x) for x in input().split())
a = int(n)-sum(lists)
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()))

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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-1]
x=sum
if N>=x:
    print(N-x)
else:
    print("-1")

Submission status: Accepted

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

Submission status: Accepted

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



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

Submission status: Accepted

Solution code:
#先にAの合計値を出してもよい
N, M = map(int, input().split())
A = list(map(int, input().split()))
suma = sum(A)
if N-suma>=0:
    print(N-suma)
else:
    print(-1)

Submission status: Accepted

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

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

Submission status: Accepted

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

total = 0
for time in times:
    total += time

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = input().split(" ")
a = input().split(" ")
n[0] = int(n[0])
sum_HomeworkDays = 0

for i in a:
	sum_HomeworkDays += int(i)
    
if n[0]-sum_HomeworkDays >= 0:
  print(n[0]-sum_HomeworkDays)
else:
  print("-1")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

sum=sum(a)

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

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

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

total = sum(a)

answer = n - total

if total > n:
    answer = -1

print(answer)

Submission status: Accepted

Solution code:
# B - Homework
def main():
    N, _, *A = map(int, open(0).read().split())
    print(max(-1, N - sum(A)))


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
print(max(int(input().split()[0]) - sum(map(int, input().split())), -1))

Submission status: Accepted

Solution code:
import numpy as np
N, M = list(map(int,input().split()))
a = list(map(int,input().split()))
s = np.sum(a)
if s <= N:
  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)
ans = -1 if ans < 0 else ans
print(ans)

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

Submission status: Accepted

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

l = 0
i = 0

for i in A:
    l += i

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

Submission status: Accepted

Solution code:
def main():
    N, M = map(int, input().split())
    li = list(map(int, input().split()))
    s = 0
    for i in range(M):
      s += li[i]

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

if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
N=()
M=()
A=()

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

Submission status: Accepted

Solution code:
NM = [int(s) for s in input().split()]
N, M = NM[0], NM[1]
arr = [int(s) for s in input().split()]
total = sum(arr)
if total <= N:
    print(N-total)
else:
    print(-1)

Submission status: Accepted

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

Submission status: Accepted

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

HW = list(map(int,input().split()))
Holidays = N -sum(HW)

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def Main():
    N, M = list(map(int, input().split(" ")))
    nSums = sum(list(map(int, input().split(" "))))
    
    playDays = N - nSums if nSums <= N else -1
    print(playDays)
    
    
if __name__ == "__main__":
    Main()

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
ret = sum([int(x) for x in input().split()])
print(max(N - ret, -1))

Submission status: Accepted

Solution code:
def main():
    N, M = map(int, input().split())
    HW = [int(a) for a in input().split()]
    if N >= sum(HW):
        print(N-sum(HW))
    else:
        print(-1)
if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

day = 0

for i in A:
    day += i

remaining = N-day

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

Submission status: Accepted

Solution code:
import numpy as np
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

N, M = map(int, input().split())
A = np.array(list(map(int, input().split())))
tot = np.sum(A)

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

Submission status: Accepted

Solution code:
import numpy as np
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

N, M = map(int, input().split())
A = np.array(list(map(int, input().split())))
tot = np.sum(A)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
NM = str(input()).split()
work = str(input()).split()
SV = int(NM[0])
for i in range(len(work)):

	SV -= int(work[i])
	if SV <= -1:
		SV = -1
		break

print(SV)

Submission status: Accepted

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

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

Submission status: Accepted

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

min_time=0
for i in range(M):
    min_time=min_time+necess[i]
    # print(i)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
days , assi = map(int,input().split())
lst = []
lst = [int(i) for i in input().split()]
tot = sum(lst)
if (tot>days):
    print(-1)
else:
    print(days-tot)

Submission status: Accepted

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

Submission status: Accepted

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

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

totalA = sum(A)

ans = N - totalA

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

Submission status: Accepted

Solution code:
a,b = input().split()
a = int(a)
c = []

c = input().split()

for i in range(int(b)):
	a-=int(c[i])

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())) #i_1 i_2を取得し、iに値を入れる
sum=0
for i in range(m):
    sum+=a[i]
if n>=sum:
    print(n-sum)
else:
    print(-1)

Submission status: Accepted

Solution code:
n,m = map(int, list(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()))
n=sum(A)
if N-n>=0:
  print(N-n)
else:
  print(-1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
n,m=map(int,input().split())
arr=list(map(int,input().split()))
ss=sum(arr)
if n<ss:
	print(-1)
else:
	print(n-ss)

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]

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

Submission status: Accepted

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