n = int(input())
a = list(map(int, input().split()))
a2 = [0]
cnt = 0
for i in a:
    a2.append(a2[-1] + i)

info = list(set(a2))
chm = []
for k in info:
    chm.append(a2.count(k))

for j in chm:
    if j == 2:
        cnt += 1
    elif j == 1:
        continue
    else:
        cnt += j * (j - 1) // 2
print(cnt)