program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,m
    integer(int32), allocatable:: a(:)

    read*, n,m
    allocate(a(m))
    read*, a(:)

    if (n < sum(a)) then
        print*, -1
    else
        print'(i0)', n - sum(a)
    end if
end program name