program abc163b
   implicit none
   integer :: N, M
   integer, allocatable :: A(:)
   integer :: sum_A

   read(*,*) N, M
   allocate(A(M))
   read(*,*) A(:)

   sum_A = sum(A(:))

   if (N >= sum_A) then
      print *, N - sum_A
   else
      print *, -1
   endif

   deallocate(A)

end program abc163b
