import numpy as np
N = int(input())
A = np.array([int(i) for i in input().split()])
ret_arr = [0]*N

def ca(n):
    if n == 1:
        array = np.zeros(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]
        ret_arr[0] = array
    else:
        array = A[n-1:N] + np.array(ret_arr[n-2][0:N-n+1])
        ret_arr[n-1] = array
    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)
