def insertion_sort(aa)
  puts aa.join(" ")
  for i in 1..aa.size-1
    key = aa[i]
    j = i - 1
    while j >= 0 and aa[j] > key
      aa[j+1] = aa[j]
      j -= 1
    end
    aa[j+1] = key
    puts aa.join(" ")
  end
end

gets
insertion_sort(gets.split(" ").map(&:to_i))

