program cch(input,output);
var
a:array[1..20] of longint;
ans,i,n,ch,b:longint;
procedure search(k:integer);
var
i:integer;
begin
if ch>=b then
if (ch-b)<ans then ans:=ch-b
else exit;
for i:=k+1 to n do
begin
inc(ch,a[i]);
search(i);
dec(ch,a[i]);
end;
end;
begin
assign(input,'shelf2.in');
assign(output,'shelf2.out');
reset(input);
rewrite(output);
readln(n,b);
for i:=1 to n do readln(a[i]);
ch:=0; ans:=maxint;
search(0);
write(ans);
close(input);
close(output);
end.