N = gets.to_i
H_LIST = gets.split(' ').take(N).map(&:to_i)

# [[i, size], ...]
def mk_candidate_list(list)
  candidate_list = []
  i = 0
  while i < list.size
    l = list[i..-1].map.with_index { |h, i| [h, i] }.take_while do |h, j|
      h < H_LIST[i + j]
    end
    if l.size > 0
      candidate = [i, l.size]
      candidate_list.push(candidate)
    end
    i += l.size + 1
  end
  candidate_list
end

answer = 0
list = Array.new(N, 0)
candidate_list = mk_candidate_list(list)
while candidate_list.size > 0
  i, size = candidate_list.max_by { |i, size| size }
  list =
    list[0...i] + list[i, size].map(&:next) + list[(i + size)..-1]
  candidate_list = mk_candidate_list(list)
  answer += 1
end
puts answer
