import Control.Applicative
import Data.List
import Data.Ratio

main = do
  n <- readLn :: IO Int
  as <- scanl (+) 0 . map read . words <$> getLine :: IO [Int]

  print $ sum . map (((flip combination) 2) . length) . group . sort $ as

{-- nCk --}
combination :: Integral a => a -> a -> a
combination n k = numerator $ combination' n k
  where
    combination' :: Integral a => a -> a -> Ratio a
    combination' n k
      | n < k || n < 0 || k < 0 = 0
      | n == 0 || k == 0 = 1
      | otherwise = (n % k) * combination' (n-1) (k-1)
