loop do
  @co = 0
    def binary_search(arr, search)
      @co += 1
      mid = arr.size/2
      if arr.size <= 1
        return @co
      elsif arr[mid-1] < search
        return binary_search(arr[mid..-1], search)
      else
        return binary_search(arr[0..(mid-2)], 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