def insertion_sort(array)
  1.upto @N-1 do |i|
    v = array[i]
    j = i - 1
    while j >= 0 && array[j] > v do
      array[j+1] = array[j]
      j -= 1
    end
    array[j+1] = v

    puts array.join(" ")
  end
end


@N = gets.to_i
array = gets.split(" ").map{|x| x.to_i}

puts array.join(" ")
insertion_sort array

