import qualified Data.IntSet                   as S

import           Control.Monad                  ( replicateM )
import           Data.List                      ( foldl' )


main :: IO ()
main = do
    n <- readLn :: IO Int
    print . fst . foldl' f initState =<< replicateM n inputWord
  where
    initState = (0, [])
    f :: (Integer, [Int]) -> Int -> (Integer, [Int])
    f (c, known) x = case length . filter (== x) $ known of
        0 -> (c, x : known)
        n -> (c + toInteger n, x : known)

    inputWord :: IO Int
    inputWord = foldl' (+) 0 . map fromEnum <$> getLine
