from collections import Counter
N = int(input())
A = list(map(int, input().split()))

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

c = Counter(Acum)
ans = sum(x * (x - 1) // 2 for x in c.values())
print(ans)
