program main
	implicit none
	integer(8) :: Q, H, S, D, N
	
	read(*, *) Q, H, S, D
	read(*, *) N
	
	if(mod(N,2) == 0) then
		Q = 8*Q
		H = 4*H
		S = 2*S
		write(*, *) N/2 * min(Q,H,S,D)
	else
		Q = min(2*H,4*Q,S)
		write(*, *) min(N*Q,N/2 * D+Q)
	end if
end program main
; ModuleID = 'FIRModule'
source_filename = "FIRModule"
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"

@_QQcl.341c6651a59e83b63da90069489b4cd8 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_6970/source.f\00"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

define void @_QQmain() local_unnamed_addr {
  %1 = alloca i64, align 8
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.341c6651a59e83b63da90069489b4cd8, i32 5)
  %7 = call i1 @_FortranAioInputInteger(ptr %6, ptr nonnull %4, i32 8)
  %8 = call i1 @_FortranAioInputInteger(ptr %6, ptr nonnull %2, i32 8)
  %9 = call i1 @_FortranAioInputInteger(ptr %6, ptr nonnull %5, i32 8)
  %10 = call i1 @_FortranAioInputInteger(ptr %6, ptr nonnull %1, i32 8)
  %11 = call i32 @_FortranAioEndIoStatement(ptr %6)
  %12 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.341c6651a59e83b63da90069489b4cd8, i32 6)
  %13 = call i1 @_FortranAioInputInteger(ptr %12, ptr nonnull %3, i32 8)
  %14 = call i32 @_FortranAioEndIoStatement(ptr %12)
  %15 = load i64, ptr %3, align 8, !tbaa !3
  %16 = and i64 %15, 1
  %17 = icmp eq i64 %16, 0
  br i1 %17, label %18, label %37

18:                                               ; preds = %0
  %19 = load i64, ptr %4, align 8, !tbaa !3
  %20 = shl i64 %19, 3
  store i64 %20, ptr %4, align 8, !tbaa !3
  %21 = load i64, ptr %2, align 8, !tbaa !3
  %22 = shl i64 %21, 2
  store i64 %22, ptr %2, align 8, !tbaa !3
  %23 = load i64, ptr %5, align 8, !tbaa !3
  %24 = shl i64 %23, 1
  store i64 %24, ptr %5, align 8, !tbaa !3
  %25 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.341c6651a59e83b63da90069489b4cd8, i32 12)
  %26 = load i64, ptr %3, align 8, !tbaa !3
  %27 = sdiv i64 %26, 2
  %28 = load i64, ptr %4, align 8, !tbaa !3
  %29 = load i64, ptr %2, align 8, !tbaa !3
  %30 = load i64, ptr %5, align 8, !tbaa !3
  %31 = load i64, ptr %1, align 8, !tbaa !3
  %32 = call i64 @llvm.smin.i64(i64 %28, i64 %29)
  %33 = call i64 @llvm.smin.i64(i64 %32, i64 %30)
  %34 = call i64 @llvm.smin.i64(i64 %33, i64 %31)
  %35 = mul i64 %34, %27
  %36 = call i1 @_FortranAioOutputInteger64(ptr %25, i64 %35)
  br label %55

37:                                               ; preds = %0
  %38 = load i64, ptr %2, align 8, !tbaa !3
  %39 = shl i64 %38, 1
  %40 = load i64, ptr %4, align 8, !tbaa !3
  %41 = shl i64 %40, 2
  %42 = load i64, ptr %5, align 8, !tbaa !3
  %43 = call i64 @llvm.smin.i64(i64 %39, i64 %41)
  %44 = call i64 @llvm.smin.i64(i64 %43, i64 %42)
  store i64 %44, ptr %4, align 8, !tbaa !3
  %45 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.341c6651a59e83b63da90069489b4cd8, i32 15)
  %46 = load i64, ptr %3, align 8, !tbaa !3
  %47 = load i64, ptr %4, align 8, !tbaa !3
  %48 = mul i64 %47, %46
  %49 = sdiv i64 %46, 2
  %50 = load i64, ptr %1, align 8, !tbaa !3
  %51 = mul i64 %50, %49
  %52 = add i64 %51, %47
  %53 = call i64 @llvm.smin.i64(i64 %48, i64 %52)
  %54 = call i1 @_FortranAioOutputInteger64(ptr %45, i64 %53)
  br label %55

55:                                               ; preds = %18, %37
  %.sink = phi ptr [ %25, %18 ], [ %45, %37 ]
  %56 = call i32 @_FortranAioEndIoStatement(ptr %.sink)
  ret void
}

declare ptr @_FortranAioBeginExternalListInput(i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioInputInteger(ptr, ptr, i32) local_unnamed_addr

declare i32 @_FortranAioEndIoStatement(ptr) local_unnamed_addr

declare ptr @_FortranAioBeginExternalListOutput(i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputInteger64(ptr, i64) local_unnamed_addr

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

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!llvm.module.flags = !{!0, !1, !2}

!0 = !{i32 2, !"Debug Info Version", i32 3}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{!4, !4, i64 0}
!4 = !{!"any data access", !5, i64 0}
!5 = !{!"any access", !6, i64 0}
!6 = !{!"Flang Type TBAA Root"}
