fun main(args: Array<String>) {
    solve(java.util.Scanner(System.`in`))
}

fun sumArray(a: List<Int>): List<Int> {
    val result = mutableListOf(0)
    var i = 0
    a.forEach {
        i += it
        result.add(i)
    }
    return result
}

fun solve(sc: java.util.Scanner) {
    val N = sc.nextInt()
    val A = Array(N) { sc.nextInt() }

    var result = 0
    val S = sumArray(A.toList())
    for (i in 0 until S.count() - 1) {
        for (j in (i + 1) until S.count()) {
            if (S[i] == S[j]) {
                result++
            }
        }
    }
    println(result)
}
