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



Sample input:
41 2
5 6


Sample output:
30

Submission status: Runtime Error

Solution code:
def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split(' ')))
    homework_day = 0
    for i in range(2):
        homework_day = homework_day + A[i]
    if homework_day > N:
        print(-1)
    else:
        print(N - homework_day)
main()

Submission status: Runtime Error

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

for i in A:
    sum += i

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

Submission status: Runtime Error

Solution code:
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
f = open('input.txt', 'r')
sys.stdin = f

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

Submission status: Runtime Error

Solution code:
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
f = open('input.txt', 'r')
sys.stdin = f

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

Submission status: Runtime Error

Solution code:
#b
n,m=[int(i)for i in input().split()]

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

Submission status: Runtime Error

Solution code:
#b
n,m=[int(i)for i in input().split()]
arr=[]
for i in range(m):
  x=int(input())
  arr.append(x)
s=sum(arr)
if s>n:
  print(-1)
elif s==n:
  print(0)
else:
  print(n-s)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,m = input().split()
add = 0
n = int(n)

m = int(m)

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n_m = input().rstrip()

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

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

finish_day = sum(a_i_list)

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
import numpy as np

def main():
  N,M = (int(x) for x in input().split())
  A = [int(x) for x in input().split(M)]
  
  for i in range(M):
    N = N - A[i]
  
  if N < 0:
    print('-1')
  else:
    print(N)  
  
if __name__ == '__main__':
  main()

Submission status: Runtime Error

Solution code:
print(int(input())*6.283)

Submission status: Runtime Error

Solution code:
N,M = map(int, input().split())
A_list = []
A_list.append(list(input().split()))

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

Submission status: Runtime Error

Solution code:
N,M = map(int, input().split())
A_list = []
A_list.append(list(input().split()))

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

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
A = list(int(input()).split())
tmp = n-sum(A)

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

hw_days = 0

for i in len(A):
  hw_days += A(i)

vacation = n - hw_days

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

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
A = [map(int,input().split())]
print(max(-1,N-sum(A)))

Submission status: Runtime Error

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

list = [map(int,input().split())]

if count(list) > N:
  print(-1)
else:
  print(N-count(list))

Submission status: Runtime Error

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

sum=sum(A)

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

Submission status: Runtime Error

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

sum=sum(A)

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

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
a=0
a+=map(int,input().split())
if(n>a):
  print("{}",n-a)
else:
  print("-1",

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
a = list(map(int, input().split()))
d = n-sum(a)
if(a<0):
  d = -1
pritn(d)

Submission status: Runtime Error

Solution code:
import sys

def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())

n, m = ISI()
l=ILI()
if n-sum8(l)<:print(-1)
else:print(n-sum(l))

Submission status: Runtime Error

Solution code:
import sys
def ISI(): return map(int, sys.stdin.readline().rstrip().split())

n, m = ISI()
l=ILI()
print(n-sum(l))

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
li=[]
ai=map(int,input().split())
li.append(ai)
k=sum(li)
if k<=n:
    print(n-k)
else:
    print("-1")

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
li=[]
for ai in range(m):
    ai=int(input())
    li.append(ai)
k=sum(li)
if k<=n:
    print(m-k)
else:
    print("-1")

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
li=[]
for ai in range(m):
    ai=map(int,input().split())
    li.append(ai)
k=sum(li)
if k<=n:
    print(m-k)
else:
    print("-1")

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
for ai in range(m):
    ai=list(map(int,input().split())
    k=sum(ai)
if k<=n:
    print(m-k)
else:
    print("-1")

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
for ai in range(m):
    ai=list(int(input()))
    k=sum(ai)
if k<=m:
    print(m-k)
else:
    print("-1")

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a,b=map(int,input().split())

c=[i for i in input().split()]

print(a-sum(c) if a>=sum(c) else '-1')

Submission status: Runtime Error

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

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

days = 0

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

remaining = n-days

if remaining < 0:
    print(-1)
else:
    print(remainig)

Submission status: Runtime Error

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

if M < A + B:
  print(-1)
else:
  print(M - A - B)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
D, n = map(int,input().split())
l = list(map(int,input().spliy()))
print(D-sum(l))

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

Solution code:
def actual(n, m, a_list):
    a_sum = sum(a_list)

    if n >= a_sum:
        return n - a_sum

    return -1

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

print(actual(n, m, a_list))

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
lst = list(map(int,input().split()))
plus = 0
for a in range(lst):
    plus += a
if plus <= N:
    print(N-plus)
else:
    print('-1')

Submission status: Runtime Error

Solution code:
N = int(input())
M = int(input())
lst = []
for i in range(M):
    lst.append(int(input()))
plus = 0
for a in lst:
    plus += a
if plus <= N:
    print(N-plus)
else:
    print('-1')

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
for i in range(M):
    i = int(input())
    i += i
O = N - i
print(O)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
for i in range(M)
    i = int(input())
    i+=i
O = N - i
print(O)

Submission status: Runtime Error

Solution code:
N = int(input())
M = int(input())
List = [int(input()) for i in range(M)]

for i in range(M):
    N = N - i
    if N < 0:
        print(-1)
        break
print(N)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]
s_A = sum(A)

if N - s_A >= 0:
    print(N - s_A)
    exit()
if N - s_A < 0:
    print(-1)
    exit()

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]
s_A = sum(A)

if N - s_A>= 0:
    print(N - s_A)
if N -s_A < 0:
    print(-1)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]
s_A = sum(A)

if N >= s_A:
    print(N - s_A)
elif N < s_A:
    print(-1)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]
s_A = sum(A)
if N >= s_A:
    print(N - s_A)
if N < s_A:
    print(-1)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
A = [input() for _ in range(M)]
s_A = sum(A)
if N >= s_A:
    print(N-s_A)
if N < s_A:
    print(-1)

Submission status: Runtime Error

Solution code:
N,M = map(int, input().split())
A = [0] * M
for i in M:
  A[i] = int(input())
  N -= A[i]

if N < 0:
  N = -1

print(N)

Submission status: Runtime Error

Solution code:
def resolve():
    a,b = map(int, input().split())
    A = list(map(int, input().split()))
    count = 0

    for c in range(b):
        count += A[c]
    
    print(a - count)
    
 resolve()

Submission status: Runtime Error

Solution code:
x, y = [int(x) for x in input().split()]

for tareas in range(y):

    c = int(input())

    x-=c
print(x)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
a=[]
for i in range(0,m):
    num=int(input())
    a.append(num)
    n-=a[i]
if n<=0:
    print(-1)
else:
    print(n)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
A = list(map(int,input()))
counter = 0

for i in range(M):
    counter += A[i]
    
print(N-counter)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
for num	in input().split():
  n-=num
print(n if n>=0 else -1)

Submission status: Runtime Error

Solution code:
import numpy as np

from sys import stdin


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

    ans = n - np.sum(a)

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


if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N, M = int(input().split())
A = input.split()
total = 0
for i in range(A):
    total = total+A[i]

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

Submission status: Runtime Error

Solution code:
N = int(input())
M = int(input())
total = 0
 
for i in range(M):
    A = int(input())
    total = total+A
 
if total <= N:
    print (N - total)
else:
    print ("-1")

Submission status: Runtime Error

Solution code:
N = int(input())
M = int(input())
total = 0

for i in range(M):
    A = int(input())
    total = total+A

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

Submission status: Runtime Error

Solution code:
N = int(input())
M = int(input())
total = 0

for i in range(M):
  	A = int(input())
    total = total + A
    
if total <= N:
    print (N - total)
else:
  	print "-1"

Submission status: Runtime Error

Solution code:
N, M = tuple(int(c) for c in input().split(' '))
A = tuple(int(c) for c in input().split(' '))
if len(sum(A)) > N:
  print(-1)
else:
  print(len(sum(A)) > N)

Submission status: Runtime Error

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


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

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
a_ = list(map(int,input().split()))

sum = sum(s_)
res = n - sum

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

Submission status: Runtime Error

Solution code:
NM = list(map(int, input().split()))
N, M = NM[0],NM[1]
a = list(map(int, input().split()))

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

Submission status: Runtime Error

Solution code:
NM = list(map(int, input().split())
N, M = NM[0],NM[1]
a = list(map(int, input().split()))
x = 0
for i in range(M):
    x += a[i]

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,m=(int(x) for x in input().split())
a,A = (int(x) for x in input().split())
ans = max(n - (a+A), -1)
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

count = 0

for i in range(m):
  count += int(input())
  
asobi = n - count

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

Submission status: Runtime Error

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

count = 0

for i in range(m):
  count += int(input())
  
asobi = n - count

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

Submission status: Runtime Error

Solution code:
from math import floor

X, val, a = eval(input()), 100, 1

while True :
    val += floor(val * 0.01)
    if val >= X:
        break
    a += 1
print(a)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N M = map(int,input().split())
List = [map(int,input().split())]
print(N-sum(List) if N-sum(List) >= 0 else -1)

Submission status: Runtime Error

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

A = 0
for i in range(M):
    s = int(input())
    A += s

sub = N - A

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

Submission status: Runtime Error

Solution code:
m, n = map( int, input().split() )
a = 0
for i in range(m)
	a += int(input())

n=n-a
if a<=-2:
  a=-1

print(a)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
/*
 ~ author - Sayan Bose
 ~ Do Good Die Great
*/
#include<bits/stdc++.h>
#define ll long long
#define amaterasu ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
using namespace std;

void solve()
{
	int n, m;
	cin >> n >> m;
	int work = 0;
	while(m--)
	{
		int t;
		cin >> t;
		work += t;
	}
	if(work > n)
		cout << -1 << '\n';
	else
		cout << n-work << '\n';
}

int main()
{
	amaterasu
	solve();
	return 0;
}

Submission status: Runtime Error

Solution code:
S=input().split()
N=S[0]
N=int(N)
del S[0]
M=S[0]
M=int(M)
del S[0]
s=0
for i in range(M):
    s=s+int(S[i])
if s>N:
    print(-1)
else:
    print(N-s)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
li = input().split()
b = 0
for a in li:
    b = b + a
if n >= b:
    print(n-b)
else:
    print("-1")

Submission status: Runtime Error

Solution code:
N,M  = map(int, input().split())
A_list = list(map(int, input.split()))

avail = N - sum(A_list)

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

Submission status: Runtime Error

Solution code:
a,b=map(int,input().split())
c,d=map(int,input().split())
play_day=a-(c+d)
if play_day>=0:
    print(play_day)
else:
    print("-1")

Submission status: Runtime Error

Solution code:
a,b=input().split()
c,d=input().split()
a=int(a)
b=int(b)
c=int(c)
d=int(d)
play_day=a-(b+c)
if play_day>=0:
    print(play_day)
else:
    print(-1)

Submission status: Runtime Error

Solution code:
a,b=map(int,input().split())
c,d=map(int,input().split())
play_day=a-(c+d)
if play_day>=0:
    print(play_day)
else:
    print(-1)

Submission status: Runtime Error

Solution code:
a,b=map(int,input().split())
c,d=map(int,input().split())
play_day=a-(c+d)
if play_day>0:
    print(play_day)
else:
    print("-1")

Submission status: Runtime Error

Solution code:
a,b=map(int,input().split())
c,d=map(int,input().split())
play_day=a-(c+d)
if play_day>0:
    print(play_day)
else:
    print(-1)

Submission status: Runtime Error

Solution code:
a,b=map(int,input().split())
c,d=map(int,input().split())
print(a-(c+d))

Submission status: Runtime Error

Solution code:
([int(r) for r in input().split(" ")])-sum([int(r) for r in input().split(" ")])

Submission status: Runtime Error

Solution code:
N=int(input())
M=int(input())
A=list(range(M+1))
play_day=N-sum(A)
if play_day>0:
    print(play_day)
else:
    print(-1)

Submission status: Runtime Error

Solution code:
N, M = [map(int, input(.split()))]

works = [map(int, input().split())]

ans = N

for i in range(M):
    ans -= works[i]

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

Submission status: Runtime Error

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

homework = sum(a)

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

else:
    print(N - homework)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
a = [int(input()) for i in range(M)]

homework = sum(a)

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

else:
    print(N - homework)

Submission status: Runtime Error

Solution code:
N=int(input())
M=int(input())
A=list(range(M+1))
play_day=N-sum(A)
if play_day>0:
    print(play_day)
else:
    print("-1")

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

hwdsum=0
k=0
while k<= m-1:
  sum += a[k]
  
if n-sum>=0:
  print(str(sum))
  
else:
  print(-1)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
a_data = input()
a = a_data.split(' ')

sum = 0
# sum = sum(a)
for item as a:
  sum += int(item)

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

Submission status: Runtime Error

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

A=[int(input())for i in range(M)]

print(N-sum(A))

Submission status: Runtime Error

Solution code:
NM = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

N = NM[0]
M = NM[1]

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

Submission status: Runtime Error

Solution code:
NM = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

N = NM[0]
M = NM[1]

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

Submission status: Runtime Error

Solution code:
NM = [int(i) for i in input().split(" ")]
A = [int(i) for i in input().split(" ")]

N = NM[0]
M = NM[1]

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

Submission status: Runtime Error

Solution code:
NM = [int(i) for i in input().split()]
A = [int(i) fot i in input().split()]

N = NM[0]
M = NM[1]

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

Submission status: Runtime Error

Solution code:
NM = [int(i) for i in input().split(" ")]
A = [int(i) fot i in input().split(" ")]

N = NM[0]
M = NM[1]

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

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
a_data = input()
a = a_data.split(' ')

sum = sum(a)

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy as np
N,M = map(int,input().split())
A = np.array(list(map(int,input().split())))
output = N - np.sum(A)
if output >= 0:
    print(output)
else:
    print(-1)

Submission status: Runtime Error

Solution code:
n, m = list(map(int, input().split())
print(max(n - sum(list(map(int, input().split()))), 0))

Submission status: Runtime Error

Solution code:
n, m = list(map(int, input().split())
print(max(n - sum(list(map(int, input().split()), 0))

Submission status: Runtime Error

Solution code:
n = int(input())
m = int(input())

for i in range(m):
    x = int(input())
    n = n - x

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

Submission status: Runtime Error

Solution code:
if __name__ == '__main__':
    x=list(map(int,input().split(" ")))
    y = list(map(int, input().split(" ")))
    num=0
    for i in y:
        num+=i
    if x[0]<y:
        print(-1)
    else: print(x[0]-y)

Submission status: Runtime Error

Solution code:
if __name__ == "__main__":
    n=input()
    m=input()
    n=int(n)
    m=int(m)
    for i in range(m):
        j=input()
        n-=int(j)

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

Submission status: Runtime Error

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

homework = A.sum()
print(n - m if n - m >= 0 else -1)

Submission status: Runtime Error

Solution code:
a=map(int,input().split(" "))
Ai=map(int,input().split(" "))
n=a[0]
days=0
for i in range(a[1]):
    days+=Ai[i]
if days>n:
    print(-1)
else:
    print(n-days)

Submission status: Runtime Error

Solution code:
a=map(int,input().split(" "))
Ai=map(int,input().split(" "))
n=a[0]
days=0
for A in Ai:
    days+=A
if days>n:
    print(-1)
else:
    print(n-days)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,m = input().split();
a = input().split();

a_sum = sum(a);

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

Submission status: Runtime Error

Solution code:
n,m = input().split();
a = input().split();

a_sum = sum(a);

rest_day = int(n) - a_sum

if rest_day < 0:
    rest_day = -1

return rest_day

Submission status: Runtime Error

Solution code:

n,m = input().split();
a = input().splite();

a_sum = sum(a);

rest_day = int(n) - a_sum

if rest_day < 0:
    rest_day = -1

return rest_day

Submission status: Runtime Error

Solution code:

n,m = input().split();
a = input().splite();

a_sum = sum(a);

rest_day = n - a_sum

if rest_day > 0:
    return rest_day
else: return -1

Submission status: Runtime Error

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

total = 0
for i in range(M):
  total += A[i]
  
if N - total >= 0:
  print(N - total)
  
else:
  print("-1")

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

c_sum = 0
for i in range(M):
  b = int(input())
  c_sum += b

day_count = N-c_sum

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

Submission status: Runtime Error

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

a = 0
for i in range(M):
  c_sum = int(input())
  a += b

day_count = N-c_sum

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

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
 
a = 0
for i in range(M):
  b = int(input())
  a += b

day_count = N-a

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

Submission status: Runtime Error

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

a = 0
for i in range(M):
  b = int(input())
  a += b

day = N-a
print(day)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
a=[b for b in int(input().split())]
def func(n,a):
    if n< sum(a):return "-1"
    else: 
        return n-sum(a)
print(func(n,a))

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
a=[int(b) for b in input()]
def func(n,a):
    if n< sum(a):return "-1"
    else: 
        return n-sum(a)
print(func(n,a))

Submission status: Runtime Error

Solution code:
n,m = map(int,input())
a = [int(x) for x in input().split()]
s = sum(a)
if n < s:
  print("-1")
else:
  print(n-s)

Submission status: Runtime Error

Solution code:
n,m = map(int, input().strip().split(" "))

homework = list(n,m)

day = n - sum(homework)

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

Submission status: Runtime Error

Solution code:
n,m = map(int, input().strip().sprit(' '))

homework = list(map(int, input().strip().sprit(' ')))

day = n - sum(homework)

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

Submission status: Runtime Error

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

ans = n
for i range(len(a)):
    ans -= a(i)
    
    if ans < 0:
        print(-1)
    else:
        print(ans)