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

if (N-1).times.all?{|i| A[i] < A[i+1]}
    puts 1
    exit
end

def check(k)
    st = [[-1, -1]]
    (N-1).times do |i|
        if A[i] >= A[i+1]
            st.pop while st[-1][0] > A[i+1]
            if st[-1][0] == A[i+1]
                st[-1][1] += 1
                while st[-1][1] == k
                    d = st[-1][0]
                    return false if d == 1
                    st.pop
                    if st[-1][0] == d-1
                        st[-1][1] += 1
                    else
                        st.push([d-1, 1])
                    end
                end
            else
                st.push([A[i+1], 1])
            end
        end
    end
    true
end

puts (2..N).bsearch{|k| check(k)}