from collections import defaultdict

N = int(input())
A = list(map(int, input().split()))

counter = defaultdict(int)
ret = 0
cum = 0
counter[0] += 1
for a in A:
    cum += a
    ret += counter[cum]
    counter[cum] += 1
print(ret)