from collections import Counter
import numpy as np

N = int(input())
A = [0]+list(map(int, input().split()))

cumulative_sum = np.cumsum(A)
print(cumulative_sum)
counts = Counter(cumulative_sum)
ans = 0
for v in counts.values():
    ans += v * (v-1) // 2
    
print(ans)