Problem:


Score : 200 points

Problem Statement

Takahashi has N days of summer vacation.

His teacher gave him M summer assignments. It will take A_i days for him to do the i-th assignment.

He cannot do multiple assignments on the same day, or hang out on a day he does an assignment.

What is the maximum number of days Takahashi can hang out during the vacation if he finishes all the assignments during this vacation?

If Takahashi cannot finish all the assignments during the vacation, print -1 instead.

Constraints

1 \leq N \leq 10^6

1 \leq M \leq 10^4

1 \leq A_i \leq 10^4

Input

Input is given from Standard Input in the following format:

N M
A_1 ... A_M

Output

Print the maximum number of days Takahashi can hang out during the vacation, or -1.

Sample Input 1

41 2
5 6

Sample Output 1

30

For example, he can do the first assignment on the first 5 days, hang out on the next 30 days, and do the second assignment on the last 6 days of the vacation. In this way, he can safely spend 30 days hanging out.

Sample Input 2

10 2
5 6

Sample Output 2

-1

He cannot finish his assignments.

Sample Input 3

11 2
5 6

Sample Output 3

0

He can finish his assignments, but he will have no time to hang out.

Sample Input 4

314 15
9 26 5 35 8 9 79 3 23 8 46 2 6 43 3

Sample Output 4

9



Sample input:
41 2
5 6


Sample output:
30

Submission status: Accepted

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

Submission status: Accepted

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

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

ans=max(-1,N)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

def one_int():
    return int(input())

def one_str():
    return input()

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

N,M = input_int()
A = many_int()

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n, m = input().split()
As = input().split()
suma = 0
for a in As:
    suma += int(a)
res = int(n) - suma
if res < 0:
    print(-1)
else:
    print(res)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

costs = list(map(int, input().split()))
totalCosts = sum(costs)
free = N - totalCosts
print(max(free, -1))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import bisect,collections,copy,heapq,itertools,math,operator,string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
def LS(): return list(input().split())
##################################################
N,M = LI()
A = LI()
for x in A:
    N -= x
print(N if N>=0 else -1)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
import math
import itertools

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

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

Submission status: Accepted

Solution code:
def resolve():
    '''
    code here
    '''
    N, M = [int(item) for item in input().split()]
    A_list = [int(item) for item in input().split()]

    all_sum = sum(A_list)

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

if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

    ans = n

    for aa in a:
        ans -= aa
        if ans < 0:
            print(-1)
            exit()

    print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

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

def print_l(l):
    print(' '.join(map(str, l)))

class Interval():
    def __init__(self, li):
        self.li = li
        self.n = len(li)
        self.sum_li = [li[0]]
        for i in range(1, self.n):
            self.sum_li.append(self.sum_li[i-1] + li[i])

    def sum(self, a, b=None):
        if b is None:
            return self.sum(0, a)

        res = self.sum_li[min(self.n-1, b-1)]
        if a > 0:
            res -= self.sum_li[a-1]
        return res


n,m = l_in()
A = l_in()

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

Submission status: Accepted

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

Submission status: Accepted

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

C=0
for i in A:
    C+=i
if N-C>=0:
    print(N-C)
else:
    print(-1)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n,m=n1()
a=n1()

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

Submission status: Accepted

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

MOD = 10**9
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

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

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

Submission status: Accepted

Solution code:


def solve():
    N, M = map(int, input().split())
    Alist = list(map(int, input().split()))

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


if __name__ == "__main__":
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 19 20:57:48 2020

@author: black
"""


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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(max(-1,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
# from fractions import 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 functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

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


def main():
    N, M = MAP()
    A = LIST()

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

# process
ans = N - sum(A)

# output
print(-1 if ans < 0 else ans)

Submission status: Accepted

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

sa = sum(a)
diff = n - sa

print(max(diff, -1))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = N - sum(A)

if ans < 0:
    ans = -1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,M=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()))
y = n-sum(a)
if y < 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()))

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

Submission status: Accepted

Solution code:
num_holiday, num_homework = map(int, input().split())
days_required = sum(map(int, input().split()))

print(max(-1, num_holiday - days_required))

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

N, M  = i_l()
A = i_l()


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

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

Submission status: Accepted

Solution code:
#B

#デバッグ
debug=1
def pront(*n):
    if debug==1:
        print(n)
        
#10**9+7を底とした処理

base=10**9+7

def add(a,b):#a+b
    return (a+b)%base

def sub(a,b):#a-b
    return (a-b)%base

def multi(a,b):#a*b
    return (a*b)%base

def exp(a,b):#a**b
    x=1
    c=a
    d=b
    while d!=0:
        if d%2==1:
            x=multi(x,c)
        c=(c**2)%base
        d=d//2
    return x

def div(a,b):#a/b
    return(multi(a,exp(b,base-2)))

#入力
N,M=map(int,input().split())

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

#処理

x=N-sum(A)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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


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

    r = n - sum(a_list)
    print(r if r >= 0 else -1)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

for i in range(M):
    N -= AList[i]
if N >= 0:
    print(N)
else:
    print('-1')

Submission status: Accepted

Solution code:
# /usr/bin/python3
# -*- coding: utf-8 -*-
from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt, floor, ceil, log2
from fractions import gcd
from itertools import permutations, combinations
from operator import itemgetter
from functools import cmp_to_key


INF=1001001001
__MOD__=(10**9)+7
yn = 'YNeos'
judge = False
cnt = 0
ans = None


def lcm(a, b):
    return (a*b) // gcd(a,b)

def intinput():
    return int(input())

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

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas

class ModInt():
    def __init__(self, x):
        self.__x = (x % __MOD__)
    def __add__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x + other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x + other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __sub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x - other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x - other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __mul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __truediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __pow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(self.__x, other.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(self.__x, other.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")
    def __modinv(self, m=__MOD__):
        a = self.__x
        if a == 0:
            raise ZeroDivisionError()
        if gcd(a, m) != 1:
            raise Exception("%sの逆数は求まりません。" % a)
        b, u, v = m, 1, 0
        while b != 0:
            t = a//b;
            a -= t*b
            a, b = b, a
            u -= t * v
            u, v = v, u
        u %= m
        if u < 0:
            u += m
        return u
    def __int__(self):
        return self.__x



if __name__ == '__main__':
    N, M = mulinputs()
    total = sum(list(mulinputs()))

    # 出力
    if total <= N:
        print(N-total)
    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:
import collections
import math
import operator as op
from functools import reduce
from collections import Counter
import numpy as np
import math
import bisect
import heapq


def get_inputs(cast_func=None):
    if cast_func is None:
        return input().split()
    else:
        return list(map(cast_func, input().split()))


def get_input(cast_func=None):
    if cast_func is None:
        return input()
    else:
        return cast_func(input())


def main():
   N, M = get_inputs(int)
   A = get_inputs(int)
   print(max(-1, N - sum(A)))





if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
k = list(map(int, input().split()))
l = list(map(int, input().split()))
g = sum(l)

if k[0] >= g:
  print(k[0] - g)
else:
  print(-1)

Submission status: Accepted

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

asum=sum(alist)
print(max(-1,N-asum))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

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

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

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

Submission status: Accepted

Solution code:
import math
#def main(S, b):
if __name__ == '__main__':
    n, m = map(int, input().split())

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

    s = sum(a)

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

    #print(n * 2 * pi)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n,m=INTM()
    a=LIST()
    print(max(n-sum(a),-1))
if __name__ == '__main__':
    do()

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())
arr = [int(x) for x in input().split()]
s = sum(arr)
print(max(-1,n-s))

Submission status: Accepted

Solution code:
import math

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from math import gcd

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

yes = "Yes"
no = "No"

def main():
    n,m = mi()
    a = li()
    s = sum(a)
    print(max(n-s,-1))

main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if res < 0:
    res = -1

print(res)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
from collections import deque
import math
import pprint
from functools import reduce
# stdin = open("sample.txt")

def keta(kazu):
    kazu_str = str(kazu)
    kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]
    return kazu_list

def gcd(*numbers):
    return reduce(math.gcd, numbers)

N, M = [int(x) for x in stdin.readline().rstrip().split()]
A = list(map(int,[int(x) for x in stdin.readline().rstrip().split()]))
sum_A = sum(A)

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

Submission status: Accepted

Solution code:
hoge = input().split()
N = int(hoge[0])
M = int(hoge[1])

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

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(a[1]):
  a[0] = a[0] - b[i]
if(a[0] < 0):a[0]=-1
print(a[0])

Submission status: Accepted

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

if n>=sa:
    print(n-sa)
else:
    print("-1")

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import sys,math,copy,queue,itertools,bisect
sys.setrecursionlimit(10**7)
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
INF = 10**18
MOD = 10**9 + 7
DD = ((1,0),(0,1),(-1,0),(0,-1))

N,M = LI()
A = LI()
ans = N - sum(A)
if ans < 0:
    ans = -1
print (ans)

Submission status: Accepted

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

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

s = sum(res)

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