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: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

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

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

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

Submission status: Wrong Answer

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: Wrong Answer

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

s = 0
for n in A:
	s += n
    
d = N - s

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(n-sum(a))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for num in range(y):
    x -= A[num]

print(x)

Submission status: Wrong Answer

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: Wrong Answer

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

for i in range(m):
  n-=a[i]
if n > -1:
	print(n)
elif n < -1:
	print(-1)

Submission status: Wrong Answer

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: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

sm = sum(A)
count = N - sm
print(count)

Submission status: Wrong Answer

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)
print(n - count)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math

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

    return 0

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
X, Y  = input().split()
sum = 0
Y2 = input().split()
for i in range(0, int(Y)):
  sum += int(Y2[i])

if int(X)-sum > 0:
  print(int(X)-sum)
else:
  print(-1)

Submission status: Wrong Answer

Solution code:
import numpy as np

A=list(input().split())

print(A, A[0], int(A[0]))

N=int(A[0])
M=int(A[1])

B=list(input().split())

k=0

for i in range(len(B)):
    k+=int(B[i])

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
print(sum([int(r) for r in input().split(" ")])-sum([int(r) for r in input().split(" ")]))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read
 
 
n,m = map(int,input().split())

a = list(map(int, input().split()))  # n個の文字列がリストに格納される

print(n-sum(a))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

hwdsum=0
k=0
while k<= m-1:
  hwdsum += a[k]
  k+=1
  
if n-hwdsum>=0:
  print(str(hwdsum))
  
else:
  print(str(-1))

Submission status: Wrong Answer

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

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

print(N-sum(A))

Submission status: Wrong Answer

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

print(N-S)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
N, M = map(int, input().split())
A_list = np.array(list(map(int, input().split())))

total = np.sum(A_list)
free_day = max(N - M, -1)
print(free_day)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N=[int(x) for x in input().split()]
A=[int(x) for x in input().split()]
sum=0
for a in range(N[1]):
    sum=sum+A[a]
if sum>=0:
   print(N[0]-sum)
else:
   print(-1)

Submission status: Wrong Answer

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

a = input().split()
for i in range(len(a)):
	a[i] = int(a[i])
	
if n > sum(a):
	print(n-sum(a))
else:
	print(-1)

Submission status: Wrong Answer

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

a = input().split()
for i in range(len(a)):
	a[i] = int(a[i])
	
if n > sum(a):
	print(n-sum(a))
else:
	print("-1")

Submission status: Wrong Answer

Solution code:
a = input()
b = input()
temp = a.split()
n = int(temp[0])
m = int(temp[1])



ai = b.split()

sum = 0

for i in range(m):
    sum += int(ai[i])

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

Submission status: Wrong Answer

Solution code:
a = input()
b = input()
temp = a.split()
n = int(temp[0])
n -= 1
m = int(temp[1])



ai = b.split()

sum = 0

for i in range(m):
    sum += int(ai[i])

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

Submission status: Wrong Answer

Solution code:
a = input()
b = input()
temp = a.split()
n = int(temp[0])
m = int(temp[1])



ai = b.split()

sum = 0

for i in range(m):
    sum += int(ai[i])

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
from sys import *
inp=stdin.readline

zip=zip 
def linp(x):
    return list(map(int,x.split()))
def minp(x):
    return map(int,x.split())

n,m=minp(inp())
a=linp(inp())
an=sum(a)-n
if an>=0:
    print(an)
else:
    print("-1")

Submission status: Wrong Answer

Solution code:
import math
from sys import *
inp=stdin.readline

zip=zip 
def linp(x):
    return list(map(int,x.split()))
def minp(x):
    return map(int,x.split())

n,m=minp(inp())
a=linp(inp())
print(sum(a)-n)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def days(n,arr):
  s = sum(arr)
  if s > n:
    print(-1)
    return
  else:
    print(n-s)
    return

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
days, num = map(int, input().split())
hwk = map(int, input().split())
if days >= sum(hwk):
  print(days - sum(hwk))
else:
  print(-1)

Submission status: Wrong Answer

Solution code:
days, num = map(int, input().split())
hwk = map(int, input().split())
print(days - sum(hwk))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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: Wrong Answer

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

all_done_days = sum(a_list)

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

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
a=[int(b) for b in input().split()]
def func(n,a):
    if n< sum(a):return "-1"
    else: 
        return n-sum(a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

n = s1[0]
m = s1[1]

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

lt = 0

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

ld = n - lt

if ld > n:
    print("-1")
else:
    print(ld)

Submission status: Wrong Answer

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: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
data = input().rstrip().split(" ")
print(data)
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: Wrong Answer

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: Wrong Answer

Solution code:
line_1 = input().split()
N = int(line_1[0])
line_2 = input().split()
M = list(map(int,line_2))
 
Ms = sum(M)
 
if N-Ms > 0 :
  print(N-Ms)
else:
  print(-1)

Submission status: Wrong Answer

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]
print(N)

Submission status: Wrong Answer

Solution code:
line_1 = input().split()
N = int(line_1[0])
line_2 = input().split()
M = list(map(int,line_2))

Ms = sum(M)

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

Submission status: Wrong Answer

Solution code:
line_1 = input().split()
N = int(line_1[0])
line_2 = input().split()
M = list(map(int,line_2))

Ms = sum(M)

print(Ms-N)

Submission status: Wrong Answer

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: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import collections
 
n,m = map(int,raw_input().split(' '))
print n - sum(map(int,raw_input().split(' ')) or [0])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
D, n = map(int,input().split())
#D 夏休み期間　n　宿題数
A = list(map(int, input().split()))
A_sum = 0
for i in range(0, n):
    A_sum += A[i]
    # A_sum 宿題全日数
x = D - A_sum
print(x)

Submission status: Wrong Answer

Solution code:
map(int, input().split(' '))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N , M = input().split(" ")
A = input()
Ai = A.split(" ")
tm = 0
for i in Ai:
    tm = tm + int(i)
print(int(N)-tm)

Submission status: Wrong Answer

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: Wrong Answer

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: Wrong Answer

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

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

Submission status: Wrong Answer

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 sum >= 0:
  print(plan)

else:
  print('-1')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

sum_day = sum(day_list)
print(n - sum_day)

Submission status: Wrong Answer

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

ai = input().split(" ") 
l_ai = [int(s) for s in ai]

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

suma = sum(a)

tmp = n - suma

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

Submission status: Wrong Answer

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

if sum(A)==N:
  print(-1)
else:
  for i in A:
    N=N-i
  print(N)

Submission status: Wrong Answer

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

for i in A:
  N=N-i
print(N)

Submission status: Wrong Answer

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: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
a,b = map(int, input().split())
s = input()
count = 0
nums = s.rstrip().split(' ')
for num in nums:
  count += int(num)
print(a-count)

Submission status: Wrong Answer

Solution code:
days, _ = [int(i) for i in input().strip().split()]
hw = [int(i) for i in input().strip().split()]
print(days - sum(hw))

Submission status: Wrong Answer

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

p = sum(a)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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: Wrong Answer

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

diff = N - sum(A)

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

Submission status: Wrong Answer

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

A = [int(i) for i in range(M)]

B = sum(A)

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

else:
  print('-1')

Submission status: Wrong Answer

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

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

B = sum(A)

if M <= B:
  print(N-B)

else:
  print('-1')

Submission status: Wrong Answer

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

B = sum(A)

if M <= B:
  print(N-B)

else:
  print('-1')

Submission status: Wrong Answer

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

B = sum(A)

if M < B:
  print(N-B)

else:
  print('-1')

Submission status: Wrong Answer

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

B = sum(A)

if M < B:
  print(N-B)

else:
  print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
d, n = list(map(int, input().split()))
work = list(map(int, input().split()))
sumwork = sum(work)
ans = d - sumwork
print(ans)

Submission status: Wrong Answer

Solution code:
d, n = map(int, input().split()) 
work = map(int, input().split())
sumwork = sum(work)
ans = d - sumwork
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

N, M = input().split()

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

sum = 0
for i in range(M):
  sum += A[i]
print(str(N - sum))

Submission status: Wrong Answer

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



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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N,_=input().split()
a=map(int,input().split())
print(int(N)-sum(a))

Submission status: Wrong Answer

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: Wrong Answer

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

print(SV)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

c = input().split()

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

print (a)

Submission status: Wrong Answer

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

print(N-sum(A))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if A>sum(Lis):
    print(A-sum(Lis))

else:
    print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(n - sum(a))

Submission status: Wrong Answer

Solution code:
t=list(map(int,input().split()))		
s=list(map(int,input().split()))		
 
temp = 0
for i in s:
  temp += i

# print(temp)
if(t[0]-temp>=0):
  print(s[0]-temp)
else:
  print(-1)

Submission status: Wrong Answer

Solution code:




t=list(map(int,input().split()))		
s=list(map(int,input().split()))		
 
temp = 0
for i in s:
  temp += i

print(temp)
if(t[0]-temp>=0):
  print(s[0]-temp)
else:
  print(-1)

Submission status: Wrong Answer

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

temp = 0
for i in s:
  temp += i
  
if(s[0]-temp>=0):
  print(s[0]-temp)
else:
  print(-1)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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: Wrong Answer

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

Submission status: Wrong Answer

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

print(N-sum(A))

Submission status: Wrong Answer

Solution code:
N, M = input().split()
A = input().split()
B = 0
for a in A:
  B += int(a)
print(int(N)-B)

Submission status: Wrong Answer

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

days = 0
for a in A:
    days+=a

print(N-days)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

A_sum = sum(A)

print(N-A_sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, m= map(int,input().split())
lista=list(map(int, input().split()))
eq= 0
eq2= 0

for i in range(m):
	eq+= lista[i]

eq2= n-eq
if eq2==0:
	print("0")
elif eq<0:
	print("-1")
else:
	print(eq2)

Submission status: Wrong Answer

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


############ ---- Input Functions ---- ############
def in_int():
    return (int(input()))


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


def in_str():
    s = input()
    return (list(s[:len(s) - 1]))


def in_ints():
    return (map(int, input().split()))

mod = 7 + 10**9

n, m = in_ints()

a = in_list()

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

Submission status: Wrong Answer

Solution code:
n, m= map(int,input().split())
lista=list(map(int, input().split()))
eq2=0
eq=0
#lista= list(map(int,input().split()))

eq2= sum(lista)
eq= n-eq2
if eq<=n:
	print(eq)
else:
	print('-1')

Submission status: Wrong Answer

Solution code:
n, m= map(int,input().split())
lista=[]
eq2=0
eq=0
#lista= list(map(int,input().split()))

for x in input().split():
	x= int(x)
	lista.append(x)

eq2= sum(lista)
eq= n-eq2
if eq<=n:
	print(eq)
else:
	print('-1')