import Control.Monad
import Text.Printf
import Control.Applicative
import Data.List as L

main :: IO()
main = do
  _ <- getLine
  a <- map read . words <$> getLine
  printf "%d" $ sum.map (\x -> length x * (length x - 1) `div` 2) $ group.sort $ scanl (+) 0 a
