import Control.Applicative
import Data.List (sort,groupBy)

main = do
  _ <- getLine :: IO String
  ls <- map read.words <$> getLine :: IO [Int]
  print $ sum.map (snd.head).groupBy (\a b->fst a`div`2==fst b`div`2) .zip [0..] . sort $ ls
