# frozen_string_literal: true N = gets.to_i AS = gets.chomp.split.map(&:to_i) sorting = AS (0..2 * N - 3).each do |i| (0..N - 1).each do |p| q = i - p next if p >= q || sorting[p].nil? || sorting[q].nil? sorting[p], sorting[q] = sorting[q], sorting[p] if sorting[p] > sorting[q] end end puts sorting.join(' ')