N=gets.to_i
as =[]
for i in 0...N
  as << gets.to_i
end
as.reverse!
color_min=[as[0]]
for i in 1...N
  s=color_min.size
  if as[i]<color_min[0]
    judge=0
  elsif s == 1
    judge=nil
  else
    judge=(1..s-1).bsearch{|j|color_min[j-1]<=as[i] && as[i]<color_min[j]}
  end
  if judge
    color_min[judge]=as[i]
  else
    color_min << as[i]
  end
end
puts color_min.size
