loop do
  n,m = gets.chomp.split.map(&:to_i)
  break if (n|m) == 0
  targets = []
  n.times do
    targets << gets.chomp.to_i
  end
  targets.sort!{ |a,b| b <=> a }

  rest = m
  high_score = 0
  count = 4
  targets.each do |target|
    break if count == 0

    num = (rest / target)
    next if num == 0

    hit = 0
    if num <= count
      hit = num
      count -= num
    else
      hit = count
      count = 0
    end

    score = target * hit
    high_score += score
    rest = rest - score
  end
  puts high_score
end