N = int(input())
A = list(map(int, input().split()))
S = [0]
for i, a in enumerate(A):
    S.append(S[i]+a)
S = sorted(S)
prev = 0
ans = 0
tmp_count = 0
for s in S[1:]:
    if s==prev:
        tmp_count += 1
    else:
        ans += tmp_count*(tmp_count+1)//2
        tmp_count = 0
    prev = s
ans += tmp_count*(tmp_count+1)//2
print(ans)
