from itertools import accumulate
n = int(input())
a_list = list(map(int,input.split()))
cumsum = accumulate(a_list)
num_dict = {0:1}
for s in cumsum :
  if str(s) in num_list.keys:
    num_dict[str(s)] += 1
  else:
    num_dict[str(s)] = 1

res = 0
for val in numdict:
  res += val * (val - 1)/2
  
print(res)
  