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()))
for i in a:
  n -= i
if n >=0:
  print(n)
else:
  print(-1)

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

a_sum = sum(a)
asobi = n - a_sum

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

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

y=input()
y_list=y.split()

sum1=0
count=0

for i in range(M):
  s=int(y_list[count])
  count+=1
  sum1+=s

if N>=sum1:
  print(N-sum1)
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 = [int(i) for i in input().split()]
print(N-sum(A) if N-sum(A) >= 0 else -1)

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

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

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

print(n-s if n-s>=0 else "-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()))
day = sum(a)
if day <= n:
    print(n-day)
else:
    print('-1')

Solution (Python):
n,m = map(int,input().split())
a = list(map(int,input().split()));
x = 0;
y = -1;

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

if x > n:
    print(y);
else:
    print(n-x);

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

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

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

Solution (Python):


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

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

Solution (Python):
N, M = map(int, input().split())
total = 0
for A in input().split():
    total = total+int(A)
if total > N:
    ans = -1
else:
    ans = N-total
print(ans)

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

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

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

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

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:
        print("-1")
        exit()
    elif N>=0 and i+1 == M:
        print(N)
        exit()

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

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

Solution (Python):
import sys
import math
def main():
    N,M=tuple(map(int,sys.stdin.readline().split()))
    r=N-sum(tuple(map(int,sys.stdin.readline().split())))
    print('-1') if r<0 else print(r)
if __name__=='__main__':main()

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

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

Solution (Python):
n = [int(i) for i in input().split()]
N = n[0]
M = n[1]

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


A_sum = sum(A)

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

Solution (Python):
n,m=map(int,input().split())
arr = list(map(int, input().split()))
A=[]
suM=0
for i in arr:
  A.append(i)
for i in A:
  suM+=i
if suM>n:
  print(-1)
elif (suM==n) or (suM<n):
  print(n-suM)

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

Solution (Python):
def main():

    N, M = input_ints()

    A = input_int_list_in_line()

    day = N - sum(A)

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


def input_int():
    return int(input())


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


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


def input_int_tuple_list(n: int, q: int):
    return [tuple(map(int, input().split())) for _ in range(n)]


main()

Solution (Python):
def main():

    N, M = input_ints()

    A = input_int_list_in_line()

    day = N - sum(A)

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


def input_int():
    return int(input())


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


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


def input_int_tuple_list(n: int, q: int):
    return [tuple(map(int, input().split())) for _ in range(n)]


main()

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

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

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

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

Solution (Python):
n = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
sum_a = sum(a)
if(sum_a <= n[0]):
	print(n[0] - sum_a)
else:
	print('-1')

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

days,tasks = arr[0],arr[1]

def main(days, ais):
  sum = 0
  for i in ais:
    sum += i
    if sum > days: return -1

  return days - sum

print(main(days, ais))

Solution (Python):
[N, M]=list(map(int, input().split()))
alist=list(map(int, input().split()))
day=0
for a in alist:
    day+=a
if day>N:
    print(-1)
else:
    print(N-day)

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

for i in a:
    sum += i

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

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

day = sum(a)

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

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

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

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

Solution (Python):
n, m = map(int, input().split())
lst = list(map(int, input().split()))
s = sum(lst)
if n >= s:
  print(n - s)
else:
  print(-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):
def solve(n,m,a_list):
  days = n - sum(a_list)
  return days if days >= 0 else -1

n, m = map(int,input().split())
a_list = list(map(int,input().split()))
ans = solve(n,m,a_list)
print(ans)

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

workdays=int()

for i in a:
    workdays += i

if workdays>n:
    print("-1")

else:
    print(n-workdays)

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

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

Solution (Python):

def main():
    n, m = list(map(int, input().split()))
    a_list = list(map(int, input().split()))
    
    homework_day = 0
    for task in a_list:
        homework_day += task
    
    play_day = n - homework_day
    if play_day >= 0:
        print(play_day)
    else:
        print(-1)

if __name__ == '__main__':
    main()

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

Solution (Python):
def main():
  n, m = map(int, input().split())
  
  A = list(map(int, input().split()))
  
  total = sum(A)
  
  if total > n:
    print(-1)
    return
  
  free = n - total
  print(free)
  
main()

Solution (Python):
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, M = map(int, readline().split())
A = list(map(int,readline().split()))
B = sum(A)
if B > N:
    print(-1)
else:
    print(N-B)

Solution (Python):
import sys
import itertools

import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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()))
b = 0
for i in range(m):
  b +=a[i]
if n<b:
  print("-1")
else:
  print(n-b)

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

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()))
def s(a,n):
    if a<=n:
        return n-a
    else:
        return -1
print(s(sum(a),n))

Solution (Python):
import numpy as np
def cumsum(x):
    return list(np.cumsum(x))

def cumsum_number(N,K,x):
    ans=[0]*(N-K+1)
    number_cumsum = cumsum(x)
    number_cumsum.insert(0,0)
    for i in range(N-K+1):
        ans[i]=number_cumsum[i+K]-number_cumsum[i]
    return ans
"""
int 
float 


for name in fruits: 
    print(name)


list0 = [] 
list0 = [1,2,3,4] 
list0 = [0]*10 
list1= [i for i in range(10)] 
list1 = list(map(int, input().split()))　
number=[int(input()) for i in range(int(input()))] 
list1 = list1 + [6, 7, 8] 
list2.append(34) 
list.insert(3,10) 
len(list4) 
max(sa) 
list5.count(2) 
list1.sort() 
list1.sort(reverse=True)  
set(list1) 
sum([2,3,   ,3]) 

abs(a) 
max(a,b) min(a,b) 
text1 = text1.replace("34","test") 

exit(0) 

cumsum(リスト) 
cumsum_number(N,K,x) 
"""
N,M=map(int,input().split())
day=sum(list(map(int,input().split())))
if day<=N:
    print(N-day)
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 = [i for i in map(int, input().split())]

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

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

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

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

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

Solution (Python):
N, M = map(int, input().split())
a_list = list(map(int, input().split()))
days = sum(a_list)
if N >= days:
    print(N-days)
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 = [int(i) for i in 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()))
sum_day = N - sum(A)
print(sum_day if sum_day >= 0 else -1)

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

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

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

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

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

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

Solution (Python):
import sys
from collections import deque
import numpy as np
import math
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def Main():
    n,m = IL()
    a = np.array(list(IL()))
    b = np.cumsum(a,axis=0)
    if n<b[-1]:
        print(-1)
    else:
        print(n-b[-1])
if __name__=='__main__':
    Main()

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

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

s = sum(a)

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

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

N, M = inpl()
print(max(-1, N - sum(inpl())))

Solution (Python):
n = int(input().split()[0])
print(max(-1, n - sum(map(int, input().split()))))

Solution (Python):
def resolve():
    a, b = input().strip().split(' ')
    n, m = [int(a), int(b)]
    array = list(map(int, input().strip().split(' ')))
    homework_sum = 0
    for i in range(m):
        homework_sum = homework_sum + array[i]
    if n - homework_sum >= 0:
        ans = n - homework_sum
    else:
        ans = -1
    print(ans)
resolve()

Solution (Python):
import numpy as np

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

    kadai = np.sum(a)
    if n<kadai:
        print(-1)
    else:
        print(n-kadai)

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

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

homework = sum(A)

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

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

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

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

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

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

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

Solution (Python):

import sys
import numpy as np


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

A = np.array(A)
d = np.sum(A)        



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

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

days = sum(A)
holidays = N - days

if holidays >= 0:
    print(holidays)
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):
    print(n-sum(a))
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):

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

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


if __name__ == "__main__":
    main()

Solution (Python):
ALL, num = map(int, input().split())
time = list(map(int, input().split()))
if (ALL - sum(time)) >=0:
  print(ALL - sum(time))
else:
  print("-1")

Solution (Python):
a=input()
a=a.split()
N=int(a[0])

b=input()
b=b.split()

z=0

for x in b:
  z=z+int(x)

w=N-z

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

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):
def main():
  import math
  n,m=map(int,input().split())
  a=list(map(int,input().split()))
  if(n<sum(a)):
    print(-1)
    return 0
  print(n-sum(a))

main()

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

for a in A:
    n -= a
    if n < 0:
        print(-1)
        break
else:
    print(n)

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

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

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

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

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)

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

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

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

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

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

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

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

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

Solution (Python):
import math
def fact(n):
    ans = 1
    for i in range(2, n+1):
        ans*= i
    return ans
def comb(n, c):
    return fact(n)//(fact(n-c)*c)

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

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

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

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

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

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

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

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

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

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

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

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

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

Solution (Python):

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

arr=[int(i)for i in input().split()]
s=sum(arr)
if s>n:
  print(-1)
elif s==n:
  print(0)
else:
  print(n-s)

Solution (Python):

n, m, *a = map(int, open(0).read().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()))
print(n - sum(a) if n >= sum(a) else -1)

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

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

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

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

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())
for Ai in input().split():
  i = int(Ai)
  N = N - i
  if N < -1:
    N = -1
    break
print(N)

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

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

Solution (Python):
a,b = map(int,input().split())
li = list(map(int,input().split()))
sum = 0
for i in li:
    sum += i

result = a - sum
if result < 0:
    print("-1")
else:
    print(result)

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):
def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    for i in a:
        n -= i
    print(n) if n > -1 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):
  print(n-sum(A))
else:
  print(-1)

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

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


if __name__ == '__main__':
    solve()

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

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

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

s=0
c=0

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

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

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

flag=0

for i in range(M):
  N-=A[i]
  if N<0:
    flag=1
    break

if flag==1:
  print(-1)
else:
  print(N)

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

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

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

if __name__ == '__main__':
    main()

Solution (Python):
N,M = list(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=input().split()
A=[]
for _ in a:
    A.append(int(_))
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()))

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

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

sum = 0
for i in kadai:
  sum += i

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

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

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

s=0
for i in a:
    s+=i
    if s > n :
        print(-1)
        break
else:
    print(n-s)

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

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

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

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

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

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

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

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

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

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

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

if sum(k) > int(n):
    print("-1")
    exit()

kekka = int(n) - sum(k)

print(kekka)

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

Su=sum(A)

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

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

a = [int(x) for x in input().split()]
ans = max(-1, n - sum(a))

print(ans)

Solution (Python):
def main():
    nm = input().split()
    N = int(nm[0])
    a = list(map(int,input().split()))
    if sum(a) > N:
        print(-1)
    else:
        print(N - sum(a))




main()

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)

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

day = sum(A)

if m < day:
    print(-1)
else:
    print(m-day)

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

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

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

ret = -1
sum_a = sum(a)
if sum_a <= n:
    ret = n - sum_a

print("{}".format(ret))

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

syukudai = sum(list(map(int, input().split())))
if N-syukudai < 0:
    print("-1")
else:
    print(N-syukudai)

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]
print(N-count if N-count >= 0 else "-1")

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


if gokei <= a:
    print(a - gokei)
else:
    print("-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()))
sA = sum(A)
if sA > N:
    print(-1)
else:
    print(N-sA)

Solution (Python):
def actual(n, m, a_list):
    left_days = n - sum(a_list)

    if left_days < 0:
        return -1

    return left_days


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

print(actual(n, m, a_list))

Solution (Python):
n_m = input().rstrip().split(' ')

n = int(n_m[0])
m = int(n_m[1])

a_i = input().rstrip().split(' ')
a_i_list = [int(i) for i in a_i[:m]]

finish_day = sum(a_i_list)

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

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

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


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

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

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

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