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):
import sys
import os
import math
import string

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7


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

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

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

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

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

Solution (Python):






import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache






MOD = 10**9+7
INF = float('inf')






def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]


def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


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(a, b):
    return a * b // gcd (a, b)





N,M = inputIL()
A = inputIL()

sumA = sum(A)

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

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

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

Solution (Python):
n, k = [int(s) for s in input().split()]
arr = [int(s) for s in input().split()]
sum = 0
for i in arr:
    sum+=i 
if n-sum<0:
    print(-1)
else:
    print(n-sum)

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

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

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

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

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

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

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

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):
import numpy as np
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
N, M = map(int, input().split())
A = np.array(list(map(int, input().split())))

tot = np.sum(A)
if N < tot:
	print(-1)
else:
	print(N-tot)

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

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

















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

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):
import math  
import bisect  
import queue  


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

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

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

if __name__ == '__main__':
    main()

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

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

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

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

T = sum(List)

if T > N:
  print(-1)
else:
  print(int(N-T))

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

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

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

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

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

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 = list(map(int, input().split()))
A = list(map(int, input().split()))
ans = N
for i in range(M):
    ans -= A[i]
print(max(-1, ans))

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

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

play_days = n - cost_days
if play_days < 0:
    print(-1)
else:
    print(play_days)

Solution (Python):

import sys


def solve(N: int, M: int, A: "List[int]"):
    S = sum(A)
    if S > N:
        print(-1)
    else:
        print(N-S)
    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
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def solve():
    N, M = Scanner.map_int()
    A = sum(Scanner.map_int())
    print(max(-1, N - A))


def main():
    
    solve()


if __name__ == "__main__":
    main()

Solution (Python):

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

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

ans = N - sum(A)

if ans < 0:
    print (-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):
if __name__ == '__main__':
    N, M = [int(x) for x in input().split()]
    arr = [int(x) for x in input().split()]
    res = N - sum(arr)
    if res < 0:
        print(-1)
    else:
        print(res)

Solution (Python):
import sys


def input():
    return sys.stdin.readline().strip()


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


if __name__ == "__main__":
    main()

Solution (Python):
from collections import deque, Counter, defaultdict
from itertools import chain, combinations
import json

import bisect
import sys
import math
import bisect
from functools import lru_cache

sys.setrecursionlimit(10 ** 8)

M = 10 ** 9 + 7
INF = 10 ** 17


def main():
    
    N,M = [int(a) for a in input().split()]
    A = [int(a) for a in input().split()]
    t = sum(A)
    print(N-t if N-t>=0 else -1)

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    


if __name__ == "__main__":
    main()

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

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

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

Solution (Python):
import math

n, m = 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()))
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(N-sum(A) if N>=sum(A) else -1)

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

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
from pprint import pprint
from copy import deepcopy
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from pprint import pprint


sys.setrecursionlimit(2147483647)
INF = 10 ** 15
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007

n, m = LI()
ret = sum(LI())
if ret > n:
    print(-1)
else:
    print(n - ret)

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

import sys


def solve(N: int, M: int, A: "List[int]"):
    return max(-1, N - sum(A))



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)]  
    print(solve(N, M, A))

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 = [int(x) for x in 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()))
print(max(N-sum(A), -1))

Solution (Python):

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

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

Solution (Python):
N,M = list(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())

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

total = sum(homework)

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

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

do_days = sum(As)

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

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



if __name__ == '__main__':
    solve()

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

Solution (Python):


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

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

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

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

sum_a=sum(a)

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

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

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

Solution (Python):
import sys, math
def input(): return sys.stdin.readline().strip()

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

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

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:
    ans = -1
print(ans)

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:
    print(ans)
    exit()
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=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,*A = map(int,open(0).read().split())

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

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

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

Solution (Python):
import sys
import itertools
if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
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()))
As = list(map(int,(input().split())))

days = sum(As)
free_days = N - days


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

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

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

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

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

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

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

Solution (Python):

from decimal import *
from itertools import permutations, combinations,combinations_with_replacement,product
import math
s = input().split()
p = [int(w) for w in s] 
t = input().split()
q = [int(w) for w in t] 

ans = p[0] - sum(q)
if(ans < 0):
    ans = -1
print(ans)

Solution (Python):
def Int():
    return int(input())
def Ints():
    return map(int,input().split())
def IntList():
    return list(Ints())
def IntMat(N):
    return [IntList() for i in range(N)]

N,M = Ints()
A = IntList()

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

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

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

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) else -1)

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

Solution (Python):
import sys

stdin = sys.stdin

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

n,m = nm()
a = sum(nm())
print(-1 if a > n else n-a)

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 = [int(x) for x 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()))

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

Solution (Python):
import sys
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

import math

N, M = rl()
A = rl()

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

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

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

ans = sum(a)

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

Solution (Python):
import sys


sys.setrecursionlimit(10 ** 9)




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

days = sum(A)

ans = N - days if N - days >= 0 else -1

print(ans)

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

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

asum=sum(a)

if(asum>n):
    print("-1")
else:
    print(n-asum)

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

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

if __name__ == '__main__':
	main()

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

Solution (Python):
INF = 10 ** 9
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from  collections import deque

def main():
    n,m = map(int,input().split())
    a  = list(map(int,input().split()))
    x  =sum(a)
    if x > n:
        print(-1)
    else:
        print(n - x)
if __name__ == '__main__':
    main()

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

rest = N - sum(days)
print(max(rest, -1))

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):
import heapq
from collections import defaultdict, deque
from math import ceil, factorial, gcd
from itertools import accumulate
import sys
import bisect
import numpy as np

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

si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
lmii = lambda: list(map(int, input().split()))
smii = lambda: sorted(map(int, input().split()))



N, M = mii()
A = lmii()

total = sum(A)

enjoy = N - total

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

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

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

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

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

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

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)
residue = n - total

if residue < 0:
    residue = -1
print(residue)

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

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

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

Solution (Python):



def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    

    def dump(*args):
        sys.stderr.write(str(args))

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


if __name__ == '__main__':
    main()

Solution (Python):
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import permutations,combinations
from collections import defaultdict,Counter


from functools import reduce
from pprint import pprint

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

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col):
    data.sort(key=lambda x:x[col],reverse=False)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

n,m = myinput()
a = list(myinput())

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()))
suma = 0
for a in A:
    suma += a
if suma <= N:
    print(N - suma)
else:
    print("-1")

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

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(n-sum(a) if n-sum(a)>=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):
import sys
input = sys.stdin.readline

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

import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

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

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

Solution (Python):


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

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

if __name__ == '__main__':
    main()