
import Control.Monad
import Debug.Trace

greedy :: [Int] -> [Int] -> Int
greedy [] memo = length memo
greedy (x:xs) memo = greedy xs (bar x memo) where
  bar x [] = [x]
  bar x (y:ys) = if y < x then x:ys else y:bar x ys

main = do
  n <- read <$> getLine :: IO Int
  ints <- replicateM n (read <$> getLine) :: IO [Int]
  print $ greedy ints []
