n = int(input())
a = list(map(int,input().split()))
b = list()
b.append(0)
b.append(a[0])
for i in range(len(a) - 1):
    b.append(b[i + 1] + a[i + 1])
y = 0
while True:
    x = b.count(b[0])
    if x >= 2:
        y += x * (x-1) / 2
    b.remove(b[0])
    if len(b) <= 1:
        break
print(int(y))