local mfl = math.floor
local n = io.read("*n")
local a = {}
for i = 1, n do
  a[i] = io.read("*n")
end

local function solve(x)
  local tasks = {}
  tasks[1] = {a[1], 1}
  local ok = true
  for i = 2, n do
    if a[i - 1] < a[i] then
      table.insert(tasks, {a[i], 1})
    else
      while true do
        if #tasks == 0 then ok = false break end
        local pos, val = tasks[#tasks][1], tasks[#tasks][2]
        table.remove(tasks)
        if pos <= a[i] then
          if val < x then
            table.insert(tasks, {pos, val + 1})
            break
          end
        end
        if 1 < pos then
          if 0 == #tasks or tasks[1][1] ~= pos - 1 then
            table.insert(tasks, {pos - 1, 1})
          end
        end
      end
    end
  end
  return ok
end

local min, max = 0, n
while 1 < max - min do
  local mid = mfl((max + min) / 2)
  if solve(mid) then
    max = mid
  else
    min = mid
  end
end
print(max)
