from collections import Counter
N = int(input())
A = list(map(int, input().split()))
s = [0]
for a in A:
    s.append(s[-1]+a)

c = Counter(s)

ans = 0
for k, v in c.items():
    ans += v*(v-1)//2
print(ans)
