N  = gets.to_i
probes = [1000000000]

N.times{
	a = gets.to_i
	if a <= probes.first
		probes.unshift(a)
	else
		(probes.length-1).downto(0){|i|
			if probes[i] < a
				probes[i] = a
				break
			end
		}
	end
}

p probes.length-1
