import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N = int(input())
A = list(map(int, input().split()))

S=[0]
for i in range(1, N+1):
    S.append(S[i-1]+A[i-1])

S.sort()
Num = list(set(S))

ans = 0
for num in Num:
    count = S.count(num)
    if count!=1:
        ans += combinations_count(count,2)

print(ans)