size = gets.chomp.to_i
input_values = []

input_strings = gets.chomp.split
for i in 0..size-1
  input_value = input_strings[i].to_i
  input_values.push(input_value)
end



# def insertion_sort(array, size)
#  for i in 0..(size-2)
#    if array[i] > array[i+1]
#      tmp = array[i+1]
#      array[i] = array[i+1]
#      array[i+1] = tmp
#     end
#   end
# end
def insertion_sort(array, size)
  for i in 1..(size-1)
    target = array[i]
    while (i > 0) && (array[i-1] > target)
      array[i] = array[i-1]
      i += -1
    end
    array[i] = target
    puts array.join(' ')
  end
  return array
end

insertion_sort(input_values, size)