from itertools import accumulate
import collections

N = int(input())
A = [int(i) for i in input().split()]

B = [0] + A
B = list(accumulate(B))

c = collections.Counter(B)
cm = c.most_common()

cnt = 0
for v in cm:
    if v[1] > 1:
        cnt += (v[1]*(v[1]-1)//2)
