include Math
n = gets.to_i
a = (1..n).map { gets.to_i }.sort
t = []
if a[0] == 0
    t << a.shift while !a.empty? && a[0] == 0
    t << a.shift if !a.empty?
end

puts a.sort_by {|x| [log(x) / x, -x]}.reverse
puts t.reverse