


from collections import Counter

N = int(input())
A = list(map(int, input().split()))

cum = [0]
for a in A:
    cum.append(cum[-1] + a)

ans = 0
c = Counter(cum)
for _,v in c.items():
    ans += v*(v-1)//2

print(ans)