a = [] (0..5).each do |i| n = gets.to_i if n%2 == 0 a.insert(0, n) else a.push(n) end end print a