n = int(input())
a = list(map(int,input().split(" ")))
b = [0 for a in range(n)]
b[0] = a[0]
answer = 0
for i in range(n-1):
    b[i+1] = b[i] + a[i+1]
# print(b)
for i in b:
    if i == 0:
        answer += 1;
minimum = min(b)
for i in range(n):
    b[i] -= minimum
# print(b)
c = [0 for a in range(max(b)+1)]
for i in range(n):
    c[b[i]] += 1

for i in c:
    if i > 1:
        answer += i * (i-1) // 2
# print(c)
# print(sum(c))
print(answer)