inport bisect

N = int(input())
A = [int(i) for i in input().split()]

B = [0]
X = [0]
ans = 0

for i in range(N):
    X.append(X[i]+A[i])
    insert_index = bisect.bisect_left(B,X[i+1])
    for j in range(insert_index,i+1):
        if B[j] == X[i+1]:
            ans += 1
        else:
            break

    B.insert(insert_index,X[i+1])

print(ans)