n = gets
array = gets

class Array
  def swap!(a, b)
    self[a], self[b] = self[b], self[a]
    self
  end
end

array.each_with_index do |key, key_index|
  p array
  next if key_index.zero?
  array[0..key_index].each_with_index do |comp, comp_index|
    if key < comp
      array.swap! key_index, comp_index
      next
    end
    puts array
  end
end

