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])
    }
//    aAccumulation.sort()
    val set = aAccumulation.toSet()
    var ans = 0
    for (s in set) {
        ans += kaijo(aAccumulation.filter { it == s }.size - 1)
    }

    println(ans)
}

fun kaijo(i: Int): Int {
    var ans = 1
    if (i < 2) return i
    for (k in 2..i) {
        ans *= k
    }
    return ans
}