program busses;
var
f:array [1..10] of byte;
dp:array [1..320000] of dword;
n,i:word;
procedure go(n:dword);
var
i:dword;
tmp:dword;
begin
if n<>1 then begin
tmp:=maxint;
for i:=1 to (n-1) div 2+1 do begin
if dp[i]=0 then go(i);
if dp[n-i]=0 then go(n-i);
if dp[i]+dp[n-i]<tmp then tmp:=dp[i]+dp[n-i];
end;
if n<=10 then if tmp>f[n] then tmp:=f[n];
dp[n]:=tmp;
end;
end;
begin
fillchar (dp,sizeof(dp),0);
assign (input,'busses.in');
reset (input);
for i:=1 to 10 do read (f[i]);
readln (n);
close (input);
assign (output,'busses.out');
rewrite (output);
dp[1]:=f[1];go(n);
writeln (dp[n]);
close (output);
end.