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()))
print(N - sum(A) if N - sum(A) >= 0 else -1)

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

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

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

s = sum(A)

ans = N - s

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

Solution (Python):
import sys
import numpy as np


n,k=map(int,sys.stdin.readline().split())
a=np.array(sys.stdin.readline().split(),dtype='int64')


print(max(-1,n-np.sum(a)))

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

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

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

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

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

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

ans=n-sum(a)

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

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

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

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

Solution (Python):
import sys
from io import StringIO
import unittest

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

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """41 2
5 6"""
        output = """30"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """10 2
5 6"""
        output = """-1"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """11 2
5 6"""
        output = """0"""
        self.assertIO(input, output)
    def test_入力例_4(self):
        input = """314 15
9 26 5 35 8 9 79 3 23 8 46 2 6 43 3"""
        output = """9"""
        self.assertIO(input, output)

if __name__ == "__main__":
    
    resolve()

Solution (Python):
n,m=map(int,input().split())
a = list(map(int,input().split()))
s = 0
for x in a:
    s += x
print(max(-1,n-s))

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

d = N - sum(A)

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

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

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

Solution (Python):
import sys
input = sys.stdin.readline
N, M = (int(i) for i in input().split())
A = [int(x) for x in input().split()]


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

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

Solution (Python):
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, chain
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp



class UnionFindEx:
    def __init__(self, size):
        
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'


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



main()

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

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

for i in a:
  n -= i


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

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

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

Solution (Python):
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from math import factorial, sqrt, ceil, gcd
from functools import lru_cache, reduce
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def dijkstra_heap(s, edge, n):
    
    d = [10**20] * n
    used = [True] * n 
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


def lcm(x, y):
    return (x * y) // gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm, numbers, 1)


def gcd_list(numbers):
    return reduce(gcd, numbers)


def is_prime(n):
    if n <= 1:
        return False
    p = 2
    while True:
        if p ** 2 > n:
            break
        if n % p == 0:
            return False
        p += 1
    return True



def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P


def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret



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

Solution (Python):
import numpy as np

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


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


nokori = N - np.sum(a_l)


if nokori >= 0:
    print(int(nokori))
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()))

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

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

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

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

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

Solution (Python):
import sys
sys.setrecursionlimit(10000000)


def main():
    N, M = map(int, input().split())
    A = [int(c) for c in input().split()]
    import numpy as np
    sum_ = np.sum(A)
    if N - sum_ < 0:
        print(-1)
    else:
        print(N - sum_)


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):
from sys import stdin
N,M=list(map(int,(stdin.readline().strip().split())))
A=list(map(int,(stdin.readline().strip().split())))
if N<sum(A):
    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)
print(max(-1,ans))

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

total_homework = sum(A)

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

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(x) for x in input().split()]
SUM = sum(A)
if SUM > N:
    print(-1)
else:
    print(N-SUM)

Solution (Python):
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math

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

import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()
A = lr()
if sum(A) > N:
    print(-1); exit()
answer = N - sum(A)
print(answer)

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

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

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

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):
N, M = list(map(int, input().split()))
A = sorted(list(map(int, input().split())), reverse=True)

total = sum(A)

if N < total:
    print(-1)
elif N == total:
    print(0)
else:
    print(N - total)

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

temp = sum(a)

if temp <= n:
  print(n-temp)
else:
  print("-1")

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

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

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

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

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

Solution (Python):
n,m,*a = map(int, open(0).read().split())

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

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

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

Solution (Python):
from sys import stdin
N,M = [int(x) for x in stdin.readline().rstrip().split()]
A = [int(x) for x in stdin.readline().rstrip().split()]
ans = N - sum(A)
if ans < 0:
    print(-1)
else:
    print(ans)

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

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

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


if __name__ == '__main__':
    main()

Solution (Python):
def main():
  N, M = (int(_) for _ in input().split())
  A = [int(_) for _ in input().split()]
  s = sum(A)
  print(N - s if N - s >= 0 else -1)
  return

if __name__ == '__main__':
  main()

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

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

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

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


main()

Solution (Python):

def main():
    n,m = map(int,input().split())
    a_s = list(map(int,input().split()))
    a_s.sort()
    for a in a_s:
        n -= a

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

if __name__ == '__main__':
    main()

Solution (Python):
import math
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)
else:
    print(n)

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 = (int(i) for i in input().split())
l=(int(i) for i in input().split())
s = sum(l)
if n>= s:print(n-s)
else:print(-1)

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

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

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

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

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

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

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()))
AA=sorted(A)
S=sum(AA[:M])
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()]
sums = sum(a)
if n<sums:
    print(-1)
else:
    print(n-sums)

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()))
A_total = sum(A)
if N - A_total >=0:
    print(N-A_total)
else:
    print(-1)

Solution (Python):
from sys import stdin
n,m = [int(x) for x in stdin.readline().rstrip().split()]
a = [int(x) for x in stdin.readline().rstrip().split()]
s = sum(a)
s = n-s
if s >= 0:
    print(s)
else:
    print(-1)

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

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

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

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

if left >= 0:
    print(left)
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):
import sys
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,m = na()
a = na()

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()))
print(N - sum(A) if N - sum(A) >= 0 else -1)

Solution (Python):
import sys










sys.setrecursionlimit(10**6)
readline = sys.stdin.readline


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

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

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
mod = 10**9+7
import sys
from collections import Counter, defaultdict, deque
from itertools import product, permutations, combinations
from itertools import accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from math import ceil,floor
from copy import deepcopy
from heapq import heappop,heappush,heapify
import heapq


sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1


p2D = lambda x: print(*x, sep="\n")

def II(): return int(sys.stdin.readline())

def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())




def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI(): return list(map(lambda x:int(x), sys.stdin.readline().split()))
def HI(): return list(map(lambda x:int(x)*(-1), sys.stdin.readline().split()))




n,m = MI()
a = LI()

r = n-sum(a)
if r>=0:
	print(r)
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())
Hlist = list(map(int, input().split())) 
tot = sum(Hlist)
if tot > N:
  print(-1)
else:
  print(N-tot)

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

Solution (Python):
import bisect,sys
import math
from collections import deque

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29

DIV = (10**9) + 7

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max, mod=DIV):
    fac, finv, inv = [0]*max, [0]*max, [0]*max
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        finv[i] = finv[i-1]*inv[i] % mod

    class CONV:
        def __init__(self):
            self.fac =fac
            self.finv = finv
            pass

        def ncr(self, n, k):
            if(n < k):
                return 0
            if(n < 0 or k < 0):
                return 0
            return fac[n]*(finv[k]*finv[n-k] % DIV) % DIV
        
    return CONV()



sys.setrecursionlimit(200005)


def main():
    N,M = isRaw()
    As = isRaw()
    sAs = sum(As)
    if sAs > N:
        return -1
    
    ans = N-sAs
    return ans

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

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

Solution (Python):
N, M = map(int, input().split())
lst = list(map(int, input().split()))
su = sum(lst)
if N-su >= 0:
    print(N-su)
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 = list(map(int,input().split()))
result = 0
for i in range(M):
    result += A_list[i]
    if result > N:
        print(-1)
        exit(0)
print(N-result)

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

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

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

Solution (Python):
import sys
import os
from io import BytesIO, IOBase






'''def sieve(n):
    if n < 2: return list()
    prime = [True for _ in range(n + 1)]
    p = 3
    while p * p <= n:
        if prime[p]:
            for i in range(p * p, n + 1, p):
                prime[i] = False
        p += 2
    r = [2]
    for p in range(3, n + 1, 2):
        if prime[p]:
            r.append(p)
    return r'''


'''def divs(n, start=1):
    divisors = []
    for i in range(start, int(n**.5) + 1):
        if n % i == 0:
            if n / i == i:
                divisors.append(i)
            else:
                divisors.extend([i, n // i])
    return len(divisors)'''


'''def divn(n, primes):
    divs_number = 1
    for i in primes:
        if n == 1:
            return divs_number
        t = 1
        while n % i == 0:
            t += 1
            n //= i
        divs_number *= t
    return divs_number'''


'''def flin(d, x, default=-1):
    left = right = -1
    for i in range(len(d)):
        if d[i] == x:
            if left == -1: left = i
            right = i
    if left == -1:
        return (default, default)
    else:
        return (left, right)'''


'''def xor1_n(n):
    d={0:n,1:1,2:n+1,3:0}
    return d[n&3]'''

def cel(n, k): return n // k + (n % k != 0)
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(map(int, input().split()))
def lcm(a, b): return abs(a * b) // math.gcd(a, b)
def prr(a, sep=' '): print(sep.join(map(str, a)))
def dd(): return defaultdict(int)
def ddl(): return defaultdict(list)
def ddd(): return defaultdict(defaultdict(int))



BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
            while True:
                    b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
                    if not b:
                            break
                    ptr = self.buffer.tell()
                    self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
            self.newlines = 0
            return self.buffer.read()

    def readline(self):
            while self.newlines == 0:
                    b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
                    self.newlines = b.count(b"\n") + (not b)
                    ptr = self.buffer.tell()
                    self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
            self.newlines -= 1
            return self.buffer.readline()

    def flush(self):
            if self.writable:
                    os.write(self._fd, self.buffer.getvalue())
                    self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
            self.buffer = FastIO(file)
            self.flush = self.buffer.flush
            self.writable = self.buffer.writable
            self.write = lambda s: self.buffer.write(s.encode("ascii"))
            self.read = lambda: self.buffer.read().decode("ascii")
            self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

from collections import defaultdict 


from math import gcd,pi















n,m=mi()
a=li()
sm=sum(a)
if n-sm>=0:
    print(n-sm)
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):
import sys
from math import sqrt
from collections import Counter, defaultdict, deque

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)


def I():
    return int(input())


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


def LI():
    return list(MI())


def LIN(n: int):
    return [I() for _ in range(n)]


inf = float("inf")
mod = 10 ** 9 + 7


def main():
    n, m = MI()
    a_list = LI()

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


if __name__ == "__main__":
    main()

Solution (Python):
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) 
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    


MOD = 10**9 + 7
INF = 2**31  

from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  


N, M = read_ints()
A = read_ints()
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()))
A_sum = sum(A)
if N >= A_sum:
    print(N-A_sum)
else:
    print(-1)

Solution (Python):
l = [int(x) for x in input().split(' ')]
line = [int(x) for x in input().split(' ')]
print(max(l[0]-sum(line),-1))