N = gets.to_i
A = gets.split.map(&:to_i)

K = [*1..A.max]

ok = A.max
ng = 0

def f(k)
  mp = Hash.new(1)

  x = A[0]

  A[1..-1].each do |y|
    next if x < y

    t = y

    while mp[t] == k && t > 0
      mp[t] = 1
      t -= 1
    end

    if t == 0
      return false
    else
      mp[t] += 1
    end

    mp.delete_if { |key| key > y }

    x = y
  end

  true
end

while (ok - ng).abs > 1
  mid = (ok + ng) / 2

  if f(mid)
    ok = mid
  else
    ng = mid
  end
end

puts ok
