# -*- coding: utf-8 -*-

max_length = 10e5

def func(A, n):
    # nこの話を数える.
    count = 0
    for i in range(len(A)):
        if i + n > len(A):
            break

        s = sum(A[i:i+n])
        if s == 0:
            count += 1
    return count



def main():
    N = int(input())
    A = input().split()
    A = [int(a) for a in A]
    count = 0
    for i in range(1,N):
        count += func(A, i)
    print(count)


if __name__ == '__main__':
    main()
