import qualified Data.ByteString.Char8 as C
import Data.Maybe ( fromJust )
import Data.List

cReadLn :: IO Int
cReadLn = fst . fromJust . C.readInt <$> C.getLine

getParms :: IO [Int]
getParms = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

main :: IO ()
main = do
  n  <- cReadLn
  as <- getParms
  print $ count as 

f :: [Int] -> [[Int]]
f as = group . sort . map length . group . zipWith (<) as . tail $ as

count :: [Int] -> Int
count as = h is
  where
    is = f as
   
    h jj@(j:js) 
      | head j == 1 = ((length j) `div` 2) + 1 + sum (map length js)
      | otherwise   = sum $ map length jj
