N = int(input())
A = [int(i) for i in input().split()]


def ca(n):
    array = [0]*(N-n+1)
    array[0] = sum([A[i] for i in range(n)])
    for i in range(1,N - n + 1):
        array[i] = array[i - 1] + A[n + i - 1] - A[i-1]
    return array


count = 0
for j in range(1, N+1):
    count += sum([1 if k == 0 else 0 for k in ca(j)])

print(count)