n = int(input())
A = list(map(int, input().split()))
for i in range(1, n):
    A[i] = A[i] + A[i-1]
ans = 0
A.sort()
p = A[0]
count = 1
for i in range(1, n):
    x = A[i]
    if x == p:
        count += 1
    else:
        ans += count * (count-1)//2
        count = 1
        p = x
ans += count * (count-1)//2
print(ans)
