program ex1029_2;
var
len:array[1..10] of longint;
s,tm,i,x:longint;
f:array[0..10] of longint;
begin
assign(input,'busses.in');
assign(output,'busses.out');
reset(input); rewrite(output);
for i:=1 to 10 do
read(len[i]);
readln(s);
for i:=1 to 10 do f[i]:=maxlongint;
for i:=1 to s do
begin
tm:=maxlongint;
for x:=1 to 10 do
begin
if x>i then break;
if f[(i-x+11) mod 11]+len[x]<tm
then tm:=f[(i-x+11) mod 11]+len[x];
end;
f[i mod 11]:=tm
end;
writeln(f[s mod 11]);
close(input); close(output);
end.