_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 << [n-1,b] << [1,b+1]
    end
    max = b+1 if max < b+1
  elsif len >= n
    i,t = [0,n]
    loop do
      t -= curr[i][0]
      break if t <= 0
      i += 1
    end
    a,b = curr[i]
    curr = i == 0 ? [] : curr[0..i-1]

    if a == 1
      curr << [1,b+1]
    elsif n == 1
      curr << [1,b+1]
    else
      curr << [n-1,b] << [1,b+1]
    end
    max = b+1 if max < b+1
  else # len < n
    curr << [n-len,1]
  end
  len = n
end

p max