program busses;
var
dp:array [1..100000] of longint;
tmp,min,i,j,len:longint;
begin
fillchar (dp,sizeof(dp),0);
assign (input,'busses.in');
assign (output,'busses.out');
reset (input);
read (dp[1]);
rewrite (output);
for i:=2 to 10 do begin
read (tmp);
min:=maxlongint;
for j:=1 to i-1 do if min>dp[i-j]+dp[j] then min:=dp[i-j]+dp[j];
if min<tmp then dp[i]:=min else dp[i]:=tmp;
end;
readln (len);
for i:=11 to len do begin
min:=maxlongint;
for j:=1 to 10 do if dp[i-j]+dp[j]<min then min:=dp[i-j]+dp[j];
dp[i]:=min;
end;
close (input);
writeln (dp[len]);
close (output);
end.