import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = (1..n).map { sc.nextLong() }
    val count = mutableMapOf<Long,Int>()
    count[0] = 1
    var sum = 0L
    var ans = 0L
    for (i in a.indices) {
        sum += a[i]
        val countTmp = count.getOrElse(sum, {0})
        ans += count.getOrElse(sum, {0})
        count[sum] = countTmp + 1
    }
    println(ans)
}