from collections import Counter

N = int(input())
A = list(map(int, input().split()))

cumA = [0] * (N + 1)

for i in range(N):
    cumA[i + 1] += cumA[i] + A[i]

cntA = Counter(cumA)

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

def ncr(n, r):
    if r > n or n < 0 or r < 0:
        return 0
    return fact[n] // fact[n - r] // fact[r]

ans = 0
for _, c in cntA.items():
    ans += ncr(c, 2)

print(ans)