N = int(input())
A = list(map(int, input().split()))
S = [0]*(N+1)
for n in range(N):
    S[n+1] = S[n] + A[n]
C = [0]*(2*10**5+1)
for n in range(len(S)):
    C[S[n]] += 1
cnt = 0
for c in range(2*10**5+1):
    cnt += C[c] * (C[c] - 1) // 2
print(cnt)