fun main(args: Array<String>) {
  val N = readLine()!!.toInt()
  val A = readLine()!!.split(" ").map{ it.toLong() }.toList()

  val tb = mutableMapOf<Long, Long>()
  var sum = 0L
  var ans = 0L
  tb[0] = 1L
  for(x in A) {
    sum += x
    ans += tb.getOrElse(sum) { 0L }
    tb[sum] = tb.getOrElse(sum) { 0L } + 1
  }

  println(ans)
}