fun main(args: Array<String>) {
    agc023a()
}

fun agc023a() {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(' ').map { it.toLong() }.toLongArray()

    val cumulativeSum = LongArray(n + 1)
    for (i in aList.indices) cumulativeSum[i + 1] = cumulativeSum[i] + aList[i]

    var answer = 0L
    for (left in 0..aList.lastIndex + 1) {
        for (right in left + 1..aList.lastIndex + 1) {
            if (cumulativeSum[right] - cumulativeSum[left] == 0L) answer++
        }
    }

    println(answer)
}
