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

sum_list = [None] * (N+1)

sum_list[0] = 0
for i in range(N):
    sum_list[i+1] = sum_list[i] + A[i]

output = 0
sum_list_sorted = sorted(sum_list)
for i in range(N):
    if sum_list_sorted[i] == sum_list_sorted[i+1]:
        for j in range(i+1, N+1):
            if sum_list_sorted[i] == sum_list_sorted[j]:
                output += 1
            else:
                break

print(output)