import Control.Applicative
import Control.Monad
import Data.List

comb :: Int -> Int -> Int
comb n r = iterate (scanl1 (+)) [1, 1 ..] !! (n - r) !! r

main :: IO ()
main = do
    n <- readLn :: IO Int
    as <- fmap read . words <$> getLine :: IO [Int]
    let bs = scanl' (+) 0 as
    let cs = filter (>= 2) . fmap length . group . sort $ bs
    print $ foldr (\x a -> comb x 2 + a) 0 cs