from collections import Counter
from scipy.misc import comb

N = int(input())
A = list(map(int, input().split()))
ans = 0
cumulative_sum = [0] + [sum(A[:i+1]) for i in range(N)]
counts = Counter(cumulative_sum).most_common()
ans = 0
for c in counts:
    if c[1] < 2:
        break
    ans += comb(c[1], 2, exact=True)
    
print(ans)
