N = int(input())
a = [int(i) for i in input().split()] 
b =[0]
i = 1
num = 0
while i < N+1:
    b.append(sum(a[0:i]))
    i = i+1
b.sort()
j = 0
num = 0
v = 0
while j < N:
    if b[j+1] == b[j]:
        v = v+1
    else:
        num = num + (v*(v+1))//2
        v = 0
    j = j +1
num = num + (v*(v+1))//2
print(num)