import itertools
N = int(input())
A = list(map(int, input().split()))
acum = [0] + list(itertools.accumulate(A))
cnt = 0
for i in range(len(acum)):
    for j in range(i+1, len(acum)):
        if acum[j] == acum[i]:
            cnt += 1
print(cnt)

