program main
  implicit none
  integer :: n, prev, i
  integer, allocatable :: a(:)
  read (*, *) n
  allocate (a(n))
  read (*, *) a(:)
  prev = 0
  do i = 1, n
    if (a(i) == prev + 1) prev = prev + 1
  end do
  if (prev == 0) then
    write (*, "(i0)") -1
  else
    write (*, "(i0)") n - prev
  end if
end program main
