import qualified Data.Map as M

f2::Maybe Int->Int
f2 (Just x)=x
f2 Nothing =0

f :: M.Map Int Int->Int->[Int]->[Int]
f _ _ []=[]
f ms1 sum1 (x:xs)=let sum2=sum1+x
                      ms2=M.insertWith (+) sum2 1 ms1
                  in (f2 (M.lookup (sum2) ms1)) : f ms2 sum2 xs

main = do
       n<-getLine
       e<-getLine
       let xs=map read (words e)::[Int]
           ms1=M.empty
           ms2=M.insert 0 1 ms1
       putStrLn $ show $ sum $ f ms2 0 xs