let f a=Array.iteri(fun i n->Printf.printf(if i=0 then "%d" else " %d")n)a;print_newline()
let g a n=f a;let rec h j v=if j<0 || a.(j)<=v then a.(j+1)<-v else (a.(j+1)<-a.(j);h(j-1)v)in let rec z i=if i<n then (h(i-1) a.(i);f a;z(i+1))in z 1
let () =let n=read_int()in let a=Array.of_list(List.map int_of_string(Str.split(Str.regexp " ")(read_line())))in g a n