from collections import defaultdict

N = int(input())
c = defaultdict(int)
s = 0
c[s] += 1
for a in list(map(int, input().split())):
    s += a
    c[s] += 1
print(sum(list(map(lambda v: v * (v - 1) // 2, c.values()))))
