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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

sums = sum(lista)

ans = N - sums

if ans < 0:
    ans = -1

print(ans)

Submission status: Accepted

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

suma = sum(a)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin

[N, M] = [int(x) for x in stdin.readline().rstrip().split()]

As = [int(x) for x in stdin.readline().rstrip().split()]


shukudai_sum = sum(As)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

s=0

for a in a_list:
    s+=a


if N-s <0:
    ans=-1
else:
    ans=N-s

print(ans)

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

asobi = n - a_sum

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
line = [int(x) for x in input().split()]

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

t = sum(vals)

if t > line[0]:
  print(-1)
else:
  print(line[0] - t)

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(max(-1, N))

Submission status: Accepted

Solution code:
# coding: utf-8


def solve(*args: str) -> str:
    n, m = map(int, args[0].split())
    A = list(map(int, args[1].split()))
    ret = max(-1, n-sum(A))

    return str(ret)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

sample = list(map(int, input().split(" ")))
if sum(sample) > n:
  print(-1)
else:
  print(n - sum(sample))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

for i in range(len(a)):
    n -= a[i]
    if n < 0:
        break
print(max(n, -1))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from math import *
test = 1
#test = int(input())
for __ in range(test):
	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()))
sum = 0
for i in range(M):
    sum += A[i]

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(res)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

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

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

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

Submission status: Accepted

Solution code:
nm = list(map(int,input().split()))
n,m = nm[0],nm[1]
a = list(map(int,input().split()))
sam = sum(a)
ans = n - sam
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()))

print(max(-1, n - sum(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:
"""
Author    : co_devil Chirag Garg
Institute : JIIT
"""
from math import pi
from collections import deque
from math import factorial
from math import log, ceil
from collections import defaultdict
from math import *
from sys import stdin, stdout
import itertools
import os
import sys
import threading
from collections import deque, Counter, OrderedDict, defaultdict
from heapq import *
# from math import ceil, floor, log, sqrt, factorial, pow, pi, gcd
# from bisect import bisect_left,bisect_right
# from decimal import *,threading
from fractions import Fraction
# mod = int(pow(10, 9)+7)
mod = 998244353


def ii(): return int(input())


def si(): return str(input())


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


def li(): return list(mi())


def fii(): return int(stdin.readline())


def fsi(): return str(stdin.readline())


def fmi(): return map(int, stdin.readline().split())


def fli(): return list(fmi())


abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12,
       'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24,
       'z': 25}


def getKey(item): return item[0]


def sort2(l): return sorted(l, key=getKey)


def d2(n, m, num): return [[num for x in range(m)] for y in range(n)]


def isPowerOfTwo(x): return (x and (not (x & (x - 1))))


def decimalToBinary(n): return bin(n).replace("0b", "")


def ntl(n): return [int(i) for i in str(n)]


def powerMod(x, y, p):
    res = 1
    x %= p
    while y > 0:
        if y & 1:
            res = (res * x) % p
        y = y >> 1
        x = (x * x) % p
    return res


graph = defaultdict(list)
visited = [0] * 1000000
col = [-1] * 1000000


def bfs(d, v):
    q = []
    q.append(v)
    visited[v] = 1
    while len(q) != 0:
        x = q[0]
        q.pop(0)
        for i in d[x]:
            if visited[i] != 1:
                visited[i] = 1
                q.append(i)
        print(x)


def make_graph(e):
    d = {}
    for i in range(e):
        x, y = mi()
        if x not in d:
            d[x] = [y]
        else:
            d[x].append(y)
        if y not in d:
            d[y] = [x]
        else:
            d[y].append(x)
    return d


def gr2(n):
    d = defaultdict(list)
    for i in range(n):
        x, y = mi()
        d[x].append(y)
    return d


def connected_components(graph):
    seen = set()

    def dfs(v):
        vs = set([v])
        component = []
        while vs:
            v = vs.pop()
            seen.add(v)
            vs |= set(graph[v]) - seen
            component.append(v)
        return component

    ans = []
    for v in graph:
        if v not in seen:
            d = dfs(v)
            ans.append(d)
    return ans


def primeFactors(n):
    s = set()
    while n % 2 == 0:
        s.add(2)
        n = n // 2
    for i in range(3, int(sqrt(n)) + 1, 2):
        while n % i == 0:
            s.add(i)
            n = n // i
    if n > 2:
        s.add(n)
    return s


def find_all(a_str, sub):
    start = 0
    while True:
        start = a_str.find(sub, start)
        if start == -1:
            return
        yield start
        start += len(sub)


def SieveOfEratosthenes(n, isPrime):
    isPrime[0] = isPrime[1] = False
    for i in range(2, n):
        isPrime[i] = True
    p = 2
    while (p * p <= n):
        if (isPrime[p] == True):
            i = p * p
            while (i <= n):
                isPrime[i] = False
                i += p
        p += 1
    return isPrime


def dijkstra(edges, f, t):
    g = defaultdict(list)
    for l, r, c in edges:
        g[l].append((c, r))

    q, seen, mins = [(0, f, ())], set(), {f: 0}
    while q:
        (cost, v1, path) = heappop(q)
        if v1 not in seen:
            seen.add(v1)
            path = (v1, path)
            if v1 == t:
                return (cost, path)

            for c, v2 in g.get(v1, ()):
                if v2 in seen:
                    continue
                prev = mins.get(v2, None)
                next = cost + c
                if prev is None or next < prev:
                    mins[v2] = next
                    heappush(q, (next, v2, path))
    return float("inf")


def binsearch(a, l, r, x):
    while l <= r:
        mid = l + (r-1)//2
        if a[mid]:
            return mid
        elif a[mid] > x:
            l = mid-1
        else:
            r = mid+1
    return -1


# def input():
#    return stdin.buffer.readline()


def readTree(n):
    adj = [set() for _ in range(n)]
    for _ in range(n-1):
        u, v = map(int, input().split())
        adj[u-1].add(v-1)
        adj[v-1].add(u-1)
    return adj


def treeOrderByDepth(n, adj, root=0):
    parent = [-2] + [-1]*(n-1)
    ordered = []
    q = deque()
    q.append(root)
    depth = [0] * n
    while q:
        c = q.popleft()
        ordered.append(c)
        for a in adj[c]:
            if parent[a] == -1:
                parent[a] = c
                depth[a] = depth[c] + 1
                q.append(a)
    return (ordered, parent, depth)


# n, k = map(int, input().split())
# adj = readTree(n)
# ordered, parent, depth = treeOrderByDepth(n, adj)
# # children = [0]*n
# # for nd in ordered[::-1]:
# #     if parent[nd] != -2:
# #         children[parent[nd]] += children[nd] + 1
# # value = list(map(lambda a, b: a - b, depth, children ))
# # value.sort(reverse=True)
# # print(sum(value[:k]))
# print(ordered, parent, depth)

n, m = mi()
l = sorted(li())
if sum(l) <= n:
    print(n-sum(l))
else:
    print(-1)

Submission status: Accepted

Solution code:
import math
N, M = map(int,input().split())
lis = list(map(int,input().split()))
s = 0
for homework in lis:
  s += homework
  
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()))
num = 0
for i in range(m):
    num += a[i] 
if num > n:
    print("-1")
else:
    print(n - num)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(100000)

def ins(): return input().split()
def ii(): return int(input())
def iil(): return list(map(int, ins()))
def lin(): return list(input())
def iin(): return map(int, ins())

n, m = iin()
a = sum(iin())
print(-1 if n-a<0 else n-a)

Submission status: Accepted

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

# B - Homework
N, M = map(int, input().split())
A = list(map(int, input().split()))

remainder = N - sum(A)

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

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 sum_a <= n else -1)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix

# slist = "abcdefghijklmnopqrstuvwxyz"
N,M = map(int,input().split())
arrA = list(map(int,input().split()))
# arrA = np.array(input().split(),dtype=np.int64)

ans = max(N - sum(arrA),-1)

print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))

Submission status: Accepted

Solution code:
[N,M] = [int(s) for s in input().rstrip().split(' ')]
L = [int(s) for s in input().rstrip().split(' ')]
S = sum(L)
if N >= S:
    print(N-S)
else:
    print("-1")

Submission status: Accepted

Solution code:
import math
N,M=map(int, input().split())
A_list = list(map(int, input().split()))
sumA=sum(A_list)
ans=N-sumA
if(ans<=-1):
  print(-1)
else:
  print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
c=input().split()
l=[]
for i in c:
  l.append(int(i))
if sum(l)>a:
  print(-1,end="")
else:
  print(a-sum(l),end="")

Submission status: Accepted

Solution code:
import math

n, m = map(int, input().split())
arr = list(map(int, input().split()))
s = sum(arr)
print(n - s if s <= n else -1)

Submission status: Accepted

Solution code:
from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations
import math
import bisect
import numpy as np
from collections import defaultdict, deque
from operator import itemgetter
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
# MOD = 10 ** 9 + 7
# INF = float("inf")


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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import numpy as np

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

    for w in works:
        n -= w
    print(-1) if n < 0 else print(n)



if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N,M = list(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:
import numpy as np


def solve():
    return max(n - np.sum(a), -1)



n, m = [int(i) for i in input().split(" ")]
a = [int(i) for i in input().split(" ")]
print(solve())

Submission status: Accepted

Solution code:

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

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

for i in items:
    n-=i
if n<=-1:
    print(-1)
    exit()
print(n)

Submission status: Accepted

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

total = sum(A_list)
re = N - total
if re >= 0:
    print(re)
else:
    print(-1)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
amount = 0
li = list(map(int,input().split()))
for l in li:
  amount += l
if amount <= N:
  print(N-amount)
else:
  print(-1)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

def solve():
    N,M = map(int, input().split())
    D = N - sum(map(int, input().split()))
    if D >= 0:
        return str(D)
    else:
        return '-1'

if __name__ == '__main__':
    print(solve())

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

Submission status: Accepted

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

benkyou = sum(A)

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans=N-sum(A)

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

Submission status: Accepted

Solution code:
inp1=list(map(int,input().strip().split()))[:2]
n,m=inp1[0],inp1[1]
arr=list(map(int,input().strip().split()))[:m]
sum1=sum(arr)
if(sum1 > n):
	print(-1)
else:
	print(n-sum1)

Submission status: Accepted

Solution code:
# coding: utf-8

# 標準入力 <int><int>
N, M = map(int, input().split())

# 標準入力 <int> list[]
A = list(map(int, input().split()))

a = sum(A)

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

import math

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

sum = 0
for a in As:
    sum += a

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

total = sum(a)

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

Submission status: Accepted

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

cnt = 0

for i in a:
    cnt += i

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

Submission status: Accepted

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

Submission status: Accepted

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

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

I = input().split()
Ai = [0] * M

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

ans = N - sum

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