N = int(input())
num_list = list(map(int, input().split()))
cumulative_sum_list = [0]
c_s = 0
for i in num_list:
    c_s += i
    cumulative_sum_list.append(c_s)
cumulative_sum_list.sort()
cumulative_sum_set = set(cumulative_sum_list)
s = 0
for i in cumulative_sum_set:
    c = cumulative_sum_list.count(i)
    s += c * (c - 1) // 2
print(s)
