import Data.List

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

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

zeroSumRanges as n = foldl' (+) 0 . map (flip combinatorial 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 n