fun main(arr: Array<String>) {
    val n = readLine()!!.toInt()
    val list = readLine()!!.split(" ").map { it.toLong()}
    val total = mutableListOf(list.first())
    list.drop(1).forEach { total.add(total.last() + it) }
    val cnt = mutableMapOf<Long, Int>()
    total.forEach { cnt[it] = (cnt[it]?:0) + 1 }
    var ans = (cnt[0]?:0).toLong()
    cnt.filter { it.value > 1}.forEach { ans += it.value.toLong() * (it.value - 1) / 2 }
    println(ans)
}