from collections import Counter

n = int(input())
a = list(map(int, input().split()))
b = [0]
ans = 0
for i in range(1, n+1):
    b.append(a[i-1] + b[i-1])
d = Counter(b)
d_v = d.values()
for i in d_v:
    ans += i*(i-1)//2
print(ans)