program upoz;
var
a,b,c,i,s,j,g,z,f,v:longint;
d:array[1..100] of longint;
begin
read(a);
read(b);
j:=1;
g:=0;
z:=0;
v:=0;
for i:=1 to a do begin
read (c);
if g=0 then begin
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;
g:=1;
end 
else begin
d[j]:=b;
s:=j;
j:=j+1;
d[j]:=c;
j:=j+1;
g:=1;
end;
end 
else begin
d[j]:=c;
j:=j+1;
end;
end;
for i:=1 to j-1 do
if d[i]=b then
v:=1;
if v=0 then begin
d[j]:=b;
s:=j;
end
else j:=j-1;
f:=d[j];
for i:=j-1 downto 1 do begin
if (f>0) and (d[i]<0) then begin
z:=z+(abs(f)+abs(d[i]));
end
else 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;
if (s<>1) and (s<>j) then begin
f:=d[s];
for i:=s-1 downto 1 do begin
if (f>0) and (d[i]<0) then begin
z:=z+(abs(f)+abs(d[i]));
end
else 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;
end;
write(z);
end.