{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
module Main (main) where
import Control.Applicative
import Control.Monad
import qualified Data.ByteString as BS
import Data.ByteString.Char8 (readInt)
import qualified Data.IntSet as IS
import Data.Maybe (fromJust)
import qualified Data.Vector.Unboxed as VU



main :: IO ()
main = do
  n <- readLn
  as <- VU.replicateM n $ fst . fromJust . readInt <$> BS.getLine
  --as <- replicateM n $ read <$> getLine
  print $ solve as
{-# INLINE solve #-}
solve :: VU.Vector Int -> Int
solve as = IS.size $ VU.foldl' f IS.empty as
  where
    f s e = case IS.lookupGE e s of
      Just ix | e < ix     -> IS.insert e $ IS.delete ix s
              | otherwise -> s
      Nothing -> IS.insert e s