n = input()
a = list(map(int, input().split()))

a_sum = []

for ai in a:
    if a_sum:
        a_sum.append(a_sum[-1] + ai)
    else:
        a_sum.append(ai)

a_len = len(a)
count = 0
for end_ind in range(1, a_len + 1):
    for start_ind in range(end_ind):
        if start_ind == 0:
            sum_1 = 0
        else:
            sum_1 = a_sum[start_ind - 1]
        
        sum_2 = a_sum[end_ind - 1]

        sub_seq_sum = sum_2 - sum_1

        if sub_seq_sum == 0:
            count += 1

print(count)
