#import <stdio.h>
#import <limits.h>
#define INT long long
#define MIN(a,b) ((a)<(b)?(a):(b))
INT Q,H,S,D,N;
INT f(INT y, INT z, INT w){
    if (y+2*z+4*w>2*N) {
        return LONG_MAX;
    }
    return 4*Q*N + (H-2*Q)*y + (S-4*Q)*z + (D-8*Q)*w;
}
int main(){
    scanf("%lld %lld %lld %lld %lld",&Q,&H,&S,&D,&N);
    INT min = f(0,0,0);
    min = MIN(min, f(2*N,0,0));
    min = MIN(min, f(2*N,0,1));
    min = MIN(min, f(2*N,1,0));
    min = MIN(min, f(0,N,0));
    min = MIN(min, f(1,N,0));
    min = MIN(min, f(0,N,1));
    min = MIN(min, f(0,0,N/2));
    min = MIN(min, f(1,0,N/2));
    min = MIN(min, f(2,0,N/2));
    min = MIN(min, f(3,0,N/2));
    min = MIN(min, f(0,1,N/2));
    min = MIN(min, f(0,2,N/2));
    min = MIN(min, f(0,3,N/2));
    min = MIN(min, f(1,1,N/2));
    min = MIN(min, f(1,2,N/2));
    min = MIN(min, f(2,1,N/2));
    min = MIN(min, f(2,2,N/2));
    printf("%lld",min);
}

; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/ObjectiveC/Source_722/source.m'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/ObjectiveC/Source_722/source.m"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"

@N = dso_local global i64 0, align 8
@Q = dso_local global i64 0, align 8
@H = dso_local global i64 0, align 8
@S = dso_local global i64 0, align 8
@D = dso_local global i64 0, align 8
@.str = private unnamed_addr constant [25 x i8] c"%lld %lld %lld %lld %lld\00", align 1
@.str.1 = private unnamed_addr constant [5 x i8] c"%lld\00", align 1

; Function Attrs: minsize mustprogress nofree norecurse nosync nounwind optsize willreturn memory(read, argmem: none, inaccessiblemem: none) uwtable
define dso_local i64 @f(i64 noundef %y, i64 noundef %z, i64 noundef %w) local_unnamed_addr #0 {
entry:
  %mul = shl nsw i64 %z, 1
  %add = add nsw i64 %mul, %y
  %mul1 = shl nsw i64 %w, 2
  %add2 = add nsw i64 %add, %mul1
  %0 = load i64, ptr @N, align 8, !tbaa !5
  %mul3 = shl nsw i64 %0, 1
  %cmp = icmp sgt i64 %add2, %mul3
  br i1 %cmp, label %return, label %if.end

if.end:                                           ; preds = %entry
  %1 = load i64, ptr @Q, align 8, !tbaa !5
  %mul4 = shl nsw i64 %1, 2
  %mul5 = mul nsw i64 %mul4, %0
  %2 = load i64, ptr @H, align 8, !tbaa !5
  %mul6 = shl nsw i64 %1, 1
  %sub = sub nsw i64 %2, %mul6
  %mul7 = mul nsw i64 %sub, %y
  %add8 = add nsw i64 %mul7, %mul5
  %3 = load i64, ptr @S, align 8, !tbaa !5
  %sub10 = sub nsw i64 %3, %mul4
  %mul11 = mul nsw i64 %sub10, %z
  %add12 = add nsw i64 %add8, %mul11
  %4 = load i64, ptr @D, align 8, !tbaa !5
  %mul13 = shl nsw i64 %1, 3
  %sub14 = sub nsw i64 %4, %mul13
  %mul15 = mul nsw i64 %sub14, %w
  %add16 = add nsw i64 %add12, %mul15
  br label %return

return:                                           ; preds = %entry, %if.end
  %retval.0 = phi i64 [ %add16, %if.end ], [ 9223372036854775807, %entry ]
  ret i64 %retval.0
}

; Function Attrs: minsize nofree nounwind optsize uwtable
define dso_local i32 @main() local_unnamed_addr #1 {
entry:
  %call = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @Q, ptr noundef nonnull @H, ptr noundef nonnull @S, ptr noundef nonnull @D, ptr noundef nonnull @N) #4
  %call1 = tail call i64 @f(i64 noundef 0, i64 noundef 0, i64 noundef 0) #4
  %0 = load i64, ptr @N, align 8, !tbaa !5
  %mul = shl nsw i64 %0, 1
  %call2 = tail call i64 @f(i64 noundef %mul, i64 noundef 0, i64 noundef 0) #4
  %spec.select = tail call i64 @llvm.smin.i64(i64 %call1, i64 %call2)
  %call6 = tail call i64 @f(i64 noundef %mul, i64 noundef 0, i64 noundef 1) #4
  %cond13 = tail call i64 @llvm.smin.i64(i64 %spec.select, i64 %call6)
  %call15 = tail call i64 @f(i64 noundef %mul, i64 noundef 1, i64 noundef 0) #4
  %cond22 = tail call i64 @llvm.smin.i64(i64 %cond13, i64 %call15)
  %call23 = tail call i64 @f(i64 noundef 0, i64 noundef %0, i64 noundef 0) #4
  %cond29 = tail call i64 @llvm.smin.i64(i64 %cond22, i64 %call23)
  %call30 = tail call i64 @f(i64 noundef 1, i64 noundef %0, i64 noundef 0) #4
  %cond36 = tail call i64 @llvm.smin.i64(i64 %cond29, i64 %call30)
  %call37 = tail call i64 @f(i64 noundef 0, i64 noundef %0, i64 noundef 1) #4
  %cond43 = tail call i64 @llvm.smin.i64(i64 %cond36, i64 %call37)
  %div = sdiv i64 %0, 2
  %call44 = tail call i64 @f(i64 noundef 0, i64 noundef 0, i64 noundef %div) #4
  %cond51 = tail call i64 @llvm.smin.i64(i64 %cond43, i64 %call44)
  %call53 = tail call i64 @f(i64 noundef 1, i64 noundef 0, i64 noundef %div) #4
  %cond60 = tail call i64 @llvm.smin.i64(i64 %cond51, i64 %call53)
  %call62 = tail call i64 @f(i64 noundef 2, i64 noundef 0, i64 noundef %div) #4
  %cond69 = tail call i64 @llvm.smin.i64(i64 %cond60, i64 %call62)
  %call71 = tail call i64 @f(i64 noundef 3, i64 noundef 0, i64 noundef %div) #4
  %cond78 = tail call i64 @llvm.smin.i64(i64 %cond69, i64 %call71)
  %call80 = tail call i64 @f(i64 noundef 0, i64 noundef 1, i64 noundef %div) #4
  %cond87 = tail call i64 @llvm.smin.i64(i64 %cond78, i64 %call80)
  %call89 = tail call i64 @f(i64 noundef 0, i64 noundef 2, i64 noundef %div) #4
  %cond96 = tail call i64 @llvm.smin.i64(i64 %cond87, i64 %call89)
  %call98 = tail call i64 @f(i64 noundef 0, i64 noundef 3, i64 noundef %div) #4
  %cond105 = tail call i64 @llvm.smin.i64(i64 %cond96, i64 %call98)
  %call107 = tail call i64 @f(i64 noundef 1, i64 noundef 1, i64 noundef %div) #4
  %cond114 = tail call i64 @llvm.smin.i64(i64 %cond105, i64 %call107)
  %call116 = tail call i64 @f(i64 noundef 1, i64 noundef 2, i64 noundef %div) #4
  %cond123 = tail call i64 @llvm.smin.i64(i64 %cond114, i64 %call116)
  %call125 = tail call i64 @f(i64 noundef 2, i64 noundef 1, i64 noundef %div) #4
  %cond132 = tail call i64 @llvm.smin.i64(i64 %cond123, i64 %call125)
  %call134 = tail call i64 @f(i64 noundef 2, i64 noundef 2, i64 noundef %div) #4
  %cond141 = tail call i64 @llvm.smin.i64(i64 %cond132, i64 %call134)
  %call142 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %cond141) #4
  ret i32 0
}

; Function Attrs: minsize nofree nounwind optsize
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: minsize nofree nounwind optsize
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.smin.i64(i64, i64) #3

attributes #0 = { minsize mustprogress nofree norecurse nosync nounwind optsize willreturn memory(read, argmem: none, inaccessiblemem: none) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { minsize nofree nounwind optsize uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { minsize nofree nounwind optsize "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { minsize optsize }

!llvm.linker.options = !{}
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
