program prison;
var
p,q,i,ans,t,j,k:longint;
sz:array[0..1001]of boolean;
s:array[1..100]of longint;
s2:array[1..100]of longint;
hx:array[1..100]of boolean;
procedure find(c:longint);
var
i:longint;
begin
if c>q then begin
t:=0;
fillchar(sz,sizeof(sz),true);
for j:=1 to q do
begin
k:=s2[j]-1;
while (k>=1)and(sz[k]) do
begin
k:=k-1;
t:=t+1;
end;
k:=s2[j]+1;
while (k<=p)and(sz[k]) do
begin
k:=k+1;
t:=t+1;
end;
sz[s2[j]]:=false;
end;
if t<ans then ans:=t;
end
else begin
for i:=1 to q do
if hx[i] then begin
hx[i]:=false;
s2[c]:=s[i];
find(c+1);
hx[i]:=true;
end;
end;
end;
begin
assign(input,'prison.in');
assign(output,'prison.out');
reset(input);
rewrite(output);
readln(p,q);
for i:=1 to q do
begin
read(s[i]);
end;
fillchar(sz,sizeof(sz),true);
ans:=2000000000;
t:=0;
fillchar(hx,sizeof(hx),true);
find(1);
writeln(ans);
close(input);
close(output);
end.