program busses;
const
fin='busses.in';
fou='busses.out';
var
f:array[0..1000000]of longint;
a:array[1..10]of longint;
i,j,n:longint;
f1,f2:text;
begin
assign(f1,fin);
assign(f2,fou);
reset(f1);
rewrite(f2);
for i:=1 to 10 do
read(f1,a[i]);
read(f1,n);
for i:=1 to n do
f[i]:=200000000;
for i:=1 to n do
for j:=1 to 10 do
if i-j>=0 then
if f[i]>f[i-j]+a[j] then f[i]:=f[i-j]+a[j];
write(f2,f[n]);
close(f1); close(f2);
end.