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 = slv' a 0
  where slv' a@(aa:aas) ret = slv' aas (ret + sum [if x == 0 then 1 else 0 | x <- scanl1 (+) a, x == 0])
        slv' [] ret = ret