import scala.io.Source

object Main extends App {

  def zeros(is: List[Int], n: Int, max: Int): Int = {
    (0 to (max - n)).foldLeft(0)((acc, start) => acc + (if (is.slice(start, start + n).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((1 to n).foldLeft(0)((acc, i) => acc + zeros(is, i, n)))
}
