program Project1; {$APPTYPE CONSOLE} uses SysUtils; type mas=array[1..100000]of longint; procedure swap(var a,b:longint); var x:longint; begin x:=a; a:=b; b:=x; end; function partition(var A:mas;p,r:longint):longint; var x,i,j:longint; begin x:=A[r]; i:=p-1; for j:=p to r-1 do if A[j]<=x then begin inc(i); swap(A[i],A[j]); end; swap(A[i+1],A[r]); partition:=i+1; end; procedure qsort(var A:mas;p,r:longint); var q:longint; begin if pb then max:=a else max:=b; end; var n,k,i,min,ri,l,kn,res:longint; d,r:mas; begin res:=0; assign(input,'holy.in'); reset(input); read(n,k); for i:=1 to n do begin read(d[i]); end; close(input); qsort(d,1,n); min:=1; {vmax:=1; } for i:=2 to n do begin r[i-1]:=abs(d[i]-d[i-1]); if r[i-1]k do begin if ((r[l-1]>=r[ri])and(rir[vmax] then vmax:=ri-1;} end else if l>1 then begin dec(l); {min:=l; if r[l]r[vmax]then vmax:=l} end; inc(kn); end; {res:=d[vmax]-d[min]; } res:=d[ri]-d[l]; assign(output,'holy.out'); rewrite(output); writeln(res); close(output); end.