from numpy import cumsum
from collections import Counter
import math
def count(n,r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n = int(input())
a = list(map(int,input().split()))
wa = list(cumsum(a))
wa.append(0)
c = Counter(wa)
keys = set(wa)
ans = 0
for i in keys:
    num = c[i]
    if num >= 2:
        ans += count(num,2)
    else:
        pass
print(ans)
