'use strict'

function Main(input) {
  const inputs = input.split('\n');
  const prices = inputs[0].split(' ');
  const priceTable = [];
  priceTable.push({ q: 0.25, price: prices[0] / 0.25, index: 0 });
  priceTable.push({ q: 0.5, price: prices[1] / 0.5, index: 1 });
  priceTable.push({ q: 1, price: prices[2], index: 2 });
  priceTable.push({ q: 2, price: prices[3] / 2, index: 3 });
  
  priceTable.sort((o1, o2) => o1.price - o2.price);
  
  let quantity = inputs[1];
  let sum = 0;
  let i = 0;
  while(quantity > 0) {
      const p = priceTable[i];
      if (quantity - p.q >= 0) {
          sum += parseInt(prices[p.index], 10);
          quantity -= p.q;
      } else {
          i++;
      }
      if (i > priceTable.length) break;
  }
  console.log(sum);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
