n = gets.to_i
as = []
n.times{ as << gets.to_i }

s = []
counta = 0

k = nil
as.reverse.each do |a|
  if s.empty? && !k
    k = a
    counta += 1
    next
  end

  if k > a
    k = a
    next
  else
    f = nil
    while t = s.pop
      if a < t
        k = a
        f = true
        break
      end
    end
    next if f
    s << k
    k = a
    counta += 1
  end
end

p counta
