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 :: Int -> [[Int]] -> Int
f acc []    = acc
f acc (xs:xss) = f (acc + length [()|x <- is xs, sum x == 0]) xss

main = do
 _ <- getLine
 as <- (map read . words) <$> getLine
 print $ f 0 (ts as)