n = gets.to_i
as = gets.split.map(&:to_i)

n = as.first
len = n
curr = [[n,1]]
max = 1

as[1..-1].each do |n|
  if len == n
    a,b = curr.pop
    if a == 1
      curr << [1,b+1]
    else
      curr << [a-1,b] << [1,b+1]
    end
    max = b+1 if max < b+1
  elsif len > n
    i = 0
    t = n
    loop do
      t -= curr[i][0]
      break if t <= 0
      i += 1
    end
    a,b = curr[i]
    if i == 0
      curr = []
    else
      curr = curr[0..i-1]
    end
    if a == 1 || n == 1
      curr << [1,b+1]
    else
      curr << [n-1,b] << [1,b+1]
    end
    max = b+1 if max < b+1
    len = n
  else # len < n
    curr << [n-len,1]
    len = n
  end
end

p max