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

print(N-Hsum)

Submission status: Wrong Answer

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

total = N
for elm in elms:
   N -= elm

print(N)

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]
print(N if N>0 else -1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N, M = map(int, input().split())
As = list(map(int, input().split()))
print(N - sum(As))

Submission status: Wrong Answer

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

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    n, m = mi()
    a = lmi()
    s = sum(a)
    print(n-s)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def getIntList():
    return list(map(int, input().split()))

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

    num = 0
    for i in range(M):
        num += A[i]
    
    if num >= 0:
        print(N - num)
    else:
        print(-1)

    return

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

N, M = map(int, input().split())
ans = sum(map(int, input().split()))

if ans >= 0:
    print(N - ans)
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]

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

Submission status: Wrong Answer

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

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

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

sum_A = sum(A)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(n-sum(arr))

Submission status: Wrong Answer

Solution code:
d,h=map(int,input().split())
da=list(map(int,input().split()))
ans = d - sum(da)
if ans > 0:print(ans)
else:print(-1)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
days = list(input().split())
for i in range(len(days)):
    n -= int(days[i])
print(n)

Submission status: Wrong Answer

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

m,n=map(int,input().split())
A=list(map(int,input().split()))
print(m-sum(A))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# B - Homework
# 標準入力の取得
N,M = list(map(int, input().split()))
A = list(map(int, input().split()))

# 求解処理
print(N - sum(A))

Submission status: Wrong Answer

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


def solve(N: int, M: int, A: "List[int]"):
    print(N-sum(A))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(M)]  # type: "List[int]"
    solve(N, M, A)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
a = input()
b = input()

days,home = [int(i) for i in a.split(" ")]
cost = [int(n) for n in b.split(" ")]
print(days,home)
print(cost)

validdate = int(days) - sum(cost)
if validdate >= 0:
    print(validdate)
else:
    print(-1)

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
result = N - days
print(str(result))

Submission status: Wrong Answer

Solution code:
Summer_Vac,  HomeWork = map(int, input().split())
SyukuDai = input().rstrip().split(' ')
Ans = Summer_Vac

for i in range(HomeWork):
    Ans = Ans - int(SyukuDai[i])

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

Submission status: Wrong Answer

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

sum_home_day = sum(lists)

print(N - sum_home_day)

Submission status: Wrong Answer

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

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

sum = sum(a)

print(n - sum)

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:
a = input()
b = input()

days,home = [int(i) for i in a.split(" ")]
cost = [int(n) for n in b.split(" ")]
#print(days,home)
#print(cost)

validdate = int(days) - sum(cost)
if validdate >= 0:
    print(validdate)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
NM = input().split()
A = input().split()
N = int(NM[0])
M = int(NM[1])
a = 0
for i in range(M):
    a+=int(A[i])
print(N-a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

N,M = map(int, input().split())

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

if len(A)>N:
    print("-1")
    sys.exit()

print(N-sum(A))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

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

a = sum(int(i) for i in a)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

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

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

Submission status: Wrong Answer

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

print(N-sum(list))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
lists = list(map(int, input().split())) #１行の入力をi[0],i[1]というように空白で分けてを取得し、iに値を入れる
a = list(map(int, input().split())) #１行の入力をi[0],i[1]というように空白で分けてを取得し、iに値を入れる

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

Submission status: Wrong Answer

Solution code:
d,h=map(int,input().split())
da=list(map(int,input().split()))
print(d - sum(da))

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:
from math import gcd
from functools import reduce
from itertools import product

def resolve():
  K, M = map(int, input().split(" "))
  A = [int(x) for x in input().split(" ")]
  print(K-sum(A) if K-sum(A) > 0 else -1)

if __name__ == "__main__":
  resolve()

Submission status: Wrong Answer

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

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

sum_A = sum(A)

if sum_A > -1:
    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()))

x = n - sum(a)

print(x if x > 0 else -1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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:
# -*- coding: utf-8 -*-
import math
# 整数の入力
n, m = map(int, input().split())
li = list(map(int, input().split()))
# 計算
a = n-sum(li)
if 0 <= n:
    print(a)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
# abc136

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

ans = n - sum(days)
if ans < 0:
    ans = 0
print(ans)

Submission status: Wrong Answer

Solution code:
# 夏休みN日
# 宿題M
# i番目の宿題をやるにはAi日間かかります。

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Solution code:
a=input().split()
f=input().split()
s=0
fl=0
for i in range(0,int(a[1])):
    s+=int(f[i])
    if(s>int(a[0])):
        print("-1")
        break
        fl+=1
if(fl!=1):
    print(int(a[0])-s)

Submission status: Wrong Answer

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

list_b = [int(i) for i in list_a]

sum_a = sum(list_b)

print(N - sum_a)

Submission status: Wrong Answer

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

a = [ int(x) for x in input().split()]
print(n-sum(a))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

souwa = sum(A)*m

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

Submission status: Wrong Answer

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

print (n-sum(l))

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
for i in A:
  if ans<0:
    print("-1")
    exit()
  else:
    ans-=i
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
#スペース区切りの整数の入力
N,M = map(int, input().split())
#スペース区切りの整数の入力リスト
A_list = list(map(int, input().split()))

sum_ = 0
for i in range(len(A_list)):
  sum_ = sum_ + A_list[i]
  
ans = N - sum_

print(ans)

Submission status: Wrong Answer

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

total = sum(a)

if (n - total) > 0:
    print(n - total)
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:
import math
a = input().split()
b = map(int,input().split())
if (sum(b) > int(a[0])):
    print("-1")
else:
    print(int(a[0]) - sum(b))

Submission status: Wrong Answer

Solution code:
# abc136

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

ans = n - sum(days)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
A = input()
B = []
atemp = A.split()
c = 0
for i, num in enumerate(atemp):
    B.append(atemp[i])
    c += int(num)
print(N-c)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

S=0
for x in range(0,M):
	S=S+X[x]

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

day = list(map(int,input().split()))
days = 0
for i in range(m):
  days += day[i]
  
print(n -days)

Submission status: Wrong Answer

Solution code:
n=int(input().split()[1])
f=n-sum(map(int,input().split()))
print(-1 if f<0 else f)

Submission status: Wrong Answer

Solution code:

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

day = sum(A)
play = N-day
print(play)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
ip1 = input()
ip1list = ip1.split(" ")
N = int(ip1list[0])
M = int(ip1list[1])
ip2 = input()
A_sub = ip2.split(" ")
A = []
for a in A_sub:A.append(int(a))

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

Submission status: Wrong Answer

Solution code:
from math import gcd
from functools import reduce
from itertools import product

def resolve():
  K, M = map(int, input().split(" "))
  A = [int(x) for x in input().split(" ")]
  print(K-sum(A))

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
s = input().split()
n=int(s[0])
m = int(s[1])
s = input().split()
for i in s:
    n-=int(i)
print(n)

Submission status: Wrong Answer

Solution code:
data = input().split()

n = int(data[0])
m = int(data[1])

data = input().split()

homework = [int(s) for s in data]
day = 0

for i in homework:
  day += i

ans = n - day
print(ans)

Submission status: Wrong Answer

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

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:
k,p = map(int,input().split())
H = list(map(int,input().split()))
kk=sum(H)
if k-kk > 0:
    print(k-kk)
else:
    print(-1)

Submission status: Wrong Answer

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

def main():
    N, M, *A = map(int, read().split())
    ans = sum(A)
    if ans > N:
        ans == -1
    else:
        ans = N - ans
    print(ans)
    return

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))


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



if __name__ == "__main__":
	main()

Submission status: Wrong Answer

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

print(lis)
ans = n
for i in range(m):
    ans -= lis[i]
if ans >= 0:
    print(ans)
else:
    print("-1")

Submission status: Wrong Answer

Solution code:
n,m = input().split()
ai = input().split()
a = 0
for i in ai:
    a=a+int(i)
print(int(n)-a)

Submission status: Wrong Answer

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


if __name__ == "__main__":
    main()

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    count = 0
    for i in a:
        count += i
    print(n - count)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    i = input().split()[0]
    i = int(i)
    ii = input().split()
    ii = [int(x) for x in ii]
    ii = sum(ii)
    if ii > i:
        print(-1)
    else:
        print(ii - i)


main()

Submission status: Wrong Answer

Solution code:

def main():
    nm = list(map(int, input().split()))
    a = list(map(int, input().split()))
    aa = nm[0] - sum(a)
    aa = aa if aa > 0 else -1
    print(aa)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


sumA = sum(A)
bj = -1

if sumA >= 0:
    print(NM[0]-sumA)

else:
    print(bj)

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
ip1 = input()
ip1list = ip1.split(" ")
N = int(ip1list[0])
M = int(ip1list[1])
ip2 = input()
A_sub = ip2.split(" ")
A = []
for a in A_sub:A.append(int(a))

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

Submission status: Wrong Answer

Solution code:
def main(N, M, A):
    memo = N - sum(A)
    if memo >= 0:
        return memo
    else:
        return memo

if __name__ == '__main__':
    N, M = list(map(int, input().split()))
    A = list(map(int, input().split()))
    # N = 314
    # M = 15
    # A = list(map(int, "9 26 5 35 8 9 79 3 23 8 46 2 6 43 3".split()))
    # print(N, M, A)
    print(main(N, M, A))

Submission status: Wrong Answer

Solution code:
days,num = map(int,input().split())
homeworks = list(map(int,input().split()))

temp = sum(homeworks)

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

Submission status: Wrong Answer

Solution code:

from sys import stdin
import sys
# sys.setrecursionlimit(10**8)

def nextLine(): return next(stdin)
def nextStrList(): return nextLine().split()
def nextIntList(): return [int(_) for _ in nextStrList()]

import numpy as np

def main():
	n,m=nextIntList()
	al=nextIntList()
	
	s=n-sum(al)
	print(s)
	
if __name__=="__main__":
	main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(N - A) if N - A >= 0 else print(0)

Submission status: Wrong Answer

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

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

s=sum(a)

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Solution code:
x = input().split()
c  =int(x[0])
v = input().split()
f = 0
for i in v:
  f += int(i)
m = c - f
print(m)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
a = map(int, input().split())
c = 0
for b in a:
    c += b
print(n-c)

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:

def main():
    nm = list(map(int, input().split()))
    a = list(map(int, input().split()))
    aa = nm[0] - sum(a)
    print(aa) if aa < 0 else print(-1)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

N = int(N)
M = int(M)
#print(N,M,A)

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

#print(sum)

ans = N - sum
print(ans)

Submission status: Wrong Answer

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

t=0
for i in li:
    t+=int(i)
print(n-t)

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:
line1 = input().split()
n = int(line1[0])
m = int(line1[1])

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

print(n - sum)

Submission status: Wrong Answer

Solution code:
def solution():
    return 1

def main():
    N , M = list(map(int , input().split()))
    assignments = list(map(int , input().split()))
    for a in assignments:
        N -= a 
    print(N)       
   
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def solve():
  n, m = map(int, input().split())
  a = list(map(int, input().split()))
  hoge = max(0, n-sum(a))
  if hoge == 0:
    print(-1)
  else:
    print(hoge)
  return 0
 
if __name__ == "__main__":
  solve()

Submission status: Wrong Answer

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

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

for i in range(len(s)):
  a=a-s[i]
  
print(a)

Submission status: Wrong Answer

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