
import std.stdio, std.string, std.conv, std.algorithm, std.array;

int swapCount(int[] arr, int target) {
  int inner(int[] arr) {
    if (arr == null) return 1;
    
    size_t pivot = arr.length / 2;
    if (arr[pivot] == target) return 1;
    else if (arr[pivot] > target) {
      return 1 + inner(arr[0..pivot]);
    }
    else {
      return 1 + inner(arr[(pivot + 1)..$]);
    }
  }
  return inner(arr);
}

int read_num() {return readln.chomp.to!int;}

void main() {
  for(int times; readf("%d\n", &times), times != 0;) {
    int[] arr;
    foreach(t; 0..times) arr ~= read_num;    
    swapCount(arr, read_num).writeln;
  }
}