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

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

fun countList(a: List<Int>): Map<Int, Int> {
    val result = mutableMapOf<Int, Int>()
    a.forEach {
        result[it] = (result[it] ?: 0) + 1
    }
    return result
}


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

    val S = sumList(A.toList())
    val C = countList(S)
    var result = 0
    C.forEach { ent ->
        result += (ent.value * (ent.value - 1)) / 2
    }
    println(result)
}
