N  = gets.to_i
probes = [100000]

N.times{
	a = gets.to_i
	selected = probes.each_with_index.select{|_,i| _ < a }
	if selected.empty?
		probes.push(a)
	else
		probes[selected.max_by{|_,i| _ }.last] = a
	end
}

p probes.length-1
