ans' m (b,e) d t =
  let i = (b+e) `div` 2
      c = d!!i
  in
    if c == t 
    then m
    else if b == e
         then m
         else 
           if t < c
           then ans' (m+1) (b,i-1) d t
           else ans' (m+1) (i+1,e) d t

ans :: [Int] -> [Int]
ans (0:_) = []
ans (n:xs) =
  let d = take n xs
      t = head $ drop n xs
      r = drop (n+1) xs
  in
    (ans' 1 (0,n-1) d t):(ans r)

main = do
  c <- getContents
  let i = map read $ lines c :: [Int]
      o = ans i
  mapM_ print o