
import Control.Monad

foo :: [Int] -> Int -> Int
foo [] num = num
foo (n:ns) color = foo (bar n ns) (color+1) where
  bar _ [] = []
  bar x (c:cs) = if c > x then bar x cs else c:bar x cs

main = do
  n <- read <$> getLine :: IO Int
  ints <- replicateM n (read <$> getLine) :: IO [Int]
  print $ foo ints 0
