// Try AtCoder
// author: Leonardone @ NEETSDKASU
import std.algorithm  : min;
import std.stdio      : readln, writeln;
import std.string     : chomp;
import std.array      : split;
import std.conv       : to;

auto gets(T)() {
    return readln.chomp;
}
auto getVals(T)() {
    return readln.chomp.split.to!(T[]);
}

void main() {
    auto xs = getVals!long;
    auto n = getVals!long[0];
    n <<= 2;
    auto a = n / 8, ar = n % 8;
    auto b = ar / 4, br = ar % 4;
    auto c = br / 2;
    auto d = br % 2;
    auto ans = d * xs[0];
    ans += min(c * 2 * xs[0], c * xs[1]);
    ans += min(b * 4 * xs[0], b * 2 * xs[1], b * xs[2]);
    ans += min(a * 8 * xs[0], a * 4 * xs[1], a * 2 * xs[2], a * xs[3]);
    writeln(ans);
}