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

ans = 0
for v in ctr.values():
    ans += v*(v-1)//2
print(ans)