from collections import Counter

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

S = []

for i, a in enumerate(S):
    S.append(S[0] + a)

S.sort()
a = Counter(S).most_common()

cnt = 0

for i in range(len(a)):
    cnt += ((a[i][1]-1)*a[i][1])//2

print(cnt)
