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

ans = 0

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