p gets.chomp.split.sort.map(&:to_i).each_slice(2).map { |a, b| a * b }.inject(:+)