import qualified Data.ByteString.Char8 as B
import           Data.Char
import           Data.List

main :: IO ()
main = do
  B.getLine
  as <- unfoldr (B.readInt . B.dropWhile isSpace) <$> B.getLine
  print $ solve as

solve :: [Int] -> Int
solve = length . concat . map (filter (== 0)) . map (scanl1 (+)) . init . tails