program zadatak;
var
 n,x,max,min,z,p:longint;
 i:integer;

begin
read(x,n);
  read(p);
  max:=p;
  min:=p;
 x:=x-1;
for i:=1 to x do begin
   read(p);
   if (max<p) then max:=p;
   if (min>p) then min:=p;
  end;

if n>=max then begin
  write(n-min);
end else if (n>=min) then begin
   z:=abs(abs(n)-abs(min));
   write(max-min+z);
end else begin
   write(max-n);
end;


end.