def search(arr,x)
  len = arr.length
  if x > arr[-1]
    d = (len-1) / 2
    i = d
    while len > 1
      if arr[i] < x
        i -= d
        len = len - d - ((len-1)%2)
        d = (len-1) / 2
        i += d
      else
        len = len - d - 1
        d = (len-1) / 2
        i += d + 1
      end
    end
    arr[i] = x
  else
    arr.push(x)
  end
  arr
end

n = gets.to_i
a = []
n.times do |i|
  a[i] = gets.to_i
end
arr = [a[0]]
(n-1).times do |i|
  arr = search(arr,a[i+1])
end
puts arr.length