import Data.Functor
import Control.Applicative
import Control.Monad
import qualified Data.IntSet as IS
import Data.List
import qualified Data.ByteString.Char8 as C
import Data.Maybe

main = sol <$> (C.getLine *> get) >>= print

get = fmap fst . mapMaybe C.readInt . C.words <$> C.getLine

sol as = IS.size $ foldl' f IS.empty as 
    where
    f s a = case IS.lookupGE a s of
        Just x
            | a < x         -> IS.insert a $ IS.delete x s
            | otherwise     -> s
        Nothing             -> IS.insert a s