let n = read_int ();;

let to_ints (lst : string list):int list = 
 (List.map (fun x -> (int_of_string x)) lst);;

let rec print_list list_ints =
  match list_ints with
    [] -> print_newline ()
  | [n] -> print_int n; print_newline ()
  |[t;h] -> print_int t; print_string " "; print_int h; print_newline ()
  | h::t::t' -> print_int h; print_string " "; print_list (t::t');;

let rec ins n list =
  match list with
    [] -> [n]
  | h::t -> if n <= h then n::h::t
    else h::(ins n t);;
 
let rec aux acc llist list =
  match list with
    [] ->  llist
  | h::t ->
     let i = (ins h acc) in
     aux i ((i @ t) :: llist) t;;

let insort list =
  List.map (fun x -> print_list x) 
    (List.rev (aux [] [] list));;


let lst = (to_ints (Str.split (Str.regexp " ") (read_line ()))) in
insort lst;;