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