import Data.List

main = do
  n <- read <$> getLine :: IO Int
  as <- map read . words <$> getLine :: IO [Int]
  print $ solve as 0

solve [] c = c
solve as c =
  solve (tail as) $c+ans 
  where
    cumsum = scanl' (+) 0 as
    ans = (length $ filter (==0) cumsum) -1
    

