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))
for j in info:
    tmp = a2.count(j)
    if tmp == 2:
        cnt += 1
    elif tmp == 1:
        continue
    else:
        cnt += tmp * (tmp - 1) // 2
print(cnt)