N = int(input())
A = list(map(int, input().split()))
csum = list()
ans = 0
for i in range(0, len(A)):
    list.append
    if i == 0:
        csum.append(A[i])
    else:
        csum.append(csum[i - 1] + A[i])
        if csum[i] == 0:
            ans += 1
        for j in range(0, i):
            if csum[i] == csum[j]:
                ans += 1
print(ans)
