from collections import Counter
n = int(input())
a = [int(i) for i in input().split()]
s = [0]*(n+1)
for i in range(n): s[i+1] = s[i] + a[i]
cnt = Counter(s)
ans = 0
for v in cnt.values(): ans += v*(v-1)//2
print(ans)