# AGC023
import collections
from scipy.misc import comb
N = int(input())
A = list(map(int, input().split()))
ans = 0
S = [0] * (N+1)
for i in range(N):
    S[i+1] = S[i] + A[i]
c = collections.Counter(S)
c = c.most_common()
for i in range(len(c)):
    if c[i][1] == 1:
        pass
    if c[i][1] == 2:
        ans += 1
    else:
        ans += comb(c[i][1], 2)
print(int(ans))