n = gets.to_i
a = gets.split.map(&:to_i)
k = 1
s = [0]
for i in 1..(n-1)
  if a[i] <= a[i-1]
    len = s.length()
    if len <= a[i]
      (a[i]-len).times {
        s.push(0)
      }
    else
      s = s[0,a[i]]
    end
    s[a[i]-1] = s[a[i]-1] + 1
    if s[a[i]-1] > k-1
      flag = true
      for j in (0..(a[i]-2)).reverse_each
        if s[j] < k-1
          s[j] = s[j] + 1
          s = s[0,j+1]
          flag = false
          break
        end
      end
      if flag 
        k = k + 1
      end
    end
  end
end
p k