n = int(input())
l = list(map(int, input().split()))
ans, c, x, y, xxx = 1, 0, [], 1, []
target = len(l)-1
for i in range(1, n-1):
    for i in range(1, n-1):
        if target==len(x):
            x.pop(0)
            y+=1
        x.append(l[c])
        if sum(x)==0:
            ans+=1
        c+=1
    x = []
    target-=1
    c = 0
print(ans-1)