n=gets.to_i
a=gets.split.map &:to_i

h=Hash.new(1)
q=[]
(1...a.size).each{|i|
  q<<a[i] if a[i-1]>=a[i]
}

m=1
q.each{|x|
  if h[x]+1 <= m
    h[x]+=1
  else
    x.downto(1).any?{|y|
      h[y]<m && h[y]+=1
    } || (
      h[x]+=1
      m+=1
    )
  end
  h.delete_if{|k,v|k>x}
}

p m