import Data.List
import Debug.Trace

main = do
  n <- read <$> getLine :: IO Int
  as <- map read . words <$> getLine :: IO [Int]
  let as' = scanl' (+) 0 as
--  traceShowM (0:as)
--  traceShowM (as')
  print $ solve (as) (tail as') 0

solve :: [Int] -> [Int] -> Int -> Int
solve [] [] c = c
solve [a] [a'] c =
  if a==0 then solve [] [] $c+1
  else solve [] [] c
solve (a:as) (a':as') c =
--  traceShow ans $
  solve as as' $ c+ans 
  where
    ans = length $ filter (==(a'-a)) as'

    
