N = gets.chomp.to_i
array = gets.chomp.split.map(&:to_i)

def insertion_sort(array, n)
  puts array.join ' '
  (1..n-1).to_a.each do |i|
    v = array[i]
    j = i - 1
    while j >= 0 && array[j] > v
      array[j + 1] = array[j]
      j -= 1
    end
    array[j + 1] = v
    puts array.join ' '
  end
end

insertion_sort(array, N)