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@(_:aas) ret = slv' aas (ret + calc a 0 0)
        slv' [] ret = ret

calc :: [Integer] -> Integer -> Integer -> Integer
calc (a:as) sumVal ret | sumVal+a == 0 = calc as (sumVal+a) (ret+1)
                       | otherwise = calc as (sumVal+a) ret
calc [] _ ret = ret
