loop do
  @co = 0

  def binary_search(arr, search)
    @co += 1
    mid = (arr.size/2.0).round.to_i
    if arr.size <= 1
      return @co
    elsif arr[mid-1] < search
      return binary_search(arr[mid..-1], search)
    else
      i = (mid-2>0) ? mid - 2 : 0
      return binary_search(arr[0..i], search)
    end
  end

  n = gets.to_i
  break if n == 0
  arr = n.times.map{ gets.to_i }
  se = gets.to_i
  puts binary_search(arr, se)
end