
def insert_sort(items)
  puts items.join(" ")
  1.upto(items.size-1) do |i|
    v = items[i]
    j = i - 1
    while j >= 0 && items[j] > v
      items[j+1] = items[j]
      j -= 1
    end
    items[j+1] = v # 挿入
    puts items.join(" ")
  end
end

gets
items = gets.split(" ").map(&:to_i)
insert_sort(items)

