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

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

sum_a = 0

for i in a:

    sum_a += i

if sum_a > N:

    print((-1))

else:

    print((N - sum_a))
def to_do():

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

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

    sum=0

    for i in range(0,M):

        sum=sum+day_list[i]

    if sum>N:

        print((-1))

    if sum<=N:

        print((N-sum))

if  __name__=="__main__":

    to_do()
N, M = list(map(int, input().split(" ")))
a = list(map(int, input().split(" ")))
sum_a = 0
for i in a:
    sum_a += i
if sum_a > N:
    print((-1))
else:
    print((N - sum_a))

def to_do():
    N, M = list(map(int, input().split()))
    day_list = list(map(int, input().split()))
    sum = 0
    for i in range(0, M):
        sum = sum + day_list[i]
    if sum > N:
        print((-1))
    if sum <= N:
        print((N - sum))


if __name__ == "__main__":
    to_do()

-N, M = list(map(int, input().split(" "))) -a = list(map(int, input().split(" "))) -sum_a = 0 -for i in a: -    sum_a += i -if sum_a > N: -    print((-1)) -else: -    print((N - sum_a)) +def to_do(): +    N, M = list(map(int, input().split())) +    day_list = list(map(int, input().split())) +    sum = 0 +    for i in range(0, M): +        sum = sum + day_list[i] +    if sum > N: +        print((-1)) +    if sum <= N: +        print((N - sum)) + + +if __name__ == "__main__": +    to_do()