import collections

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

S = [0]

for a in A:
    S.append(S[-1] + a)

c = collections.Counter(S)
ans = 0

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

print(ans)
