while n = gets.to_i
  break if n == 0

  arr = gets.split(' ').map(&:to_i)
  puts arr.join(' ')

  1.upto(arr.size - 1) do |i|
    if arr[i-1] < arr[i]
      puts arr.join(' ')
      next
    end

    i.downto(1) do |j|
      if arr[j-1] > arr[j]
        arr[j-1], arr[j] = arr[j], arr[j-1]
      else
        break
      end
    end

    puts arr.join(' ')
  end
end