num = int(input())
origin = input().split(" ")
list_ = []
sum_ = 0
output = 0

for i in origin:
    list_.append(int(i))

for start in range(num):
    for finish in range(num):
        list_once = list_[start:finish+1]
        for element in list_once:
            sum_ = sum_ + element
        if sum_ == 0:
            output = output + 1
        sum_ = 0

for i in range(num):
    output = output - i

print(output)