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