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)
  and doit i =
    if i < n then (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 (Str.split (Str.regexp " ") (read_line ()))) in
  insertion_sort a n