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

A_sum = [0] * (N + 1)
for i in range(1, N+1):
    A_sum[i] = A_sum[i-1] + A[i-1]
dict = {}
for a in A_sum:
    if a in dict.keys():
        dict[a] = dict[a] + 1
    else:
        dict[a] = 1
ans = 0
for num in dict.values():
    ans += num * (num-1) / 2
print(int(ans))
