from collections import Counter
n=int(input())
a=list(map(int,input().split()))
s=[0]
x=0
for i in a:
    x+=i
    s.append(x)
cs=Counter(s).most_common()
x=0
for i,j in cs:
    x+=j*(j-1)//2
print(x)