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

int swapCount(int[] arr, int t, int n) {
  int l = 0, r = n - 1;
  int count = 0;
  while (l <= r) {
    int m = (l + r) / 2;
    count++;
    if (arr[m] > t) r = m - 1;
    else if (arr[m] == t) break;
    else l = m + 1;
  }
  return count;
}

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

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