import qualified Data.ByteString.Lazy.Char8 as B
import           Data.Char
import qualified Data.IntMap.Strict         as M
import           Data.List

main :: IO ()
main = do
  getLine
  as <- unfoldr (B.readInt . B.dropWhile isSpace) <$> B.getContents
  print $ solve as

solve :: [Int] -> Int
solve = M.foldl' (+) 0
    . fmap (\x -> x * (x - 1) `div` 2)
    . foldl' (\mp x -> M.insertWith (+) x 1 mp) (M.singleton 0 0)
    . scanl' (+) 0