import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val s = mutableListOf(0L)

    for (i in 0 until n) {
        val a = sc.nextInt()
        s.add(s.last() + a)
    }
    s.sort()
    var ans = 0
    var cnt = 0
    for (i in 1 until s.size) {
        if (s[i - 1] == s[i]) {
            cnt++
        } else {
            cnt = 0
        }
        ans += cnt
    }
    println(ans)
}
