import java.util.*

private fun readStrings() = readLine()!!.split(" ")
private fun readInts() = readStrings().map { it.toInt() }

private inline fun <T, R> Iterable<T>.scanIndexed(initial: R, operation: (Int, R, T) -> R): List<R>
        = foldIndexed(listOf()) { index, list, elem -> list + operation(index, list.lastOrNull() ?: initial, elem) }

private inline fun <T> Iterable<T>.scanIndexed1(operation: (Int, T, T) -> T): List<T>
        = drop(1).scanIndexed(first(), operation)

private inline fun <T, R> Iterable<T>.scan(initial: R, operation: (R, T) -> R): List<R>
        = scanIndexed(initial) {i, list, elem -> operation(list, elem) }

private inline fun <T> Iterable<T>.scan1(operation: (T, T) -> T): List<T>
        = scanIndexed1 {i, list, elem -> operation(list, elem)}

private inline fun <T> Iterable<T>.countElements(): Map<T, Int> {
    val result = HashMap<T, Int>()
    forEach { result[it] = (result[it] ?: 0) + 1 }
    return result
}

fun main(args: Array<String>) {
    val N = readInts()[0]
    val a = readInts().map{ it.toLong() }
    val sums = (listOf(0L, 0L) + a).scan1 { a, b -> a + b }
    val reps = sums.countElements().values.map { it * (it - 1) / 2 }
    println(reps.sum())
}