from collections import Counter as C

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

acc = [0]
for i in a:
    acc.append(i+acc[-1])

res = 0
for k,v in C(acc).most_common():
    res += v*(v-1)//2
print(res)
