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
  var memo = Array.fill(n)(0.toLong)
  memo(0) = a(0)
  (1 until n).foreach(i =>{
    memo(i) = memo(i-1) + a(i)
    if (memo(i)==0){
      count = count + 1
    }
  })
  (1 until n).foreach(i =>{
    (i+1 until n).foreach(j =>{
      memo(j) = memo(j) -a(i-1)
      if (memo(j) == 0){
        count = count + 1
      }
    })
  })
  println(count)
}