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

#部分列の和を考えるなら累積和を
ruiseki_A_list = [0 for _ in range(N)]

for i in range(N):
    if i == 0:
        ruiseki_A_list[i] = A_list[i]
    else:
        ruiseki_A_list[i] = A_list[i] + ruiseki_A_list[i-1]

#元のある区間の総和が知りたい
ruiseki_A_list.insert(0,0)
ans = 0
for left_num in range(N+1):
    for right_num in range(N+1):
        if left_num < right_num:
            if ruiseki_A_list[right_num] - ruiseki_A_list[left_num]==0:
                ans += 1
print(ans)