import           Control.Monad
import           Data.List
main = do
    n <- readLn :: IO Int
    a <- replicateM n readLn :: IO [Int]
    print . length $ solve [] a

solve :: [Int] -> [Int] -> [Int]
solve [] (x:xs) = solve [x] xs
solve zs [] = zs
solve zs (x:xs) =
    case find (\z -> z < x) zs of
        Just i  -> let nzs = changeList i x xs
                    in solve nzs xs
        Nothing -> solve (x:zs) xs

changeList i v =
 map (\(j,x) -> if i == j then v else x) . zip [0..]
