!!! reference : submission #12221385
program main
    implicit none
    integer n, m, a(10005), t, i
    t = 0
    read(*, *) n, m
    read(*, *) (a(i), i = 1, m)
    do i = 1, m
        t = t + a(i)
    enddo
    if (n >= t) then
        print *, n - t
    else
        print *, -1
    end if
end program main