 ns = []
 STDIN.each_line { |l| ns << l }
ns= ns.to_a.join.split[1..-1].map!(&:to_i)
 p = ns[-1]
 ns = ns[0..-2]

 a = []
 b = []
 ns.each { |d| d <= p ? a << d : b << d }

ret = a + ["[#{p}]"] + b
puts             ret