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 subList (ret + cnt0)
  where (subList, cnt0) = calc a (tail sumList) ([], 0)

calc :: Integer -> [Integer] -> ([Integer], Integer) -> ([Integer], Integer)
calc a (s:ss) (rs, ret) | s - a == 0 = calc a ss ((s-a):rs, ret + 1)
                        | otherwise = calc a ss ((s-a):rs, ret)
calc _ [] (rs, ret) = (reverse rs, ret)

