N = int(input())
A = [int(i) for i in input().split()]
ca = [A[0]] + [0]*(N-1)

for i in range(1,N):
    ca[i] = ca[i-1] + A[i]

count = 0
for i in list(set(ca)):
    if i == 0:
        count += sum([1 if j == 0 else 0 for j in ca])
    number = sum([1 if j == i else 0 for j in ca])
    count += int(number * (number-1) /2)

print(count)