program ex;
type
ss=array[1..500]of integer;
var
a:ss;
n:integer;
f1,f2:text;
procedure init;
var
i:integer;
begin
assign(f1,'busses.in');
assign(f2,'busses.out');
reset(f1);
rewrite(f2);
for i:=1 to 10 do read(f1,a[i]);
readln(f1,n);
for i:=11 to n do a[i]:=maxint;
close(f1);
end;
procedure main;
var
i,j,k:integer;
begin
k:=0;
for i:=2 to n do
begin
k:=i div 2;
for j:=1 to k do
if a[j]+a[i-j]<a[i] then
a[i]:=a[j]+a[i-j];
end;
writeln(f2,a[n]);
end;
begin
init;
main;
close(f2);
end.