import scala.io.Source

object Main extends App {

  def zeros(is: List[Int]): Int = {
    def go(rest: List[Int], acc: Int): Int = rest match {
      case _ :: t => go(t, onezeros(rest.reverse) + acc)
      case Nil => acc
    }
    go(is, 0)
  }

  def onezeros(is: List[Int]): Int = is match {
    case Nil => 0
    case _ :: t => onezeros(t) + (if (is.sum == 0) 1 else 0)
  }

  val lines: Iterator[String] = Source.stdin.getLines()
  val n: Int = lines.next.toInt
  val is: List[Int] = lines.next.split(" ").take(n).map(_.toInt).toList
  println(zeros(is))
}
