let split str delim =
  let rec doit s acc =
    match
      try Some (String.index s delim)
      with _ -> None
    with
    | None -> List.rev (s :: acc)
    | Some i ->
        let s1 = String.sub s 0 i in
        let s2 = String.sub s (i + 1) (String.length s - String.length s1 - 1) in
        doit s2 (s1 :: acc)
  in
  doit str []

let print_array a =
  Array.iteri (fun i n -> Printf.printf (if i = 0 then "%d" else " %d") n) a;
  print_newline ()

let insertion_sort a n =
  print_array a;
  let rec insert j v =
    if j < 0 || a.(j) <= v then a.(j + 1) <- v
    else (a.(j + 1) <- a.(j); insert (j - 1) v)
  in
  let rec doit i =
    if i >= n then ()
    else (insert (i - 1) a.(i); print_array a; doit (i + 1))
  in
  doit 1

let () =
  let n = read_int () in
  let a = Array.of_list (List.map int_of_string (split (read_line ()) ' ')) in
  insertion_sort a n