N = int(input())

A = [0] + [n for n in map(int, input().split())]

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

element_A = set(A)

ans = 0

for a in element_A:
    num_a = A.count(a)
    if num_a > 1:
        ans += num_a * (num_a - 1) / 2
print(int(ans))
