n = int(input())
a = list(map(int, input().split()))
s = 0
d = {}
for i in a:
    s += i
    d[s] = d.get(s, 0) + 1
ans = 0
for key, value in d.items():
    ans += value*(value-1)//2
    if key == 0:
        ans += value
print(ans)