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:
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


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

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


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
A = input().split()
for i in range(M):
    N -= int(A[i])
if N >= 0:
    print(N)
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:
import numpy as np

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

As = np.asarray(input().split(), dtype=np.int32)

ans = n - np.sum(As)

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print("-1" if N < 0 else 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:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# B - Homework

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

sum_a = sum(a)

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

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
#from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = True

n, m = MAP()
a = LIST()
s = sum(a)
if n < s:
    print(-1)
else:
    print(n - s)

Submission status: Accepted

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

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

Submission status: Accepted

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

syukudai = sum(Ai)
nokori = N - syukudai
if nokori >= 0:
    print(nokori)
else:
    print(-1)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

msum = sum(A)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

w=sum(a)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

print(max(-1,n))

Submission status: Accepted

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


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

Submission status: Accepted

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

Submission status: Accepted

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

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)
        return
    print(n-sum(a))
if __name__=='__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

alist = input('').split(' ')

d=0
for a in alist:
    d+=int(a)

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

Submission status: Accepted

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

Submission status: Accepted

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

mylist = list(map(int,input().split()))
mysum = sum(mylist)

if mysum > M:
    print(-1)
else:
    print(M-mysum)

Submission status: Accepted

Solution code:
i = list(map(int,input().split()))
work = list(map(int,input().split()))
day = i[0]
sumwork = sum(work)
play = day-sumwork
if play < 0:
	print(-1)
else:
	print(play)

Submission status: Accepted

Solution code:
def slove(n, a):
    tmp = sum(a)
    if n < tmp:
        return -1
    else:
        return n - tmp
    return ans

if __name__ == "__main__":
    n, m = [int(i) for i in input().split()]
    a_list = [int(i) for i in input().split()]
    print(slove(n, a_list))

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)
    exit()
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N, M = getlist()
	A = getlist()
	s = sum(A)
	if N >= s:
		print(N - s)
	else:
		print(-1)
	


if __name__ == '__main__':
	main()

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces

def main():
    n,m = na()
    a = na()
    ans = n - sum(a)
    if ans < 0:
        print(-1)
        return
    print(ans)
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1

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

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

Submission status: Accepted

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

s = sum(A)
ans = N-s
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()))
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()))

sum_A = sum(A)

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

else:
    play = N - sum_A
    print(play)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

amount = sum(arr)
ret = n-amount
if ret < 0:
    print(-1)
else:
    print(ret)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
A = [int(x) for x in 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 = list(map(int,input().split()))
H = sum(A)
if H <= N:
    print(N-H)
else:
    print(-1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

else:
    print(n - wa)

Submission status: Accepted

Solution code:
n, m = (int(x) for x in input().split())
seq = sorted([int(x) for x in input().split()])
print(max(-1, n-sum(seq)))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#import re
import sys
input = sys.stdin.readline
#import heapq
#import bisect
#from collections import deque
#import math

def main():
    n, m = map(int, input().split())
    A = list(map(int, input().split()))
    a = 0
    for i in range(m): 
        a += A[i]
    ans = n - a
    if ans >= 0:
        print(ans)
    else:
        print(-1)
    
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

    for b in a:
        n -= b

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main(n,m,a):
    d = sum(a)
    res = n-d
    return res if res >= 0 else -1

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

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

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**9)

INF = 110110110
_INFL = -INF * INF

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

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

Submission status: Accepted

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

n, m = map(int, input().split())
A = [int(a) for a in input().split()]
A_sum = sum(A)

amari = n - A_sum
if amari < 0:
    print("-1")
else:
    print(amari)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8

N, M = list(map(int,input().split()))
a = [int(_) for _ in input().split()]
sum = sum(a)

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

Submission status: Accepted

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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: 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()))
s=sum(a)
print(max(n-s,-1))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

if ans < 0:
    ans = -1
    
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = n - sum(ai)

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

Submission status: Accepted

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

a = sum(A)

res = 0

if a > N:
    res = -1
else:
    res = N - a

print(res)

Submission status: Accepted

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

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

Submission status: Accepted

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

total = N - sum(map(int, input().strip().split()))
if total >= 0:
	print(total)
else:
	print(-1)

Submission status: Accepted

Solution code:
#!/bin/bash
''':'
docker run --rm -it -v $(cd $(dirname $0) && pwd):/vo:ro pypy:3-2.4.0 \
   /bin/bash -c "pypy3 /vo/$(basename $0) < /vo/input.txt"
exit $?
'''
import sys


def _ia(): return map(int, sys.stdin.readline().strip().split())


def main():
    n, _ = _ia()
    tot = sum(_ia())
    return max([n-tot, -1])


if __name__ == "__main__":
    print(main())

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

if __name__ == "__main__":
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    sum_ = sum(a)

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

Submission status: Accepted

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

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

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

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

s=sum(a)

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N,M = map(int, input().split())
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())
li = [int(x) for x in input().split()]
if n - sum(li)>=0:
  print(n - sum(li))
else:
  print(-1)

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

N, M = map(int, readline().split())
A = map(int, readline().split())

sum_ = sum(A)

if sum_ > N:
    print(-1)
else:
    answer = N - sum_
    print(answer)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

sumA = sum(A)

if sumA <= n:
    print(n - sumA)
else:
    print(-1)

Submission status: Accepted

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


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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

hw = sum(A)

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

Submission status: Accepted

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

b = sum(a)

c = max(n - b, -1)

print(c)

Submission status: Accepted

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

homework_date = sum(aa)
play_date = n - homework_date

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

Submission status: Accepted

Solution code:
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


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


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


def ZIP(n): return zip(*(MAP() for _ in range(n)))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    n, m = MAP()
    a = LIST()
    print(max(n - sum(a), -1))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# coding: utf-8
import numpy as np
n, m = map(int, input().split())
li = list(map(int, input().split()))
ans=n-sum(li)
if ans>=0:
    print(ans)
else:
    print('-1')

Submission status: Accepted

Solution code:
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

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

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

Submission status: Accepted

Solution code:
# int(input()) # 入力が1つ
n, m = map(int, input().split()) # 入力が複数
nums = [int(i) for i in input().split()] # 配列で数字
ans = n - sum(nums)
if ans < 0:
    print(-1)
else:
    print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

import numpy as np
a = np.array(a)
s = a.sum()
if s > n:
  print('-1')
else:
  print(n-s)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

# 入力を整数に変換して受け取る
def input_int(): return int(input())

def map_int_input(): return map(int, input())

MII = map_int_input

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

def MII_to_index(): return map(to_index, input())

def MII_split_to_index(): return map(to_index, input().split())

# 入力全てを整数に変換したものの配列を受け取る
def list_int_inputs(): return list(map(int, input()))

LII = list_int_inputs

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

# 2次元リスト化
def LII_2D(rows_number): return [LII() for _ in range(rows_number)]

def LII_split_2D(rows_number): return [LII_split() for _ in range(rows_number)]

N, M = MII_split()
As = LII_split()

ans = N-sum(As)
print(ans if ans >= 0 else -1)