import qualified Data.IntMap as M
import qualified Data.ByteString.Lazy.Char8 as B
import Data.List
import Debug.Trace
import Test.QuickCheck

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 =
  length [1|ys <- tails xs, not (null ys), y <-scanl1 (+) ys, y==0]