n = int(input())
list_a = list((map(int, input().split())))
memo = 0
memo_list = [0]
memo_dict = {}
for i in range(0,n):
    memo += list_a[i]
    memo_list.append(memo)
    if memo in memo_dict:
        memo_dict[memo] += 1
    else:
        memo_dict[memo] = 1
ans = 0
for number in memo_dict.values():
    ans += number * (number-1) / 2
print(int(ans))
