from itertools import accumulate
from collections import Counter
import sys
input = sys.stdin.readline
n = int(input())
a = [0]
a.extend(map(int,input().split()))
a = list(accumulate(a))
c = Counter(a)
ans = 0
for i in c.values():
  ans+=i*(i-1)//2