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

Submission status: Accepted

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

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

Submission status: Accepted

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

plays = n - sum(works)
print(plays if plays >= 0 else -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(ans)
else:
    print(-1)

Submission status: Accepted

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

playday = n - sum(days)

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

Submission status: Accepted

Solution code:
data = input().rstrip().split(" ")
day = int(data[0])
task = int(data[1])
need = 0
hw = input().rstrip().split(" ")
for i in range(task):
    need += int(hw[int(i)])
answer = day - need
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()))

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
N, _ = map(int, input().split())
s = sum(map(int, input().split()))

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Su = sum(A)

if Su > T[0]:
    print(-1)
else:
    print(T[0]-Su)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, m = [int(w) for w in input().split()]
a = [int(w) for w in input().split()]
a_sum = sum(a)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

free = n - sum(a_list)
if free<-1:
    free = -1

print(free)

Submission status: Accepted

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

Submission status: Accepted

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

tmp2 = input().split()
TotalDays = 0

for i in tmp2:
    TotalDays = TotalDays + int(i)

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

Submission status: Accepted

Solution code:
S = [input() for i in range(2)]
I = S[0].split()
N = int(I[0])
M = int(I[1])
A = list(map(int,S[1].split()))
# print(N)
# print(M)
# print(A)
D = N - sum(A)
if D < 0 :
    D = -1 
print(D)

Submission status: Accepted

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

left=n-sum(a)

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

Submission status: Accepted

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

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

holiday = n - sum(workday_list)

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

Submission status: Accepted

Solution code:
n,m = input().split()
ai = [int(s) for s in input().split()]
count = 0
for i in ai:
    count += i
result = int(n) - count
if result < 0:
    print('-1')
else:
    print(result)

Submission status: Accepted

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

    homework_days = sum(A)

    if N - homework_days < 0:
        return -1
    else:
        return N -homework_days

print(main())

Submission status: Accepted

Solution code:
def to_do():
    N,M=map(int,input().split())
    day_list=list(map(int,input().split()))
    sum=0
    for i in range(0,M):
        sum=sum+day_list[i]
    if sum>N:
        print(-1)
    if sum<=N:
        print(N-sum)
if  __name__=="__main__":
    to_do()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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:
import math 
a = input().split()
days = int(a[0])
num = int(a[1])

b = input().split()
sum = 0
for i in range(num):
    sum += int(b[i])

if days >= sum:
    print(days-sum)
else:
    print(-1)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import numpy
import math

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

sum = sum(a)

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

Submission status: Accepted

Solution code:


def main():
    N, M = map(int, input().split(' '))
    A = tuple(map(int, input().split(' ')))

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
a=[ int(i) for i in input().split()]
if(N-sum(a)<0):
    print('-1')
    exit(0)
print(N-sum(a))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
line_1 = input().split()
line_2 = input().split()
line_1 = list(map(lambda x: int(x), line_1))
line_2 = list(map(lambda x: int(x), line_2))

n = line_1[0]
m = line_1[1]

if (n < m):
  print(-1)
else:
  a = sum(line_2)
  r = n - a
  
  if (r < 0):
    print(-1)
  else:
    print(r)

Submission status: Accepted

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

Submission status: Accepted

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

#print(a)

b = sum(a)

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

Submission status: Accepted

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

x = n-sum(alist)

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

Submission status: Accepted

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

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

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

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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



goukei = sum(A)

Ans = N - goukei

if Ans >= 0:
    print(Ans)
else:
    print(-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:
aa = input().split(' ')
dayOf = input().split(' ')
sum = 0
for needs in dayOf:
  sum = int(sum) + int(needs)
print(int(aa[0]) - sum if sum <= int(aa[0]) else '-1')

Submission status: Accepted

Solution code:
n,m = map(int,raw_input().split(' '))
a = n - sum(map(int,raw_input().split(' ')) or [0])
print a if a >= 0 else -1

Submission status: Accepted

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

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

a=0
for i in range(l[1]):
  a+=s[i]


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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import numpy
import math

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

sum = sum(a)

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(' ')))
sum_a = 0
for i in a:
    sum_a += i
if sum_a > N:
    print(-1)
else:
    print(N - sum_a)

Submission status: Accepted

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

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

Submission status: Accepted

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

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:
N, M = list(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())
#M 夏休み期間　M　宿題数
A = list(map(int, input().split()))
A_sum = 0
for i in range(0, M):
    A_sum += A[i]
    # A_sum 宿題全日数
x = N - A_sum
if x < 0:
    print("-1")
else:
    print(x)

Submission status: Accepted

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

Submission status: Accepted

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

if a[0] >= b:
  print(a[0] - b)
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:
a,b = map(int, input().split())
#days = map(int, input().split())
days = input().split()

sum = 0
for i in days:
	sum = sum + int(i)

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

Submission status: Accepted

Solution code:
import sys

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

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

if sum(l) > n:
  print(-1)
  sys.exit()

print(n - sum(l))

Submission status: Accepted

Solution code:
#! env/bin/local python3
# -*- coding:utf-8 -*-

# -- submit ----

# --- fetch input ---

inputs: list = []
while True:
    try:
        inputs.append(input().strip('\n'))
    except EOFError:
        break

# --- write code below ---

days = int(inputs[0].split(' ')[0])
task_costs = inputs[1].split(' ')
task_costs = [int(t) for t in task_costs]
result = days - sum(task_costs)

print(f'{result if result >= 0 else -1}')

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
a=input().split(' ')
#print(a[0])
b=int(a[0])
d=int(a[1])
c=input().split(' ')
count=0
for i in c:
    count+=int(i)
    
#print(count)
if b-count>=0:
    print(b-count)
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 = [int(x) for x in 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()))

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

Submission status: Accepted

Solution code:
day_num, homework_num = map(int, input().split(" "))

requ_day = list(map(int, input().split()))
sum_day = 0

for day in requ_day:
  sum_day += day
  
activ_day = day_num - sum_day

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

Submission status: Accepted

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

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

work_days = sum(An)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def inpl(): return list(map(int, sys.stdin.readline().split()))
# 直接输入成list

x = inpl()
y = inpl()
for i in range(0, x[1]):
    x[0] -= y[i]

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

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

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

Submission status: Accepted

Solution code:
import sys
import math
from collections import deque
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def S(): return sys.stdin.readline()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h,w): return [[i for j in range(w)] for k in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**6+10)
input = sys.stdin.readline

N,M = MI()
l = LI()
n = N
for i in l:
    n = n-i
    if n<0:
        print(-1)
        break
else:
    print(n)

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

sum_a = 0

for i in range(n):
    sum_a += a[i]

if m < sum_a:
    print(-1)
else:
    print(m-sum_a)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
holidays, homeworks = input().split(' ')
holidays = int(holidays)
homeworks = int(homeworks)

days_per_homework = input().split(' ')
days_to_finish = 0
for _days in days_per_homework:
    days_to_finish = days_to_finish + int(_days)

if days_to_finish <= holidays:
    print(holidays - days_to_finish)
else:
    print(-1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
  N,M=map(int,input().split())
  A=list(map(int,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())
a = list(map(int, input().split()))

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

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

Submission status: Accepted

Solution code:
from functools import reduce

n, m = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
sum = reduce(lambda x, y: x + y, a)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N , M = input().split(" ")
Ai = input()
A = Ai.split(" ")
tm = 0
for i in A:
    tm = tm + int(i)
max = int(N)-tm
if max >= 0:
    print(int(N)-tm)
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 = (int(x) for x in input().split())
take = list(map(int, input().split()))
for per in take:
    n -= per

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

Submission status: Accepted

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

sum = 0

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

for i in list(a):
    sum += i

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

Submission status: Accepted

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

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

total_time = 0

for i in A:
    total_time += i

if total_time <= N:
    print(N-total_time)
elif total_time > N:
    print(-1)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

s = sum(l)

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

Submission status: Accepted

Solution code:
from sys import stdin, stdout
from collections import defaultdict
import math

N, M = map(int, stdin.readline().strip().split())
arr = list(map(int, stdin.readline().strip().split()))

ans = N - sum(arr)
stdout.writelines(str(-1 if ans < 0 else ans) + '\n')

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
plan = list(map(int,input().split()))
sum = N
for i in range(M):
  sum = sum - plan[i]

if 0 <= sum <= N:
  print(sum)

else:
  print('-1')

Submission status: Accepted

Solution code:
#B
NM = input().split(' ')
N = int(NM[0]) ; M = int(NM[1])
Ai = input().split(' ')
sum_Ai = 0
for k in Ai:
    k = int(k)
    sum_Ai += k
if sum_Ai > N:
    print(-1)
else:
    print(N - sum_Ai)

Submission status: Accepted

Solution code:
num = input().split(" ")
num2 = input().split(" ")

a = int(num[1])

sum = 0
for i in num2:
  sum = sum + int(i)

b = int(num[0])-sum

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

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
A=list(map(int,input().split()))
B=0
for i in A:
    B=B+i       
N=N-B
if 0<=N:
    print(N)
else:
    print(-1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

N,M = [int(i) for i in input().split()]
A=np.array([int(i) for i in input().split()])

S = np.sum(A)

p = N-S

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

Submission status: Accepted

Solution code:
#! /usr/bin/env python
# -*- coding: utf-8 -*-

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

if __name__ == '__main__':
	main()

Submission status: Accepted

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

Submission status: Accepted

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

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

x = 0
for i in range(0, len(a)):
  x = x + a[i]
  
x = int(x)
play_day = n - x

if x > n:
  print("-1")
else:
  print(play_day)

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:
def resolve():
    day, w = map(int, input().split())
    work_list = list(map(int, input().split()))
    can_game = day - sum(work_list)
    if 0 > can_game:
        print(-1)
    else:
        print(can_game)

resolve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

sum_day = sum(day_list)
remain_day = n - sum_day
if remain_day >= 0:
    print(remain_day)
else:
    print(-1)

Submission status: Accepted

Solution code:
import numpy as np
days, count = map(int, input().split())
sum = np.sum(list(map(int, input().split())))
if sum <= days:
    print(days-sum)
else:
    print(-1)

Submission status: Accepted

Solution code:
import math

days, count = map(int, input().split())
sum = sum(list(map(int, input().split())))
if sum <= days:
    print(days - sum)
else:
    print("-1")

Submission status: Accepted

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

ans=N-sum(As)

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

Submission status: Accepted

Solution code:
N, M = map(int,input().split())
A = list(map(int,input().split()))
#print(A)
if sum(A) <= N:
    print(N-sum(A))
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()]
print([N-sum(A),-1][int(0>N-sum(A))])

Submission status: Accepted

Solution code:
line = input()
niti = line.split()
linit_time = int(niti[0])


line2 = input()
time =line2.split()
total_time =0

for i in range(int(niti[1])):
  total_time +=int(time[i])

if linit_time - total_time < 0:
  print(-1)
else:
  print(linit_time - total_time)

Submission status: Accepted

Solution code:
N, _ = map(int, input().split())
result = N - sum(list(map(int, input().split())))
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()))  

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = input().split(" ")
b = input().split(" ")
c = 0
for i in b:
    c += int(i)
if int(a[0]) >= c:
    print(int(a[0]) - c)
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(N-sum(A))
else:
    print(-1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
vacation_day,homework_num=map(int,input().split())
homework_spent_list=list(map(int,input().split()))
ans=vacation_day-sum(homework_spent_list)
if ans < 0:
	print(-1)
else:
	print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    # N: 夏休み日数, M: 宿題個数
    N, M = map(int, input().split(" "))
    # 宿題実行にかかる日数
    Asum = sum(map(int, input().split(" ")))

    print(max(N - Asum, -1))