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

 w = w_arr.sort! {|a, b| b <=> a }
 k = k_arr.sort! {|a, b| b <=> a }
 puts "#{w[0]+w[1]+w[2]} #{k[0]+k[1]+k[2]}"