def insertionSort(number, array)
  puts array.join(" ").strip

  for i in 1..number-1 do 
    next_array = array[i]
    j = i - 1

    while ( j >= 0 && array[j].to_i > next_array.to_i)
      array[j + 1] = array[j]
      array[j] = next_array
      j -= 1
    end
    puts array.join(" ").strip
  end
end

number = gets.to_i
array = gets.to_s.split(" ")

insertionSort(number,array)
