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-----
41 2
5 6

-----Sample Output-----
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.

Difficulty: introductory

Starter code:

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

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

    print((max(-1, n - sum(homeworks))))
    return


def __starting_point():
    main()

__starting_point()

N, M = map(int, input().split())
day = list(map(int, input().split()))
total = 0
for i in range(M):
  total += day[i]
if N >= total:
  print(N - total)
else:
  print('-1')

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

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

n,m = list(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))        
#print(a)


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

AA = sum(A)

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

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

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

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

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy,bisect
#from operator import itemgetter
#from heapq import heappush, heappop
#import numpy as np
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
#from scipy.sparse import csr_matrix
#from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
import sys

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
nf = lambda: float(ns())
na = lambda: list(map(int, stdin.readline().split()))
nb = lambda: list(map(float, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N, M = na()
A = na()
print(max(N - sum(A), -1))

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

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

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


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


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

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

a_t= sum(a)

if n < a_t :
    print('-1')
else :
    print(n - a_t)

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


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

answer = N - sum(A)

if N >= sum(A):
    print(answer)

else:
    print('-1')

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

day = 0

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

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


N,M = map(int,input().split())
lsA = list(map(int,input().split()))
sumA = sum(lsA)
print(max(-1,N-sumA))

#!/usr/bin/env python3
n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
ans = n-sum(a)

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


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

if N >= sum(work):
    answer = N - sum(work)
else:
    answer = '-1'
print(answer)

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

day = 0
for i in range(m):
    day = day + A[i-1]

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

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

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

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


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

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


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

n,_= my_input()
ans = n-sum(my_input())
print((ans if ans>=0 else -1))


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

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


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

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

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


N, M = list(map(int, input().split()))
A_list = []
for i in range(1, M+1):
    A_list.append("A_" + str(i))
A_list = list(map(int,input().split()))

answer = N - sum(A_list)

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


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

ans = max(n - sum(a), -1)
print(ans)


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

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

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

day = 0
for i in range(len(A)):
    day = day + A[i-1]

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

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

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

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

N,M,*A=map(int,open(0).read().split());print(max(-1,N-sum(A)))

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

homework = sum(aa)

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

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

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

import sys
from collections import deque, defaultdict, Counter
from itertools import accumulate, product, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush
from math import ceil, floor, sqrt, gcd, inf
from copy import deepcopy
import numpy as np
import scipy as sp

INF = inf
MOD = 1000000007

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

tmp = 0
res = 0

for i in range(m):
    tmp += A[i]
res = max(-1, n - tmp)

print(res)


N,M=map(int,input().split());print(max(N-sum(map(int,input().split())),-1))

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

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

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


#ABC163
N,M=map(int,input().split())
A=[]
A=[int(M) for M in input().split()]
if N - sum(A) >= 0:
    print(N - sum(A))
else:
    print(-1)

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

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

N,M = list(map(int, input().split()))
day = list(map(int, input().split()))
total = 0
for i in range(M):
    total += day[i]

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



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

# 高橋君の夏休みは N 日間
# 夏休みの宿題が M 個
# 遊ぶことができる日数は？
# ただし、夏休み中に全ての宿題を終わらせることができないときは、-1 を出力

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

answer = N - sum(A)

if N >= sum(A):
    print(answer)

else:
    print('-1')

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

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


def __starting_point():

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

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

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

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

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

s = 0
n , m = list(map(int,input().split()))
a = list(map(int,input().split()))
for i in range(0 , len(a)):
    s = s + a [i]
if s > n:
    print((-1))
    return
print((n - s))


"""
高橋君の夏休みは N 日間です。
夏休みの宿題が M 個出されており、
i 番目の宿題をやるには Ai 日間かかります。
複数の宿題を同じ日にやることはできず、また、宿題をやる日には遊ぶことができません。
夏休み中に全ての宿題を終わらせるとき、最大何日間遊ぶことができますか？
ただし、夏休み中に全ての宿題を終わらせることができないときは、かわりに -1 を出力してください。
"""

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

# 全ての宿題にかかる日数 sum(data)

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


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

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

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


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

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

a=input().split()
b=input().split()
suma=0
for x in range(int(a[1])):
    suma+=int(b[x])
dias=(int(a[0]))-suma
if dias<0:
    print("-1")
else:
    print(dias)

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


def N():
    return int(input())
def L():
    return list(map(int,input().split()))
def NL(n):
    return [list(map(int,input().split())) for i in range(n)]
mod = pow(10,9)+7

#import numpy as np
import sys
import math
import collections

n,m = L()
a = L()
print(max(n-sum(a),-1))

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

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

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

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


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


#高橋君の夏休みは N 日間です。
#夏休みの宿題が M 個出されており
#i 番目の宿題をやるには Ai 日間かかります。
#夏休み中に全ての宿題を終わらせるぉとができないときは、かわりに '-1' を出力

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

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

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

def answer(N: int, M: int, A: list) -> int:
    A = sum(A)
    if N < A:
        return -1
    else:
        return N - A

print((answer(N, M, A)))


n, m = tuple(map(int, input().split()))
x = list(map(int, input().split()))
 
for _ in x:
  n -= _
  
if n >= 0:
  print(n)
else:
  print(-1)

a=input().split()
b=input().split()
suma=0
for x in range(int(a[1])):
    suma+=int(b[x])
dias=(int(a[0]))-suma
if dias<0:
    print("-1")
else:
    print(dias)

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

def main(n,m,a):
    days=sum(a)
    if days>n:
        return -1
    else:
        return n-days

def __starting_point():
    n,m,a=readinput()
    ans=main(n,m,a)
    print(ans)

__starting_point()

list = []
n, m = map(int, input().split())
a = input().split()[0:m]
for num in a:
    num = int(num)
    list.append(num)

answer = n - sum(list)
if n < sum(list):
    answer =  -1

print(answer)

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

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

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



s = 0
n , m = map(int,input().split())
a = list(map(int,input().split()))
for i in range(0 , len(a)):
    s = s + a [i]
if s > n:
    print(-1)
    return
print(n - s)

N,M,*l=map(int,open(0).read().split());print(max(-1,N-sum(l)))

radi=input()
list=radi.split(" ")
N=int(list[0])
days=input()
total=0
a=days.split(" ")
for items in a:
    total+=int(items)
if total>N:
    print((-1))
else:
    print((N-total))






# coding=utf-8

def __starting_point():
    N, M = list(map(int, input().split()))
    li = list(map(int, input().split()))

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


__starting_point()

import sys

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

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

sum_day = sum(A)

ans = N - sum_day

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

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

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

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

def calc(n, m):
    holidays = n
    a = list(int(v) for v in input().split())
    ans = holidays - sum(a)
    return ans if ans >= 0 else -1


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


def __starting_point():
    print((main()))

__starting_point()

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

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

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

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

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

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


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

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

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

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

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

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

n,m,*a=map(int,open(0).read().split());print(max(n-sum(a),-1))

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

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


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

if N >= sum(work):
    answer = N - sum(work)
else:
    answer = '-1'
print(answer)


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

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


N,M,*A=map(int,open(0).read().split());print([s:=N-sum(A),-1][s<0])

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

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

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

def i_input(): return int(input())
def i_map(): return list(map(int, input().split()))
def i_list(): return list(map(int, input().split()))
def i_row(N): return [int(input()) for _ in range(N)]
def i_row_list(N): return [list(map(int, input().split())) for _ in range(N)]

dnum,hwnum=i_map()
hws=i_list()
if dnum>=sum(hws):
    ans=dnum-sum(hws)
    print(ans)
else:
    print((-1))



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

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

x = 0
for day in days:
    x = x + int(day)

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

from numpy import cumsum
n,m=map(int,input().split())
l=(list(map(int,input().split())))
l=cumsum(l)[-1]
if n<l:
    print('-1')
else:
    print(n-l)

n, m = map(int, input().split())
a_list = list(map(int, input().split()))
a_total = sum(a_list)
ans = n - a_total

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

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

A=sum(L)

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

n,m=map(int,input().split());a=n-sum(map(int,input().split()));print([-1,a][a>=0])