N = int(input())
A = list(map(int, input().split()))

count=0
for i in range(N):
    sum=[A[i]]
    k=0
    for j in range(i+1, N):
        sum.append(sum[k]+A[j])
        k+=1
    count += sum.count(0)

print(count)