program C0488;
var p,q,i,min:longint;
S:array[1..100] of longint;
v:array[1..100] of boolean;
g:array[1..1000] of boolean;
procedure Search(top,ans:longint);
var i,j,temp:longint;
begin
if top>q then begin
if ans<min then min:=ans;
end
else
temp:=ans;
for i:=1 to q do
if v[i] then begin
v[i]:=false;
for j:=S[i]-1 downto 1 do
if g[j] then inc(ans) else break;
for j:=S[i]+1 to p do
if g[j] then inc(ans) else break;
g[S[i]]:=false;
Search(top+1,ans);
g[S[i]]:=true;
ans:=temp;
v[i]:=true;
end;
end;
begin
assign(input,'prison.in');
reset(input);
assign(output,'prison.out');
rewrite(output);
readln(p,q);
for i:=1 to q do read(S[i]);
readln;
min:=maxlongint;
fillchar(v,sizeof(v),true);
fillchar(g,sizeof(g),true);
Search(1,0);
writeln(min);
close(input);
close(output);
end.