from math import factorial
L = [0]
N = int(input())
A = list(map(int, input().split()))
cnt = 0
for i in range(N):
    L.append(L[-1] + A[i])
L.sort()
ind = list(set(L))
for i in ind:
    n = L.count(i)
    if n > 1:
        cnt += factorial(n) / factorial(2) / factorial(n - 2)
print(int(cnt))