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

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

Submission status: Accepted

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

Submission status: Accepted

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

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(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:
N, M = map(int, input().split())
A = [int(x) for x in input().split()]

sm = sum(A)

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

Submission status: Accepted

Solution code:
def main():
    nm = [int(_x) for _x in input().split()]
    n = nm[0]
    m = nm[1]
    a = [int(_x) for _x in input().split()]
    result = n - sum(a)
    if result < 0:
        print(-1)
    else:
        print(result)


main()

Submission status: Accepted

Solution code:
# B - Homework

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

days = sum(a)

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

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

result = n-sum(a)

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

Submission status: Accepted

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

h=sum(a)

if n<h:
  print('-1')
else:
  print(n-h)

Submission status: Accepted

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

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

if N-sum(sumlist)>=0:
  print (N-sum(sumlist))
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()))
B=sum(A)

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

Submission status: Accepted

Solution code:

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

Submission status: Accepted

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

Submission status: Accepted

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

    A_day = sum(A)
    hangout = N - A_day

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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



else:
    print(n-x)

Submission status: Accepted

Solution code:

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]
 
n, m = getList()
nums = getList()
sn = sum(nums)
if sn > n:
  print(-1)
else:
  print(n - sn)

Submission status: Accepted

Solution code:

ri = lambda S: [int(v) for v in S.split()]

N, M = ri(input())
A = ri(input())
s = sum(A)
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()))
for i in a:
  n -= 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()))

for i in a:
    n -= i
if n < 0:
    print(-1)
else:
    print(n)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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:
import sys

nm = input().split()
N = int(nm[0])
M = int(nm[1])

As = [int(a) for a in input().split()]

s = sum(As)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Sam = sum(A)

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

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

Submission status: Accepted

Solution code:
N, M = input().split()
N = int(N)
M = int(M)
A = list(map(int, input().split()))
LA = len(A)
i = 0
SUM = 0

for i in range(LA):
    SUM = 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()))
a = sum(A)
 
if N >= a:
  print(int(N-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 = map(int, input().split()) 
A = list(map(int, input().split()))
 
# N-sum(A)が残り日数である
s = sum(A)
ans = -1
if N >= s: ans = N - s
print(ans)

Submission status: Accepted

Solution code:
n = input()
n = n.split()
m = int(n[1])
n = int(n[0])
a = input()
a = a.split()
b = int(a[0])
for c in range(m-1):
    b = b + int(a[c+1])
if n - b < 0:
    print("-1")
else:
    print(n-b)

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 = ans+a[i]

day=n-ans

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

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

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_homework_day = sum(A)

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

for i in range(0, m):
    n -= list_a[i]
    if n < 0:
        print('-1')
        exit()
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:
n,m = map(int, input().split())
x = n-sum(list(map(int, input().split())))

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

Submission status: Accepted

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

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

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

for time in a:
    n -= time
    if n<0:
        n = -1
        break

print(n)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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



if '__main__' == __name__:
    resolve()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
l=list(map(int,input().split()))
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()))
availability = N
for i in range(M):
    availability -= A[i]

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

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:
r=input().split()
N=int(r[0])
d_pre=input().split()
d=[int(s) for s in d_pre]
ans=N-sum(d)
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()))
ans = N - sum(A)
if ans < 0:
    ans = -1
print(ans)

Submission status: Accepted

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

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

    if  N < cnt:
        return -1
    else:
        return N - cnt

print(main())

Submission status: Accepted

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

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

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

Submission status: Accepted

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

remain = N - sum(Ai)
if remain < 0:
    print("-1")
else:
    print(f"{remain}")

Submission status: Accepted

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

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

Submission status: Accepted

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

sum_a = sum(a_array)

if n - sum_a < 0:
    ans = -1
else:
    ans = n - sum_a

print(ans)

Submission status: Accepted

Solution code:
N,M = list(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(N - sum)
elif N == sum:
	print(0)
else:
	print(-1)

Submission status: Accepted

Solution code:
N,X = map(int,input().split())
Y = N - sum(map(int,input().split()))
print(("-1",Y)[Y >= 0])

Submission status: Accepted

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

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

hw_list = map(int, input().split())
for hw in hw_list:
    N -= hw

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

for i in range(m):
    t += a[i]
    if t > n:
        break
if t > n:
    ans = -1
else:
    ans = n - t

print(ans)

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

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

Submission status: Accepted

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

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

for i in a:
    cnt+=i
   
if n-cnt<0:
    print(-1)

else:
    print(n-cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = 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()))
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()))
a = sum(a)
if a > n:
  print(-1)
else:
  print(n-a)

Submission status: Accepted

Solution code:
x=input()
y=x.split(" ")
n=int(y[0])
g=input()
h=g.split(" ")
su=0
for b in h:
    su+=int(b)
if(su>n):
    print(-1)
else:
    print(n-su)

Submission status: Accepted

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

Submission status: Accepted

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

total = 0
for i in range(m):
    total = total + a[i]
if (n -total) < 0:
    print(-1)
else:
    print(n - total)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

main()

Submission status: Accepted

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

if __name__ == "__main__":
    solve()

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

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# Homework
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:
n,m = map(int, input().split())
a = list(map(int, input().split()))
syukudai = 0

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

Submission status: Accepted

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

for aa in a:
  n-=aa
if n >=0:
  print(n)
else:
  print(-1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
MM = map(int,input().split())
total = 0
for i in MM:
 
  total +=i
ans = N -total
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()))

a_sum = sum(a)

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

Submission status: Accepted

Solution code:

if __name__ == '__main__':
    """
    :param N: days
    :param M: num of homeworks
    :param A: days to finish each homework
    """
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    need = sum(A)
    if N >= need:
        print(N-need)
    else:
        print(-1)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
def main():
    N, M = map(int, input().split())
    A = [int(x) for x in input().split()]

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

s = int(sum(a))

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N, M = MI()
A = LI()
ans = N - sum(A)
if ans >= 0:
    print(ans)
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(' ')]
r = N - sum(A)
print(r if r >= 0 else -1)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
a = [int(s) for s in input().split()]
daycount = 0
for i in range(m):
    daycount += a[i]
if n - daycount >= 0:
    print(n - daycount)
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 range(m):
    day += a[i]
print(-1 if day>n else n - day)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines

def main():
    n, m, *a = map(int, read().split())
    suma = sum(a)
    if n < suma:
        print(-1)
    else:
        print(n - suma)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

for a in A:
    n-=a
if n<0:
    n=-1 
print( n )

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
tmp = input().split(" ")
N = int(tmp[0])
M = int(tmp[1])
ary = list(map(lambda n: int(n), input().split(" ")))
n = sum(ary)
print(-1) if N < n else print(N - n)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

z = n - sum(a)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

    tot = sum(A)

    diff = max(-1, N - tot)

    print(diff)


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)

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

Submission status: Accepted

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

A_sum = sum(A)
ans = N - A_sum

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

Submission status: Accepted

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

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

Submission status: Accepted

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

c = 0
for i in range(n):
  c += p[i]
  
if c > a:
  print(-1)
else:
  print(a-c)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
L = map(int,input().split())
work = 0
for i in L :
    work += i
if N >= work :
    print ( N - work )
else :
    print ("-1")

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
L = map(int,input().split())
res = 0
for i in L :
    res += i
if N >= res :
    print ( N - res )
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(-1)
else:
    print(N-A)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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())
ans = 0
for i in map(int,input().split()):
    ans += i

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

Submission status: Accepted

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