w_arr = Array.new(10) { |i| i=0 }
k_arr = Array.new(10) { |i| i=0 }

10.times do |i|
  w_arr[i] = gets.to_i
end

10.times do |i|
  k_arr[i] = gets.to_i
end

puts "#{w_arr.sort.reverse[0..2].inject(:+)} #{k_arr.sort.reverse[0..2].inject(:+)}"