n = gets.to_i
h = Hash.new {|h, k| h[k] = []}
(1..n).each do
    x = gets.to_i
    if x > 4
        h[:other] << x
    else
        h[x] << x
    end
end
h[:other].sort!

a = []
if h[0].empty?
    a = h[3] + h[2] + h[4] + h[:other] + h[1]
elsif h[1].empty?
    if h[0].size > 1
        a = h[3] + h[2] + h[4] + h[:other] + h[0]
    elsif h[3].empty?
        a = h[2] + h[4]
        t = a.pop
        a += h[:other]
        a << t
        a += h[0]
    else
        a = h[3] + h[2] + h[4] + h[:other]
        a << a.shift
        a += h[0]
    end
elsif h[0].size == 1
    a = h[3] + h[2] + h[4] + h[:other]
    a += [0] * (h[0].size / 2 * 2) + [1] + [0] * (h[0].size % 2) + [1] * (h[1].size - 1)
end

puts a