let rec insert x  = function
  [] -> [x]
  | hd :: tl -> if x < hd then x :: hd :: tl
                else hd :: (insert x tl) ;;

let print_intlist = function
    [] -> ()
  | hd :: tl -> print_int hd;
                List.iter (Printf.printf " %d") tl;
                print_newline();;

let ins_ord lst =
  let rec f res = function
      [] -> ()
    | hd::tl -> let l = insert hd res in
                print_intlist (List.append l tl);
                f l tl
  in
  f [] lst ;;
                                             
let () =
  let m = Scanf.scanf "%d\n" (fun x -> x) in
  let as_ = Array.init m (fun _ -> Scanf.scanf "%d " (fun x -> x)) in
  let lst = Array.to_list as_ in
  ins_ord lst ;;
