import collections as col

n = int(input())

a = list(map(int, input().split()))
cnt = 0
b = 0
c = [0]
for i in range(n):
    b += a[i]
    c.append(b)
    
d = col.Counter(c)
i=0
ncm=0
lend = len(d)

while i<lend:
    m = d.most_common()[i][1]
    if m > 1:
        ncm += m*(m-1)//2
        i += 1
    else:
        break

print(ncm)