N = int(input())
A = [int(i) for i in input().split()]

s = [0]
sum = 0
for i in range(N):
    sum += A[i]
    s.append(sum)
s = sorted(s)

ans = 0
for r in set(s):
    if s.count(r) >= 2:
        ans += (s.count(r)*(s.count(r)-1))//2

print(ans)
