let () =
  let q, h, s, d = Scanf.scanf "%d %d %d %d\n" (fun q h s d -> q, h, s, d) in
  let n = Scanf.scanf "%d\n" (fun n -> n) in
  [(1, q); (2, h); (4, s); (8, d)]
  |> List.sort (fun (size, price) (size', price') -> compare (price * size') (price' * size))
  |> List.fold_left (fun (acc, n) (size, price) -> (acc + n / size * price, n mod size)) (0, 4 * n)
  |> fst
  |> Printf.printf "%d\n"