n = gets.chomp.to_i
a = []
n.times do |i|
  a << gets.chomp.to_i
end
if a.all? {|i| i == 0 } then
  puts a.length
  exit
end
colors = 0
buf = []
a.each_with_index do |i, idx|
  break if idx == ( a.length - 1 )
  if a[idx] > a[idx + 1] then
    buf << a[idx]
    min = buf.min
    if min < a[idx + 1] then
      min_idx = buf.index(min)
      buf[min_idx] = a[idx + 1]
    end
  end
end
puts buf.length 