N = int(input())
A = list(map(int,input().split()))
S = []
s = 0
for i in range(N):
    s += A[i]
    S.append(s)
ans = 0
for i in range(N):
    x = S.pop(0)
    if x == 0:
        ans += 1
    ans += S.count(x)
print(ans)