from collections import Counter

n = int(input())
a = [int(i) for i in input().split()]
s = [0] * (n+1)
ans = 0
for i in range(n):
    s[i+1] = s[i] + a[i]
c = Counter(s)
for i in c:
    ans += int(c[i]*(c[i]-1)//2)
print(ans)
