def bsearch(a, i, j, x)
    return 0 if i > j
    c = (i + j) / 2
    if a[c] < x
        1 + bsearch(a, c+1 , j, x)
    elsif x < a[c]
        1 + bsearch(a, i, c-1, x)
    else
        return 1
    end
end

loop do
    n = gets.to_i
    break if n == 0
    a = (1..n).map { gets.to_i }
    p bsearch(a, 0, a.size-1, gets.to_i)
end