{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
module Main (main) where
import qualified Data.IntSet as IS
import Control.Monad
main :: IO ()
main = do
  n <- read <$> getLine
  as <- replicateM n $ read <$> getLine
  print $ solve as
{-# INLINE solve #-}
solve :: [Int] -> Int
solve as = IS.size $ foldl f IS.empty as
  where
    f s e = case IS.lookupGE e s of
      Just v | e < v     -> IS.insert v $ IS.delete v s
             | otherwise -> s
      Nothing -> IS.insert e s