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

N = int(input())
A = list(map(int, input().split()))

counter = 0

# len_zero = [[]]
# fin = False
for l in range(1, N, 1): # l is length
    # sumzero = []
    for i in range(N):
        if (i + l - 1 > N - 1):
            # fin = True
            break
        sumval = 0
        for j in range(i, i + l, 1):
            sumval += A[j]
        if(sumval == 0):
            # sumzero.append([i. j])
            counter += 1
            # fin = False
    # len_zero.append(sumzero)

# for l in range(2, N, 1): # l is length


print(counter)