# frozen_string_literal: true def solve L.permutation.map(&:wrap_length).min end class Array # rubocop:todo Style/Documentation def wrap_length 2 * combination(2).map(&:sum).zip(C).map { |a, b| a * b }.sum end end L, C = 2.times.map { gets.chomp.split.map(&:to_i) } puts solve