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