n = int(input())
a = list(map(int, input().split()))

ans = 0

for i in range(n):
    sums = [0] * (n - i +  1)
    for j in range(n - i):
        sums[j + 1] = sums[j] + a[i + j]
    ans += sums.count(0) - 1
        
print(ans)