DBG = !true
n = gets.to_i
a = gets.split.map{|x| x.to_i}
if DBG
  print a
  puts ""
end
c = 1
x = Array.new(a[0], 0)
for i in 1...a.size
  if DBG
    printf("i:%d ", i)
    print x
    puts ""
  end
  if a[i] > a[i-1]
    #x.concat(Array.new(a[i] - a[i-1], 0))
    (a[i]-a[i-1]).times do
      x << 0
    end
    next
  end
  # now a[i] <= a[i-1]
  ok = false
  (a[i]-1).downto(0) {|j|
    if x[j] < c-1
      x[j] += 1
      x.slice!(j+1, x.size-j)
      ok = true
      break
    end
  }
  printf("ok: %d\n", ok ? 1 : 0) if DBG
  if !ok
    #x = Array.new(a[i], c-1)
    x.slice!(a[i], x.size-a[i])
    x[a[i]-1] = c
    c += 1
  end

end
print c
