let print_array l = Array.fold_left (fun x y -> (if x = "" then "" else x^" ")^(string_of_int y)) "" l
                   |> print_endline;;

let n = read_int ()  and
    a = read_line () |> Str.split (Str.regexp_string " ")
        |> List.map (fun x -> int_of_string x) |> Array.of_list in
    let rec loop l = function
        i when i = n -> print_array l;l
      | i -> print_array l;
             let key = l.(i) in
             let rec loop2 l2 = function
                 j when j < 0 || l2.(j) <= key -> l2.(j+1) <- key;l2
               | j -> l2.(j+1) <- l2.(j);
                      loop2 l2 (j-1)
             in loop (loop2 l (i-1)) (i+1)
    in loop a 1;;