var f:array[0..110,0..110]of longint;
a:array[0..110]of longint;
n,m,i,j,k,p:longint;
procedure init;
begin
readln(m,n);
for i:=1 to n do read(a[i]);
for i:=1 to n do
for j:=i+1 to n do if a[i]>a[j] then
begin
k:=a[i]; a[i]:=a[j]; a[j]:=k;
end;
a[0]:=0; a[n+1]:=m+1;
for i:=1 to n do f[i,i]:=a[i+1]-a[i-1]-2;
end;
function min(x,y:longint):longint;
begin
if x>y then exit(y) else exit(x);
end;
procedure work;
begin
for j:=1 to n do
for i:=1 to n-j+1 do
begin
m:=i+j; f[i,m]:=maxlongint; p:=a[m+1]-a[i-1]-2;
for k:=i to m do f[i,m]:=min(f[i,m],f[i,k-1]+f[k+1,m]+p);
end;
writeln(f[1,n]);
end;
begin
assign(input,'prison.in');reset(input);
assign(output,'prison.out');rewrite(output);
init;
work;
close(input); close(output);
end.