N = int(input())
A = list(map(int, input().split()))
B = [0]
t = 0
for i in range(N):
    B.append(B[i] + A[i])

C = set(B)
for j in C:
    z = B.count(j)
    if z > 1:
        t += z*(z-1)/2

print(int(t))