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

import os
import sys

input()
nums = [int(i) for i in input().split()]
answer = 0

for i in range(len(nums)):
    for j in range(i, len(nums) + 1):
        if i == j:
            continue
        if sum(nums[i:j]) == 0:
            answer = answer + 1

print(answer)
