import itertools as itr
n = int(input())
a = list(map(int, input().split()))
itra = list(itr.accumulate(a))
ans_c = itra.count(0)
seta = set(itra)
for i in seta:
    tmp_c = itra.count(i)
    ans_c += tmp_c * (tmp_c - 1) // 2
print(ans_c)