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

ans = 0

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