program normal;
var
a,b,c,i,s,j,g,z,f:integer;
d:array[1..100] of integer;
begin
read(a);
read(b);
j:=1;
g:=0;
z:=0;
for i:=1 to a do begin
read (c);
if c<b then begin
d[j]:=c;
j:=j+1;
end else
if c=b then begin
d[j]:=c;
j:=j+1;
d[j]:=b;
s:=j;
j:=j+1;
end else begin
if g=0 then begin
d[j]:=b;
s:=j;
j:=j+1;
d[j]:=c;
j:=j+1;
g:=1;
end else begin
d[j]:=c;
j:=j+1;
end;
end;
end;
f:=d[j-1];
for i:=j-2 downto 1 do begin
if abs(d[i]) > abs(f) then
z:=z+(abs(d[i])-abs(f))
else
if abs(d[i]) = abs(f) then
z:=z+2*abs(f)
else
z:=z+(abs(f)-abs(d[i]));
f:=d[i];
end;
if (s<>1) and (s<>j-1) then begin
f:=d[s];
for i:=s-1 downto 1 do begin
if abs(d[i]) > abs(f) then
z:=z+(abs(d[i])-abs(f))
else
if abs(d[i]) = abs(f) then
z:=z+2*abs(f)
else
z:=z+(abs(f)-abs(d[i]));
f:=d[i];
end;
end;
write(z);
end.