import collections
n = int(input())
a = list(map(int, input().split()))

memo = collections.defaultdict(int)
memo[0] += 1
total = 0
cnt = 0
for i in range(n):
    total += a[i]
    cnt += memo[total]
    memo[total] += 1
print(cnt)
