program example
    implicit none

    integer(8) N,M,B
    integer(8),allocatable :: A(:)

    read(*,*) N,M

    allocate(A(M))

    read(*,*) A

    B=N-sum(A)

    if(B>=0) then
        write(*,*) B
    else
        write(*,*) "-1"
    end if

end program example
