import Control.Applicative
import Data.List

ts :: [a] -> [[a]]
ts [a] = [[a]]
ts all@(x:xs) = all : ts xs

is :: [a] -> [[a]]
is [a] = [[a]]
is all@(x:xs) = scanl (flip (:)) [head all] (tail all)


f xs = foldl go (0,0) xs
  where
    go (count, acc) n = if acc + n == 0 then (count+1, acc+n) else (count, acc+n)

main = do
 _ <- getLine
 as <- (map read . words) <$> getLine
 print . sum . map (fst.f) $ is as