#coding = utf-8 require "set" 💩 = gets.to_i; 💩💩 = gets.split().map(&:to_i); 🐕💩 = Hash.new(); 🐈💩 = Hash.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(" ")