n = int(input())
a = list(map(int,input().split()))
ans = 0
s = [sum(a[:i]) for i in range(n+1)]
t = sorted(s)
p=1
for i in range(n):
    if t[i]==t[i+1]:
        p+=1
    else:
        ans += p*(p-1)//2
        p=1
ans += p*(p-1)//2
print(ans)
