var
min,p,q:longint;
a:array[0..2000]of longint;
f:array[0..2000]of boolean;
function now(k:longint):longint;
var
i,j:longint;
begin
i:=k;
j:=k;
while not f[i-1] do dec(i);
while not f[j+1] do inc(j);
exit(j-i);
end;
procedure go(k,m:longint);
var
i:longint;
begin
if k=q+1 then
begin
if m<min then min:=m;
exit;
end;
for i:=1 to q do
if not f[a[i]] then
begin
f[a[i]]:=true;
go(k+1,m+now(a[i]));
f[a[i]]:=false;
end;
end;
procedure init;
var
i:longint;
begin
assign(input,'prison.in'); reset(input;
assign(output,'prison.out'); rewrite(output);
readln(p,q);
for i:=1 to q do read(a[i]);
f[0]:=true;
f[p+1]:=true;
min:=maxlongint;
end;
begin
init;
go(1,0);
writeln(min);
close(input);
close(output);
end.