fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(' ').map { it.toLong() }

    val s = LongArray(n + 1)
    for (i in 0 until n) {
        s[i + 1] = s[i] + a[i]
    }

    s.groupBy { it }
            .values
            .map { it.size.toLong() }
            .map { it * (it - 1) / 2 }
            .sum()
            .let { println(it) }
}
