N = int(input())
A = list(map(int, input().split()))
a = [0] * (N+1)

for i in range(1,N+1):
    a[i] = a[i-1] + A[i-1]

a.sort()
#print(a)

b = list(set(a))

count = []

for i in range(len(b)):
    tmp = a.count(b[i])
    if tmp >= 2:
        count.append(tmp)

#print(count)

ans = 0

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

print(ans) 

