
n = int(input())
a = list(map(int,input().split()))
ans = 0
b = [0]
for i in range(1,n+1):
    b.append(b[i-1] + a[i-1])
b.sort()

c = b.copy()
c = set(c)

#Dはそれぞれの個数を格納するリスト
d = []
for i in range(len(c)):
    d.append(b.count(b[i]))
#print(d)

for i in range(len(d)):
    ans += int(d[i]*(d[i] -1)/2)

print(ans)


#以下のプログラムだと計算量が多すぎで終わらない
"""
for i in range(n):
    for j in range(i+1,n+1):
        b = a[i:j]
#        print(b)

        if sum(b) == 0:
            ans += 1

print(ans)
"""
