import math

n = int(input())
a = [int(i) for i in input().split()]
zero = 0
total_list = [0]
total = 0
for i in a:
  total += i
  zero += total_list.count(total)
  total_list.append(total)

print(zero)
