from collections import defaultdict
n=int(input())
a=[int(i) for i in input().split()]

dic = defaultdict(int)
dic[0]=1

total = 0
ans=0
for i in a:
    total+=i
    ans += dic[total]
    
    dic[total]+=1
print(ans)
    