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,D=map(int,(input().split()))
L=list(map(int,(input().split())))
S=sum(L)
if(S>N):
    print(-1)
else:
    print(N-S)

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

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

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

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

for day in li:
    x -= day

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

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

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

Solution (Python):


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

if __name__ == "__main__":
    main()

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

homework = sum(A)

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

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

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

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

res = N - sum(A)

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

Solution (Python):
from sys import stdin
from sys import setrecursionlimit
from math import pi
setrecursionlimit(10 ** 7)

n,m = map(int,stdin.readline().rstrip().split())
a = list(map(int,stdin.readline().rstrip().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()))

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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
mo = 10**9+7

def main():
	n,m = MI()
	a = LI()
	tot = sum(a)
	if tot > n:
		print(-1)
	else:
		print(n-tot)

if __name__ == '__main__':
	main()

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

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

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

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

Solution (Python):

import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

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

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

Solution (Python):
import sys

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    A = [int(a) for a in input().split()]
    if N < sum(A): print(-1)
    else: print(N - sum(A))

    return 0

if __name__ == "__main__":
    solve()

Solution (Python):
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N,M = map(int, readline().split())
    A = [int(i) for i in readline().split()]

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


if __name__ == "__main__":
    main()

Solution (Python):
n, m = 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 = 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 = n - sum(a)
if ans < 0:
    ans = -1

print(ans)

Solution (Python):
n,m=map(int,input().split())
l=list(map(int,input().split()))
ans=n
for i in l:
  ans-=i
  if ans<0:
    ans=-1
    break
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,m = map(int,input().split())
ls=list(map(int,input().split()))

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

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

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
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log,pi
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 

def ii(): return int(sys.stdin.readline().rstrip()) 
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) 
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]

def ss(): return sys.stdin.readline().rstrip() 
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) 
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]






n,m=mii()
arr=limii()

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Solution (Python):
import math
def main():

    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    v = sum(A)
    if v <= N: return N-v
    return -1

if __name__ == '__main__':
    print(main())

Solution (Python):




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



def int1(x):
    return int(x) - 1



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



def input_to_int_tuple():
    return tuple(map(int, input().split()))



def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


def main():
    n, m = input_to_int_map()
    a = input_to_int_tuple()

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

    return ret


if __name__ == "__main__":
    print(main())

Solution (Python):
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
import sys
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from functools import lru_cache, reduce
from math import gcd
from operator import add, itemgetter, mul, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7



N, M = list(map(int, sys.stdin.buffer.readline().split()))
A = list(map(int, sys.stdin.buffer.readline().split()))

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

Solution (Python):
inf = 10**15
mod = 10**9+7

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

Solution (Python):


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

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

print(ans)

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

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

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

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

Solution (Python):














mod = int(1e9+7)
INF = 1<<29
lINF = 1<<35

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

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

if __name__=='__main__':
    main()

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

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

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

if N< T:
    print("-1")
else:
    print(N-T)

Solution (Python):
from collections import deque, Counter as cnt
from collections import defaultdict as dd
from operator import itemgetter as ig
from bisect import bisect_right as bsr
from math import factorial, ceil, floor
import sys
sys.setrecursionlimit(1000000)


args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def nlist(n, v):
    if not n:
        return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]


def yesno(v):
    print(["Yes", "No"][not v])



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


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()

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

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

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

shuku = sum(A)

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

Solution (Python):
import sys
input = sys.stdin.readline
def main():
    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__":
    main()

Solution (Python):
def main():
    import sys
    sys.setrecursionlimit(10 ** 6)
    input = sys.stdin.readline
    N, M = [int(x) for x in input().strip().split()]
    A = sum([int(x) for x in input().strip().split()])
    if N - A < 0:
        print(-1)
    else:
        print(N - A)

if __name__ == '__main__':
    main()

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

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

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

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

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

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

Solution (Python):
from sys import stdin
from sys import setrecursionlimit
from collections import Counter, deque, defaultdict
from bisect import bisect_left
setrecursionlimit(1000000)

INF = int(1e10)
MOD = int(1e9 + 7)

def input():
    return stdin.readline()[:-1]


def main():
    from builtins import int, map
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    if N < sum(A):
        print(-1)
    else:
        print(N - sum(A))
   
if __name__ == '__main__':
    main()

Solution (Python):


import sys
import numpy as np
import math
input=sys.stdin.readline

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

n,m=LI()
a=LI()
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()))

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()))
homework = sum(a)

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

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

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

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

for v in A:
	n -= v

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

Solution (Python):
def main():
    n,m = tuple([int(t)for t in input().split()])
    a = tuple([int(t)for t in input().split()])

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

if __name__ == "__main__":
    main()

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

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

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

import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

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

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

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


print(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, *a = map(int, open(0).read().split())
x = n - sum(a)
print(x if x>=0 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):
import math
import copy
import sys
import fractions


import decimal
import heapq
import collections
import itertools
import bisect



sys.setrecursionlimit(100001)







def getInputIntList():
    outputDataList = []
    inputData = input().split()
    outputDataList = [int(n) for n in inputData]

    return outputDataList


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList




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

data = getInputIntList()

total = sum(data)

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

Solution (Python):
import sys







def main():

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

    total = sum(As)
    ans = N - total if total <= N else -1
    print(ans)


if __name__ == '__main__':
    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 math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    n, m = nm()
    a = nl()

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

if __name__ == '__main__':
    main()

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

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

Solution (Python):
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N, M = list(map(int,_in[0].split(' ')))  
    A_arr = list(map(int,_in[1].split(' ')))  
    
    cnt = -1 if N - sum(A_arr)<0 else N - sum(A_arr)
    
    print(cnt)

Solution (Python):
N, M, *X = map(int, open(0).read().split())

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

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

ax = sum(a)

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

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

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

Solution (Python):
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
sm = sum(list(map(int, input().split())))
if sm <= N: print(N - sm)
else: print(-1)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

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

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

Solution (Python):

import sys


def solve(N: int, M: int, A: "List[int]"):
    result = N - sum(A)
    if result >= 0:
        print(result)
    else:
        print(-1)
    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):

import sys


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



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

Solution (Python):
LI = lambda: list(map(int,input().split()))
MI = lambda: map(int,input().split())
yes = lambda: print("YES")
no = lambda: print("NO")
I = lambda: list(input())
J = lambda x: "".join(x)
II = lambda: int(input())
SI = lambda: input()

n,m = MI()
a = LI()
c = n-sum(a)
print(c if c>=0 else -1)

Solution (Python):
import sys

n, m, *a = map(int, sys.stdin.read().split())

def main():
    r = n - sum(a)
    print(r if r >= 0 else -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(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)

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

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

sumcost = 0
for a in aes:
  sumcost += a

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

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):
str1 = str(input())
s1 = str1.split(' ')
n = int(s1[0])
m = int(s1[1])
str2 = str(input())
s2 = str2.split(' ')
l2 = [int(x) for x in s2]
if n<sum(l2):
    print('-1')
else:
    print(n-sum(l2))

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

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

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

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

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

Solution (Python):

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

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

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

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 = max(-1, n - sum(A))
print(ans)

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

Solution (Python):
import sys

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


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

if __name__ == '__main__':
    resolve()

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

Solution (Python):
N,M = map(int,input().split())
A = list(map(int,input().split()))
tmp = N
for i in A:
    tmp -= i
ans = lambda x:x if x>=0 else -1
print(ans(tmp))

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


if __name__ == '__main__':
    resolve()

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

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

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

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

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

















mod = 10**9 + 7

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

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

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
A = LIST()

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

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()))
print(max(N - sum(A), -1))

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

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

Solution (Python):





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

ans = n-sum(a_L)

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

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

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

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