let split target =
  Str.split (Str.regexp " ") target
  |> List.map int_of_string


let rec print_array arr =
  let n = Array.length arr in
  for i = 0 to n - 2 do
    Printf.printf "%d " arr.(i)
  done;
  Printf.printf "%d\n" arr.(n-1)


let insertion_sort l =
  let arr = Array.of_list l in
  let n = Array.length arr in
  for i = 1 to n - 1 do
    print_array arr;
    let v = arr.(i) in
    let j = ref (i-1) in
    while !j >= 0 && arr.(!j) > v do
      arr.(!j+1) <- arr.(!j);
      j := !j-1
    done;
    arr.(!j+1) <- v
  done;
  print_array arr


let () =
  let _ = read_int () in
  read_line ()
  |> split
  |> insertion_sort