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

S = [0]

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

S = sorted(S)

ret = 0
for s in set(S):
    cnt = S.count(s)
    ret += cnt * (cnt - 1) / 2
print(int(ret))
