program main
  implicit none
  integer i,N,turn,top
  integer,allocatable :: A(:)
  !read(*, *) (L(i), i = 1,N)
  read(*, *) N
  allocate(A(N))
  do i = 1,N
    read(*, *) A(i)
  end do

  turn = 0
  do
    top = -1
    !turn = trun + 1
    do i = 1,N
      if (top < A(i)) then
        top = A(i)
        A(i) = -2
      end if
    end do
    if (top == -1) then
      exit
    else
      turn = turn + 1
    end if
  end do
  write(*, *) turn
end program main
