from collections import Counter
n = int(input())
a = list(map(int, input().split()))
l = [0]
ans = 0
for i in range(n):
    l.append(l[i] + a[i])
c = Counter(l)
for i in c.values():
    ans += i * (i - 1) // 2
print(ans)