from collections import Counter

n = int(input())
c = Counter()
c[0] = 1
s = 0
for a in map(int, input().split()):
    s += a
    c[s] += 1

res = sum(v * (v - 1) // 2 for v in c.values())
print(res)
