import Control.Monad
import Data.List
import qualified Data.ByteString.Lazy.Char8 as B

main = do
  _ <- getLine
  input <- B.getContents
  let as = map readInt . B.words $ input
  print (solve as)

readInt :: B.ByteString -> Int
readInt s = case B.readInt s of Just (n,_) -> n

solve :: [Int] -> Int
solve xs =
  sum [c |(c,_)<-ans]
  where
    ans = scanl f (0,(0,0)) xs
    f (c,(n,s)) v = let s' = s+v
                        n' = n+1
                        c' = length [1|(_,(_,t))<-take n' ans, s'-t==0]
                    in (c',(n',s'))