n = int(input())
a = [int(i) for i in input().split()]

l = [0]
for x in a:
    l.append(l[-1]+x)

l = l[1:]

res = 0
for idx, x in enumerate(l):
    res+=l[:idx].count(x)
    if x==0:
        res += 1

print(res)
