private fun readInts() = readLine()!!.split(" ").map { it.toInt() }

fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val a = readInts()

    val sum = mutableListOf<Int>()
    a.forEachIndexed { index, value -> if (index == 0) sum.add(0, value) else sum.add(index, sum[index - 1] + value) }
    val sumArray = sum.toTypedArray()

    var amount = sumArray.count { it == 0 }
    for (i in 1 until N) for (j in 0 until i) if (sumArray[i] == sumArray[j]) amount++

    println(amount)
}