def calc(value):
    return value*(value-1)//2


n = int(input())
array = [int(x) for x in input().split()]

tmp_sum = 0
sum_array = []

for i in array:
    tmp_sum += i
    sum_array.append(tmp_sum)

sum_dict = {x:sum_array.count(x) for x in set(sum_array)}
if 0 in sum_dict.keys():
    sum_dict[0] += 1

res = 0
for key, value in sum_dict.items():
    if value >= 2:
        res += calc(value)

print(res)

