import Control.Applicative
import qualified Data.Map as Map
import qualified Data.IntMap as IMap

solve :: [Int] -> Int
solve = f5 . f4 . f3 . f2

f5 :: [Int] -> Int
f5 = sum . map comb
    where comb n = div (n*(n-1)) 2

f4 :: IMap.IntMap Int -> [Int]
f4 = map snd . IMap.toList

f3 :: [Int] -> IMap.IntMap Int
f3 = foldl app IMap.empty 
app mp v | IMap.member v mp = IMap.update (\x->Just (x+1)) v mp
         | otherwise = IMap.insert v 1 mp
    

f2 :: [Int] -> [Int]
f2 = foldl f1 [0]

f1 :: [Int] -> Int -> [Int]
f1 [] a = [a]
f1 all@(x:xs) a = (a+x):all

main = do
    getLine
    list <- map read . words <$> getLine :: IO [Int]
    print $ solve list