import scipy.misc

N=int(input())
A=list(map(int,input().split()))
ans=0
s=[0 for i in range(N+1)]

for i in range(N):
    s[i+1] = s[i] + A[i]

for x in [s.count(x) for x in set(s)]:
    ans += int(scipy.misc.comb(x, 2))

print(str(ans))
