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

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|
  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
  end
  array.each_with_index do |array_val, i|
    print array_val
    if i != array.length - 1
      print ' '
    end
    if i == array.length - 1
      puts
    end
  end
end

