import sys
import numpy as np
from collections import Counter

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(readline())
    A = np.array(readline().split(), np.int64)
    A_cum = np.cumsum(A)
    counter = Counter(A_cum)

    fact = [1] * (N + 1)
    for r in range(2, N + 1):
        fact[r] = fact[r - 1] * r

    def cmb(n, r):
        return fact[n] // (fact[r] * fact[n - r])

    ans = 0
    for key, value in counter.items():
        if value >= 2:
            ans += cmb(value, 2)
        if key == 0:
            ans += value
    print(ans)


if __name__ == '__main__':
    main()
