program brick_break
  implicit none
  integer :: n, a(200000) = 0, i, k = 0
  read(*,*) n
  read(*,*) a(1:n)
  do i = 1, n
    if (a(i) == k+1) then
      k = k+1
    end if
  end do
  if (k == 0) k = n+1
  write(*,'(i0)') n-k
end program brick_break