
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import qualified Data.Array.IO as A
import Debug.Trace
import Data.List
import Control.Monad
import Data.Ord
import qualified Data.IntSet as S

r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

rp :: IO (Int,Int)
rp  = toTup . unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

toTup [a,b] = (a,b)

main :: IO ()
main = do
    n <- readLn
    as <- replicateM n readLn :: IO [Int]
    let res = solve as (U.singleton (-1))
    print res



solve :: [Int] -> U.Vector Int -> Int
solve  []    set = U.length set
solve (a:as) set = --traceShow (a:as,set) $
    let set' = U.filter (<a) set in
    --traceShow set' $
        if U.null set' || U.null set
            then solve as (U.cons a set)
            else let Just i = U.findIndex (U.maximum set' ==) set
                    in solve as (set U.// [(i, a)])







