fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(" ").map(String::toInt)
    val aAccumulation = mutableListOf(0)
    for (i in 1..n) {
        aAccumulation.add(aAccumulation[i - 1] + aList[i - 1])
    }

    var ans = 0
    for (i in 0..(n - 1)) {
        ans += aAccumulation.filterIndexed { index, it -> it == aAccumulation[i] && index > i }.size
    }
    println(ans)
}

