#coding = utf-8 require "set" 💩 = gets.to_i; 💩💩 = gets.split().map(&:to_i); 💩💩💩💩 = 💩💩.sort().uniq() 👾 = 💩💩💩💩.size; for 🚽 in 0...💩 do 👇 = 0; 👆 = 👾; while (👆-👇>1) do 💪 = (👇+👆)/2; if 💩💩[🚽] < 💩💩💩💩[💪] then 👆 = 💪; else 👇 = 💪; end end 💩💩[🚽] = 👇; end 🐕💩 = Array.new(👾); 🐈💩 = Array.new(👾); 0.upto(💩-1) { |🚽| 🐕💩[ 💩💩[🚽] ] = 🚽; } (💩-1).downto(0) { |🚽| 🐈💩[ 💩💩[🚽] ] = 🚽; } 🎅 = Array.new(💩, "🎅"); 🎄 = SortedSet.new(); 0.upto(💩-1) { |🚽| if 🐈💩[ 💩💩[🚽] ] == 🚽 then 🎄.add( -1 * 💩💩[🚽] ); end 🎄.each { |🍦| 🎅[🚽] = -1*🍦; break; } if 🐕💩[ 💩💩[🚽] ] == 🚽 then 🎄.delete( -1 * 💩💩[🚽] ); end } puts 🎅.join(" ")