n = int(input())
a = list(map(int,input().split()))

b = []

sum = 0
for i in range(n):
    sum += a[i]
    b.append(sum)


c = [0 for i in range(n)]

for i in range(n):
    c[b[i]] += 1



sub = 0
d = []
for i in range(n):
    d.append(sub)
    sub += i
    
    


ans = 0

for i in range(n):
    ans += d[c[i]]

ans += c[0]

print(ans)
    
    
    