object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = Integer.parseInt(sc.next())
  val a = Array.fill(n)(Integer.parseInt(sc.next)).map(_.toLong)
  var count = 0
  (0 until n).foreach(i =>{
    (i+1 until n).foreach(j =>{
      var sum:Long = 0
      (i to j).foreach(k =>{
        sum = sum + a(k)
      })
      if (sum == 0){
        count = count + 1
      }
    })
  })
  println(count)
}