fun main(args: Array<String>) {
    val n = Integer.parseInt(readLine())
    val arr = readLine()!!.split(" ").map { Integer.parseInt(it) }
    var res = 0
    for (i in 0 until n) {
        var sum = 0
        for (j in i until n) {
            sum += arr[j]
            if (sum == 0) {
                res++
            }
        }
    }
    println(res)
}