import Data.List

factorial n
    | n == 0    = 1
    | otherwise = foldl' (*) 1 [1..n]

combination n m
    | m < 0 = 0
    | n >= m = factorial n `div` (factorial m * factorial (n-m))
    | otherwise = 0

zeroSumRanges as = foldl' (+) 0 . map (\n -> combination n 2) . map length . group . sort $ sums
    where
        sums = scanl' (+) 0 $ as


main = do
    n <- read <$> getLine :: IO Int
    as <- map read . words <$> getLine
    putStrLn . show $ zeroSumRanges as