fun main(args: Array<String>) {
    val N = readInputLine().toInt()
    val AArr = readInputLine().split(" ").map { it.toLong() }.toLongArray()
    val sumArr = LongArray(N)
    sumArr[0] = AArr[0]
    
    for (i in 1 until N) {
        sumArr[i] = sumArr[i - 1] + AArr[i]
    }
    
    var ans = 0L
    var sum = 0L

    for (i in 0 until N) {
        for (j in i until N) {
            if (sumArr[j] - sum == 0L) {
                ans++
            }
        }
        sum += AArr[i]
    }

    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}
