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

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

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


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

Solution (Python):
days, dummy= map(int, input().split())
list_hours = input().split()

i=0
for el in list_hours:
    list_hours[i]=int(el)
    i+=1

if(days-sum(list_hours)<0):
    print(-1)
else:
    print(days-sum(list_hours))

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

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

Solution (Python):
n,m = map(int,input().split())
lst = list(map(int,input().split()))
syukudai = 0
while lst:
    syukudai += lst.pop()

nokori = n - syukudai
if nokori < 0:
    print("-1")
else:
    print(nokori)

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

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

Solution (Python):
N, _ = input().split(" ")
N = int(N)

homeworks= input().split(" ")
homeworks = [int(homework) for homework in homeworks]
sum_homework = sum(homeworks)

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

Solution (Python):


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

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

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

    return

if __name__ == "__main__":
    main()

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

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

Solution (Python):
n,m=map(int,input().split())
a=tuple(map(int,input().split()))
for d in a:
    n -= d
    if n < 0:
        print(-1)
        exit()
print(n)

Solution (Python):
N,M= map(int,input().split())
homeworks = list(map(int, input().split()))
for homework in homeworks:
  N-=homework
if N>=0:
  print(N)
else:
  print(-1)

Solution (Python):
input1 = input().split(" ")
n = int(input1[0])
m = int(input1[1])
assignlist = input().split(" ")
con1 = n>=1 and n<=1000000
con2 = m>=1 and m<=1000000
numassign = 0
holiday = 0
if con1 == True and con2 == True:
    for i in assignlist:
        i = int(i)
        if i >= 1 and i <= 10000:
            numassign = numassign + i
        else:
            numassign = numassign
    holiday = n - numassign
    if holiday >= 0:
        print(holiday)
    else:
        print(-1)
else:
    print()

Solution (Python):
nm = list(map(int, input().split()))
am = list(map(int, input().split()))
x = 0
for i in range(len(am)):
    x += am[i]
if x > nm[0]:
    print('-1')
else:
    ans = nm[0] - x
    print(ans)

Solution (Python):










def main():
    N, M, *A = map(int, open(0).read().split())

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


if __name__ == "__main__":
    main()

Solution (Python):
a,b = map(int,input().split())
lis = list(map(int,input().split()))
ans = a - sum(lis)
if(ans>=0):
    print(ans)
else:
    print(-1)

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

Solution (Python):
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

n,m = MI()

A = LI()

sum = np.sum(A)

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

Solution (Python):
n,m=map(int,input().split())
alist = list(map(int,input().split()))

nsum=sum(alist)
if n >= nsum:
    print(n-nsum)
else:
    print("-1")

Solution (Python):
from math import gcd
from functools import reduce
from itertools import product

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

if __name__ == "__main__":
    resolve()

Solution (Python):
n,m = map(int,input().split())
try:
  a = list(map(int,input().split()))
  b = int(sum(a))
except EOFError:
  pass
if int(n-b)<0:
  print('-1')
else:
  print(int(n-b))

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

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

for i in range(len(li)):
  a -= int(li[i])
if a > -1:
  print(a)
else:
  print(-1)

Solution (Python):
str = input().split()
line = input().split()

num = 0
for i in range(int(str[1])):
    num = num + int(line[i])

if (int(str[0]) - num)  >= 0:
    print(int(str[0]) - num)
else:
    print(-1)

Solution (Python):
N,M = map(int,input().split())
HW = list(map(int,input().split()))
Hsum = sum(HW)

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

Solution (Python):
day, task = map(int, input().split())
task_list = list(map(int, input().split()))
days = day - sum(task_list)
if days >= 0:
  print(days)
else:
  print('-1')

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

Solution (Python):

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

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

sum_ = 0
for i in range(len(A_list)):
  sum_ = sum_ + A_list[i]
  
  
ans = N - sum_
if(ans>=0):
  print(ans)
else:
  print("-1")

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

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

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

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

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

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

Solution (Python):

N, M = map(int, input().split())
As = list(map(int, input().split()))
k = N - sum(As)
if k < 0:
    k = -1
print(k)

Solution (Python):
N,M=map(int,input().split())
A=input().split()
L=list(A)
no=0
for i in range(M):
  l=L[i]
  ll=int(l)
  no+=ll

if no<=N:
  print(N-no)
else:
  print('-1')

Solution (Python):
import numpy as np

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

sum = np.sum(a)

day = n - sum

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

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

Solution (Python):


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



if __name__ == '__main__':
    main()

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

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

list_A_int = [int(s) for s in list_A]

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

Solution (Python):
from sys import stdin

holiday_count, task_count = stdin.readline().rstrip().split()
holiday_count = int(holiday_count)
tasks_days = sum([int(x) for x in stdin.readline().rstrip().split()])

remain = holiday_count - tasks_days
if remain < 0:
  print(-1)
else:
  print(remain)

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

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

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

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

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

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

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

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

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

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

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

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

Solution (Python):
x, y = map(int, input().split())

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

for single in range(y):
  sumDays += days[single]

if sumDays <= x:
  print(x - sumDays)
else:
  print(-1)

Solution (Python):
inputLine=input()
N = int(inputLine.split(" ")[0])
M = int(inputLine.split(" ")[1])

inputLine=input()
A = inputLine.split(" ")

for i in range(len(A)):
    A[i] = int(A[i])

result = N - sum(A)

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

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

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

Solution (Python):
import sys
import math
n, m = map(int, input().split())
li = list(map(int, input().split()))
cnt = 0
for i in range(m):
    cnt += li[i]
if (cnt <= n):
    print(n-cnt)
else:
    print(-1)

Solution (Python):
def main():
    import sys
    N,M=list(map(int,sys.stdin.readline().split()))
    A=list(map(int,sys.stdin.readline().split()))
    print(max(N-sum(A),-1))


main()

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

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

Solution (Python):
import math
a = input().split()
b = map(int,input().split())
c = int(a[0])-sum(b)
if (c < 0):
    print("-1")
else:
    print(c)

Solution (Python):
import sys
input=sys.stdin.readline

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

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

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

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

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

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

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

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

syuku_sum = sum(M_list)

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

Solution (Python):

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

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

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

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

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

Solution (Python):


import sys



















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

if __name__ == "__main__":
    main()

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

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

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

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

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

vocation = N - sum(A)

print("{}".format(vocation) if vocation>=0 else -1)

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

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

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

num_days = n
num_hw = m
costs = a

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

print(ans)

Solution (Python):
from sys import stdin

holiday_count, task_count = stdin.readline().rstrip().split()
holiday_count = int(holiday_count)
tasks_days = sum([int(x) for x in stdin.readline().rstrip().split()])

remain = holiday_count - tasks_days
if remain < 0:
  print(-1)
else:
  print(remain)

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

Solution (Python):
a,b=map(int,input().split())
List=list(map(int,input().split()))
print(a-sum(List) if a>=sum(List) else "-1")

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

print(ans)

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

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

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

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

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

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

diff = N - sum(A)

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

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

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

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

Solution (Python):



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


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

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

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

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


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

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

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

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

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

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

l = n-sum(A)
if l < 0:
  l = -1

print(l)

Solution (Python):



def run():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))[:m]
    print(max(n - sum(a), -1))


if __name__ == '__main__':
    run()

Solution (Python):
N, M = map(int, input().split())
times = list(map(int, input().split()))
if (sum(times) <= N):
    print(N-sum(times))

else:
    print(-1)

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

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

a_sum = sum(a_list)

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

Solution (Python):
N,M = (int(i) for i in input().split())  
A = [int(i) for i in input().split()] 
res = N - sum(A)
if res > -1:
  print(res)
else:
  print(-1)

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

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

S = N - sum(A)

if S < 0:
    print("-1")
    exit()

print(S)

Solution (Python):
K_s,M_s = input().split()
A = map(int, input().split())
K = int(K_s)
M = int(M_s)
ans=K-sum(A)
if ans<-1:
    ans=-1
print(ans)

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

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

temp = sum(list(map(int,input().split())))

if N - temp > -1:
  print(N - temp)
else:
  print("-1")

Solution (Python):
import sys
input = sys.stdin.readline
def print_ans(N, M, ar):
    """Test Case
    >>> print_ans(41, 2, [5, 6])
    30
    >>> print_ans(10, 2, [5, 6])
    -1
    >>> print_ans(11, 2, [5, 6])
    0
    """
    tmp = N -sum(ar)
    if(tmp >= 0):
        print(tmp)
    else:
        print("-1")



if __name__ == '__main__':
    N, M = map(int, input().rstrip().split())
    ar = list(map(int, input().rstrip().split()))
    print_ans(N, M, ar)

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

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

Solution (Python):
n , m  = map(int , input().split())
vac = 0
numbers = list(map(int ,input().split()))
for i in numbers:
	vac += i
if n < vac:
	print(-1)
else:
	print(n-vac)

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

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

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

if ans > N:
    print('-1')
else:
    print(N-ans)

Solution (Python):
NM = list(map(int, input().split()))
N = NM[0]
M = NM[1]
A = list(map(int, input().split()))

days_for_work = 0

for i in A:
    days_for_work += i

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

Solution (Python):
N,M=map(int,input().split())
S=sum(map(int,input().split()))
print(max(-1,N-S))

Solution (Python):
import numpy as np


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

hw_days = n - np.sum(a)
if hw_days < 0:
    print("-1")
else:
    print(hw_days)

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

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

Solution (Python):
list1 = list(map(int , input().split()))
list2 = list(map(int , input().split()))

z = 0

for i in list2:
  z+=i
  
enjoy = list1[0] - z

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

Solution (Python):

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

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

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

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

print(N)

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

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

if holiday < 0:
  print('-1')
else:
  print(holiday)

Solution (Python):
s = input().split()
n = int(s[0])
m = int(s[1])
a = [m]
a = list(map(int, input().split()))
ans =0
for i in a:
    ans = ans + i

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

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

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

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

for i in range(m):
    n-=lis[i]

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

Solution (Python):
N,M = map(int, input().split())
list_1 = list(map(int, input().split()))
 
i=0
sum=0
 
while i<M:
  sum=sum+list_1[i]
  i=i+1
  
if sum>N:
  print("-1")
  
else:
  print(abs(sum-N))

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

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

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

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

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

Solution (Python):
input_list = list(map(int, input().split(" ")))

n = input_list[0]
m = input_list[1]
a_i_list = list(map(int, input().split(" ")))


a_i_sum = sum(a_i_list)

result = n - a_i_sum

if result < 0:
    result = -1

print(result)

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

Solution (Python):
import math
if __name__ == "__main__":
	r = [ int(i) for i in input().split(" ")]
	n = r[0]
	m = r[1]

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

	sm = 0
	for i in range(m):
		sm += ass[i]

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

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

sum_home_day = sum(lists)

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

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

sum = sum(a)

if (sum > n):
    print(-1)
    exit()

print(n - sum)

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

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

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

Solution (Python):
if __name__ == '__main__':
    nm = list(map(int, input().rstrip().split()))
    days = list(map(int, input().rstrip().split()))

    n = nm[0]
    total = sum(days)
    val = n - total

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

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

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

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

B = sum(A)

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

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

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

rest = N - sum(h)

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

Solution (Python):
N, M = [int(s) for s in input().split()]
A = [int(a) for a in input().split()]

d = N - sum(A)

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

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

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

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

Solution (Python):
N, M = map(int,input().split())
li = list(map(int,input().split()))	
ans = 0
for i in range(M):
  ans += li[i]
  
answer = N-ans
if answer >= 0:
  print(answer)
else:
  print("-1")

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

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

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

Solution (Python):
N,M = map(int,input().split())
A = []
A = map(int,input().split())

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

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

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

Solution (Python):
import numpy as np

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

dif = N - sum(A)

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

Solution (Python):
import sys
from functools import lru_cache
input = sys.stdin.readline
sys.setrecursionlimit(2 * 10**6)


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


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


if __name__ == '__main__':
    main()

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

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

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

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

Solution (Python):
n, m = map(int, input().split())
l_a = list(map(int, input().split()))

ans = n - sum(l_a)
if(ans < 0):
    ans = -1

print(ans)

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

Solution (Python):
N,Q = map(int ,input().split())
A = list(map(int ,input().split()))

hw_days = sum(A)

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

Solution (Python):
n, m = map(int, input().split())
aa = map(int, input().split())
total = 0
for a in aa:
    total += a
    if total > n:
        total = -1
        break

print(-1 if total == -1 else n - total)

Solution (Python):
n, m = map(int, input().split())
hw = []
hw = list(map(int, input().split()))

vacation_day = n - sum(hw)

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

Solution (Python):
import math

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

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

Solution (Python):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))
n,m = iim()
A = iil()

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

Solution (Python):
n, m = map(int, input().split())
aList = list(map(int, input().split()))

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

Solution (Python):

import sys
import numpy as np


def solve(N: int, M: int, A: "List[int]"):
    ans = N-sum(A)
    if ans<0:
        print(-1)
    else:
        print(ans)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    M = int(next(tokens))  
    A = [int(next(tokens)) for _ in range(M)]  
    solve(N, M, A)

if __name__ == '__main__':
    main()

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

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

Solution (Python):



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


rest = N
for i in range(M):
    rest -= A[i]
    
if rest<0:
    print('-1')
else:
    print(rest)

Solution (Python):
M, N = map(int, input().split())
A = list(map(int, input().rstrip().split()))
sums = 0
for day in A:
    sums += day
if sums < M:
    result = M - sums
elif sums > M:
    result = -1
elif sums == M:
    result = 0
print(result)

Solution (Python):
mylist = []
n, m = map(int, input().split())
mylist += (map(int, input().split()))
if sum(mylist) > n:
    print(-1)
else:
    print(n - sum(mylist))

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

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

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

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

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

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

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

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

Solution (Python):
n, m = tuple(map(int, input().split(" ")))
print(max(n - sum(map(int, input().split(" "))), -1))

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