program main
    implicit none
    integer(8) N, M, i, sum
    integer(8), allocatable :: A(:)
    read *, N, M
    sum = 0
    allocate(A(M))
    read *, A
    do i = 1, M
        sum = sum + A(i)
    end do
    if (sum > N) then
        print *, -1
    else
        print '(I0)', N - sum
    end if
    deallocate(A)
    stop
contains

end program main