program chefei;
var
i,j,n,min:longint;
a,f:array[0..10000]of integer;
begin
assign (input,'busses.in');
reset (input);
assign (output,'busses.out');
rewrite (output);
for i:=1 to 10 do
read (a[i]);
readln;
readln (n);
f[1]:=a[1];
for i:=2 to n do
begin
min:=99999999;
for j:=i-10 to i-1 do
if j>=0 then
if f[j]+a[i-j]<min then
min:=f[j]+a[i-j];
f[i]:=min
end;
writeln (f[n]);
close (input);
close (output)
end.