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