program main
    implicit none
    integer n, m
    integer, allocatable, dimension(:) :: a
    integer i, sum
    read(*,*) n, m
    allocate(a(m))
    read(*,*) a

    sum = 0
    do i = 1, m
        sum = sum + a(i)
    end do

    if(sum > n) then
        write(*,*) -1
    else
        write(*,*) n-sum
    end if
    
end program