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

acc = [0]
for i in range(N):
    acc.append(acc[i] + A[i])

ans = 0
for i in collections.Counter(acc).values():
    ans += i * (i-1) // 2
print(ans)