// https://atcoder.jp/contests/agc023/tasks/agc023_a

fun main() {
    agc023a()
}

fun agc023a() {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toLong() }
    val table = Array<Long>(n + 1) { 0L }
    for (i in 0 until n) {
        table[i + 1] = table[i] + a[i]
    }
    val counts = table.groupingBy { it }.eachCount()
    var count = 0L
    for (v in counts.values) {
        if (v > 1) {
            count += (v - 1) * v / 2
        }
    }
    println(count)
}