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
numbers = [ca.count(j) for j in list(set(ca)) if ca.count(j) > 1]
count += ca.count(0)
count += sum([int(i * (i-1) /2) for i in numbers])

print(count)