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

ans = 0

b = [0]
for i in range(n):
    b.append(b[i] + a[i])
for x in list(set(b)):
    b_num = b.count(x)
    ans += sum([i for i in range(b_num)])
    
print(ans)