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

sum_a = sum(a)
rest = n - sum_a

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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())
homework = list(map(int, input().split()))
homework_day = sum(homework)
rest_summer_vacation = N - homework_day
if rest_summer_vacation < 0:
    print('-1')
else:
    print(str(rest_summer_vacation))

Submission status: Accepted

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

for i in range(M):
    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()))
tmp = n-sum(A)

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

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
s=0
a=list(map(int,input().split()))
for x in a:
    s=x+s
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().strip().split()))

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

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

Submission status: Accepted

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

play_days = N - sum(A_list)

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

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

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()))
for x in range(len(a)):
    n-=a[x]
if n<0:
    n=-1
print(n)

Submission status: Accepted

Solution code:
first = input().split(" ")
n = int(first[0])
m = int(first[1])
second = input().split(" ")

for i in range(m):
    n -= int(second[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 i in range(M):
    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()))

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

Submission status: Accepted

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

Submission status: Accepted

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

Array=map(int,input().split())
A=[]
for i in Array:
    A.append(i)

days=N
for i in range(M):
    days-=A[i]

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

Submission status: Accepted

Solution code:
a=[int(x) for x in input().split()]
b=[int(x) for x in input().split()]
c=sum(b)

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

Submission status: Accepted

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

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

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

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

sum_A = sum(A)

if sum_A <= N:
  print(str(N-sum_A))
else:
  print("-1")

Submission status: Accepted

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


main()

Submission status: Accepted

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

s = sum(a)
ans = n - s

print(ans if ans >= 0 else "-1")

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

for num in a:
    n = n - num

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

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

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

Submission status: Accepted

Solution code:
n, m = (int(x) for x in input().split())
a = [int(x) for x 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())
a = [i for i in 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(" ")))
print(max(-1, n-sum(a)))

Submission status: Accepted

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

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

Submission status: Accepted

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

############ ---- Input Functions ---- ############
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))
    
n, m = invr()
A = invr()

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

Submission status: Accepted

Solution code:
holidays, num_of_homework = map(int, input().split())
days = list(map(int, input().split()))

playingdays = holidays - sum(days)
if playingdays < 0:
    print('-1')
else:
    print(playingdays)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

for i in range(m):
  s=s+a[i]
if s>n:
  print(-1)
else:
  print(n-s)

Submission status: Accepted

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

total = sum(line)

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

Submission status: Accepted

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

work = sum(a)
play = n - work

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
N, M = input().strip().split()
a = list(map(int, input().strip().split()))
N, M = [int(N), int(M)]
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()))
print(n - sum(A) if n >= sum(A) else -1)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

ASOBU = N - sum(A)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = input().split()
y = input().split()
n = int(x[0])
m = int(x[1])
count = 0
for i in y:
  count += int(i)
if (n - count) >= 0:
  print(n-count)
else:
  print('-1')

Submission status: Accepted

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

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=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(N - sum(A), -1))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

ans = N - sum(A)

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

Submission status: Accepted

Solution code:

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

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

a = n -sum(li)

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#n, m, q = map(int, input().split())
#List = list(map(int, input().split()))
#req = [list(map(int, input().split())) for _ in range(q)]
#t = t[:-1]
n, m = map(int, input().split())
a = list(map(int, input().split()))

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

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

Submission status: Accepted

Solution code:

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
day , amt = map(int,input().split())

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

for i in hw_list:
  day -= i
  
if day < 0:
  print("-1")
else:
  print(day)

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
list=list(map(int,input().split()))
n=0
while n<M:
  N = N-list[n]
  n=n+1

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
A = [i for i in map(int, input().split())]
hwday = sum(A)
D = N - hwday
if D >= 0:
    print(D)
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:
N, M = map(int,input().split())
A = list(map(int,input().split()))
sumA = sum(A)
if N >= sumA:
  print(N-sumA)
else:
  print(int(-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()))
i=0
j=0
while i<m:
    j+=a[i]
    i+=1
ju=n-j
if ju<0:
    print(-1)
else:
    print(ju)

Submission status: Accepted

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

sum_a = sum(a)

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

Submission status: Accepted

Solution code:
n,m = (int(x) for x in input().split())
days = 0
ar = [int(x) for x in input().split()]

for v in ar:
    n-=v

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

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

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

Submission status: Accepted

Solution code:
import math

ex = []
N, M = map(int, input().split())
ex = [exi for exi in map(int, input().split())]

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
a=list(map(int,input().split()))
p=0
for i in a:
      p+=i
if(n>=p):
          print("{}".format(n-p))
else:
          print("-1")

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(M):
  N -= A[i]

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())

n, m = ISI()
l=ILI()
if n-sum(l)<0:print(-1)
else:print(n-sum(l))

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

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
L=list(map(int,input().split()))
day=0
flg=True

for i in range(m):
    day+=L[i]
    if day>n:
        flg=False
        break

if flg:
    print(n-day)
else:
    print("-1")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from collections import deque
import copy
def main():
    N, M = map(int, input().split())
    A = [int(i) for i in input().split()]
    count = sum(A)
    if N - count < 0:
        print(-1)
    else:
        print(N - count)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
from collections import deque
import copy
def main():
    N, M = map(int, input().split())
    A = [int(i) for i in input().split()]
    count = 0
    for i in range(M):
        count += A[i]
    if N - count < 0:
        print(-1)
    else:
        print(N - count)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

sum_A = sum(A)
remain = N - sum_A

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

Submission status: Accepted

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

if s>N:
  print(-1)
  exit()
  
print(N-s)

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
A=list(map(int,input().split()))
sum=0
for a in A:
  sum+=a

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

Submission status: Accepted

Solution code:
line=input()
n,k=map(int,line.split())
pine=input()
koko=pine.split()
koko=map(int,koko)
koko=list(koko)
s=sum(koko)
d=n-s
if d<0:
     print(-1)
else:
     print(d)

Submission status: Accepted

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

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

a = sum(al)

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

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

        total = sum(A)

        if total>N:
                ans = -1
        else:
                ans = N-total

        print("{}".format(ans))

if __name__=="__main__":
        main()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n, m = map(int, input().split())
    sum_a = sum(list(map(int, input().split())))
    ans = n - sum_a
    if ans < 0:
        print(-1)
    else:
        print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
data = list(map(int,input().split()))
s = sum(data)
ans = N - s
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()))

days = 0

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

remaining = n-days

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

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

count=0

for i in A :
    count += i
    if count > n :
        #print("-1")
        break
    else :
        pass

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
#N: 夏休みの日数, M: 宿題にかかる日数

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

assignments = [int(a) for a in input().split(' ')]
total_a = sum(assignments)
if total_a <= n:
    print(n-total_a)
else:
    print(-1)

Submission status: Accepted

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

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

Submission status: Accepted

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

if M < sum(l):
  print(-1)
else:
  print(M - sum(l))

Submission status: Accepted

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

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

kakaru = 0

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

ans = n - kakaru

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

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

Submission status: Accepted

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


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

Submission status: Accepted

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

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

Submission status: Accepted

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

free = N - sum(l)
print( -1 if free<0 else free)

Submission status: Accepted

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

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

Submission status: Accepted

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

free = N
s = sum(l)

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

Submission status: Accepted

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

free = N
s = 0
for i in l:
	s += i

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

Submission status: Accepted

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

free = N
for i in l:
	free -= i
    
if free<0:
    print(-1)
else:
    print(free)

Submission status: Accepted

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

if sum(A) <= N:
    result = N - sum(A)

print(result)

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:
N,M = map(int, input().split())
A = list(map(int, input().split()))
sum = 0
for i in range(M):
    sum = sum + A[i]
date = -1
if N-sum >= 0:
    date = N-sum
print(date)

Submission status: Accepted

Solution code:
def solve(string):
    n, m, *a = map(int, string.split())
    return str(b if (b := n-sum(a)) >= 0 else -1)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

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 = [int(x) for x in input().split()]
A = [int(a) for a in input().split()]
tmp = N - sum(A)
if tmp >= 0:
    print(tmp)
else:
    print(-1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
in1 = input().split()
N = int(in1[0])
M = int(in1[1])
in2 = input().split()
days = 0
for i in range(M):
    days+=int(in2[i])
if days>N:
    print(-1)
else:
    print(N-days)

Submission status: Accepted

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

ta = sum(As)

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

Submission status: Accepted

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

l = 0

for i in a:
  l += i

if A < l:
  print(-1)
else:
  print(A-l)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
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:
d,h=map(int,input().split())
alist=list(map(int,input().split()))
x=sum(alist)
if x<=d:
  print(d-x)
else:
  print(-1)

Submission status: Accepted

Solution code:
# ABC163B

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

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