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):
from collections import Counter
import sys

sys.setrecursionlimit(10 ** 6)

mod = 1000000007
inf = int(1e18)

dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]


def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft

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

main()

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



 
import sys
import math



 

fileoperation=0
if(fileoperation):
    orig_stdout = sys.stdout
    orig_stdin = sys.stdin
    inputfile = open('W:/Competitive Programming/input.txt', 'r')
    outputfile = open('W:/Competitive Programming/output.txt', 'w')
    sys.stdin = inputfile
    sys.stdout = outputfile


mod=1000000007
 

def nospace(l):
    ans=''.join(str(i) for i in l)
    return ans
 
 
 

t=1
for tt in range(t):
    
    n,m= map(int, sys.stdin.readline().split(' '))
    a=list(map(int,sys.stdin.readline().split(' ')))
    if(sum(a)>n):
        print(-1)
    else:
        print(n-sum(a))
    
    

if(fileoperation):
    sys.stdout = orig_stdout
    sys.stdin = orig_stdin
    inputfile.close()
    outputfile.close()

Solution (Python):
n, m = map(int,input().split())
w = tuple(map(int,input().split())) 
day = 0
for d in w:
    day += d
ans = n - day
if (ans >= 0):
    print(ans)
else:
    print(-1)

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

days_sum = sum(A)



ans = N - days_sum

if ans < 0:
  ans = -1

print(ans)

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

Solution (Python):
import os

def main():
        n,m = map(int, input().split())
        a_list = list(map(int, input().split()))
        if n < sum(a_list):
                print(-1)
        else:
                print(n - sum(a_list))

if __name__ == "__main__":
        main()

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

Solution (Python):
N_M = input().split(" ")
total = 0
s = input().split(" ")

for i in range(int(N_M[1])):
    total += int(s[i])
result = int(N_M[0]) - total
if result < 0:
    print(-1)
else:
    print(result)

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

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

s=0
for i in range(m):
    s=s+a[i]

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

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

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

     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
N,M=nm()
A=nl()

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

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

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


if __name__ == "__main__":
    main()

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

A = [int(_) for _ in input().split()]

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

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

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):
def main(N, M, A):
    memo = N - sum(A)
    if memo >= 0:
        return memo
    else:
        return -1

if __name__ == '__main__':
    N, M = list(map(int, input().split()))
    A = list(map(int, input().split()))
    
    
    
    
    print(main(N, M, A))

Solution (Python):
n, m = 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=[int(x) for x in input().split()]
A=[int(x) for x in input().split()]

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

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

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

main()

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

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

Solution (Python):
import math

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

tot = sum(Ai)

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

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

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

temp = sum(homeworks)

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

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

Solution (Python):
N,M = 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 = list(map(int, input().split()))

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

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

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

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

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

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

for i in range(0,m):
    count+=a[i]
if count>n:
    print("-1")
else:
    print(n-count)

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

free = N - sum(A)

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

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

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

for i in range(M):
  days += li_a[i]

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

Solution (Python):
import math

def solution():
    n, m = map(int, input().split())
    a = [int(aa) for aa in input().split()]
    ans = n - sum(a)
    if ans < 0:
        print('-1')
    else:
        print(ans)

solution()

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

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

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

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

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

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

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

ans = N - sum(cons)
if(ans < 0):
        ans = -1

print(ans)

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

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

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

N -= sum(a_ar)

if N < 0:
  N = -1

print(N)

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

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

Solution (Python):


int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solve():
    n, m = MI()
    A = LI()

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


if __name__ == '__main__':
    solve()

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

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

Solution (Python):
N,M=map(int,input().split())
A=list(map(int,input().split()))
s=0
for i in A:
    s+=i
a=N-s
if a>=0:
    print(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=list(map(int,input().split()))

nissuu=sum(A)

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

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

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

Solution (Python):
import sys
input = sys.stdin.readline
def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    ans = N
    for i in range(M):
        ans -= A[i]
    if ans < 0:ans = -1
    print(ans)
if __name__ == "__main__":
    main()

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

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

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

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

Solution (Python):
import sys
n,m=map(int,input().split())
A=list(map(int,input().split()))
ans=n
for a in A:
  ans-=a
  if ans<0:
    print('-1')
    sys.exit()
print(ans)

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

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

ans = X - sum(s)

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

Solution (Python):
t=list(map(int,input().split(' ')))
u=list(map(int,input().split(' ')))
x=t[0]-sum(u)
if x>=0:
    print(x)
else:
    print('-1')

Solution (Python):

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

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

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

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

a = input().split(" ")
res = 0
for ai in a:
    res += int(ai)
    if res > n:
        print("-1")
        exit()

print(n-res)

Solution (Python):
import math

class abc_163:
    
    def __init__(self):
        pass
    
    def A(self):
        r=int(input())
        print(2*math.pi*r)
    
    def B(self):
        NM=list(map(int,input().split()))
        A=list(map(int,input().split()))
        
        if NM[0]-sum(A)>=0:print(NM[0]-sum(A))
        else:print("-1")
    
if __name__=='__main__':
    obj=abc_163()
    obj.B()

Solution (Python):
import sys

lines = sys.stdin.readlines()

X = lines[0].split(' ')
Y = lines[1].split(' ')

N = int(X[0])
M = int(X[1])

d = 0
for i in range(M):
    d = d + int(Y[i])

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

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):
X=input().split()
N=int(X[0])
M=int(X[1])
A=list(map(int,input().split()))
y=N-sum(A)
z=0
if y>=0:
  z=y
else:
  z=-1
print(z)

Solution (Python):
import math
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
mod = 10**9 + 7 
sys.setrecursionlimit(1000010)


N,M = nm()
A  = nl()
ans = max(-1,N - sum(A))
print(ans)

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

if kakaru <= a:
    print(a - kakaru)
else:
    print("-1")

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


L, R = map(int,input().split())


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


S = L - sum(huga)
if S < 0 :
  S = -1

print(S)

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

Solution (Python):
import numpy as np


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


if __name__ == '__main__':
    main()

Solution (Python):
from collections import defaultdict, Counter

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

s = sum(a)

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

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

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

Solution (Python):
Days , number = map(int,input().split())
A_list = list(map(int,input().split()))

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

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

Solution (Python):
out, n = map(int,input().split())
l = map(int,input().split())
for v in l:
    out -= v
if out < 0:
    out = -1        
print(out)

Solution (Python):
from sys import stdin, stdout
import math,sys
from itertools import permutations, combinations
from collections import defaultdict,deque,OrderedDict
import bisect as bi
import heapq 
'''


def I():return (int(stdin.readline()))
def In():return(map(int,stdin.readline().split()))
'''



def I():return (int(input()))
def In():return(map(int,input().split()))

def find_gt(a, x):
    
    i = bi.bisect_right(a, x)
    if i != len(a):
        return i
    else:
        return -1


def main():
    try:
        a,b=In()
        l=list(In())
        n=sum(l)
        if a-n<0:
            print(-1)
        else:
            print(a-n)
            
    except:
        pass
M = 998244353
P = 1000000007

if __name__ == '__main__':
    main()

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

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

Solution (Python):
N = [int(e) for e in input().split()]
nums = [int(t) for t in input().split()]
sums = 0
for k in range(0,N[1]):
    sums += nums[k]
if(sums > N[0]):
    print(-1)
else:
    print(N[0] - sums)

Solution (Python):
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)

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

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

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

Solution (Python):



def main():
    n, m = map(int, input().split(" "))
    a = [int(s) for s in input().split(" ")]
    total = sum(a)
    if n >= total:
        print(n - total)
    else:
        print("-1")


if __name__ == '__main__':
    main()

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

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

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

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

print(N - sum(A))

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

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

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

Solution (Python):
n,m=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(lambda x: int(x) ,input().split())
a = input().split()
a = [int(_) for _ in a]

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

Solution (Python):
day, num = map(int,input().split())
work = [int(x) for x in input().split()]

sum = sum(work)

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

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

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

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

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):
x = input().split()
c  =int(x[0])
v = input().split()
f = 0
for i in v:
  f += int(i)
m = c - f
if m < 0:
  print('-1')
else:
  print(m)

Solution (Python):
(N, M) = list(map(int, input().split()))
A = list(map(int, input().split()))
total = 0
for a in A:
    total += a

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

Solution (Python):

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

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

Solution (Python):
n, m = map(int, input().split())
l = list(map(int, input().split()))
for k in range(m):
    n -= l[k]
if n < 0:
    n = -1
print(n)

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

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

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

Solution (Python):
import numpy as np
N, M = map(int, input().split())
data = np.array(input().split(), dtype=np.int64)


sum = N - np.sum(data)

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

Solution (Python):
import sys
input = sys.stdin.readline
def main():
  n,m=map(int,input().split())
  a=list(map(int,input().split())) 
  ans=0
  for i in range(m):
    ans+=a[i]
  if ans<=n:
      print(n-ans)
  else:
      print('-1')
main()

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

day = sum(A)

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

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

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

answer = -1
if n >= sum:
  answer = n - sum

print(answer)

Solution (Python):
import sys

def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(get_ints())
def input(): return sys.stdin.readline().strip()


n, m = get_ints()
Arr = get_array()
Sum = sum(Arr)
if Sum > n:
	print(-1)
else:
	print(n - Sum)

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

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

Solution (Python):
params0 = list(map(lambda x: int(x), input().split(' ')))
params1 = list(map(lambda x: int(x), input().split(' ')))

days = params0[0]
required = sum(params1)
if days >= required:
    print(days - required)
else:
    print(-1)

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

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

    joy = N-sum(A)
    if joy >= 0:
        print(joy)
    else:
        print(-1)
if __name__ == '__main__':
    solve()

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

if __name__ == '__main__':
  main()

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

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

wa = sum(A)
if n < wa:
  print(str(-1))
else:
  print(n-wa)

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

sum=0
for i in range(m):
  sum=sum+a[i]

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

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


if __name__ == "__main__":
    main()

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

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

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

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

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

Solution (Python):
import sys
N,_ = map(int, sys.stdin.readline().split())
A = map(int, sys.stdin.readline().split())

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

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

tmp = []
for i in listA:
    tmp.append(int(i))

ans = N - sum(tmp)

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

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


if __name__ == '__main__':
    main()

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


if __name__ == '__main__':
    main()

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

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

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

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

def main():
  n, m = map(int, input().split())
  arg = [int(i) for i in input().split()]
  for i in arg:
    n -= i
    if n < 0:
      return -1
    
  return n
  
if __name__ == '__main__':
  print(main())

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

Solution (Python):
a, b = list(map(int, input().split()))
c = list(map(int, input().split()))
for i in range(b):
    a = a-c[i]

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

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

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


if __name__ == '__main__':
    main()

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

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

ans = n - sum(A)

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

Solution (Python):
import sys
from math import factorial
from collections import Counter
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7


N, M = MAP()
A = LIST()
if sum(A)>N:
    print(-1)
else:
    print(N-sum(A))

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

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

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

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

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

A = map(int,input().split())
b = N-sum(A)
print(-1 if b < 0 else b)

Solution (Python):
n,m = map(int,input().split())
a_list = list(map(int,input().split()))
sum_a = sum(a_list)
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()))

total = 0
for b in range(m):
  total += a[b]
  
if n - total >= 0:
  print(n-total)
else :
  print('-1')

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

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

Solution (Python):
if __name__ == "__main__":
  n, m = map(int, input().split())
  a_list = [int(i) for i in input().split()]
  hw_sum = sum(a_list)
  if hw_sum > n:
    print(-1)
    exit()
  else:
    print(n-hw_sum)

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

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

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

Solution (Python):
n,m = map(int,input().split())
all = list(map(int,input().split()))
result = 0

for i in range(m):
    result += all[i]

result = max(-1 ,n-(result))
print(result)

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

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

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

print(ans)

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

A = [int(n) for n in input().split()]

subjects = sum(A)

if subjects > N:
    print(-1)

else:
    print(N-subjects)

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

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

for i in range(0,M):
  r+=list[i]

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

Solution (Python):


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

ans=-1
SUM=0
for i in range(M):
    SUM += A[i]
if SUM <= N:
    ans = N - SUM

print(ans)

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

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

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

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

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

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

Solution (Python):


from sys import stdin


def main():
    N, M = map(int, stdin.readline().split())
    A = list(map(int, stdin.readline().split()))

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


if __name__ == "__main__":
    main()

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

t=0
for i in li:
    t+=int(i)
if n-t < 0:
    print(-1)
else:
    print(n-t)

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

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