from collections import Counter
from math import factorial


n = int(input())
a = list(map(int, input().split()))

s = [0]
s_elem = 0

for ai in a:
  
  s_elem += ai
  s.append(s_elem)

ans = 0
for c in Counter(s).values():
  if c > 1:
    com = factorial(c) / factorial(2) / factorial(c-2)
    ans += int(com)

print(ans)