import Control.Monad
import Text.Printf
import Control.Applicative
import Data.List as L

main :: IO()
main = do
  _ <- getLine
  a <- map read . words <$> getLine
  printf "%d" $ slv a

slv :: [Integer] -> Integer
slv a = slvCore a subList $ fromIntegral(length (elemIndices 0 subList))
  where subList = scanl1 (+) a

slvCore :: [Integer] -> [Integer] -> Integer -> Integer
slvCore _ [] ret = ret 
slvCore (a:as) sumList ret = slvCore as subSumList (ret + fromIntegral(length (elemIndices 0 subSumList)))
  where subSumList = map (\x -> x - a) (tail sumList)
