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

ans = 0
for i in range(n):
    b = []
    for j in range(i, n):
        b.append(a[j])
        if sum(b) == 0 and b:
            ans += 1
            pass

print(ans)