import Data.List

go :: (Ord a, Num a) => [a] -> Int
go = sum . map (\g -> length g * (length g - 1) `div` 2) . group . sort . scanl (+) 0

main = do
    getLine
    l <- map read . words <$> getLine :: IO [Integer]
    print $ go l
