N = int(input())
a = list(map(int, input().split(" ")))

# print(a)
result = 0
for i in range(1, N):
    for j in range(N-i+1):
        s = 0
        for k in range(i):
            s += a[k+j]
        # print(i,j,k,s)
        if s == 0:
            result += 1
print(result)