program xmz;
var
f1,f2:text;
n,k,a,b,sh,min,mm,t,ss:longint;
x:array[1..100]of longint;
y:array[1..100]of boolean;
s:array[1..100]of longint;
begin
assign(f1,'chop.in');assign(f2,'chop.out');
reset(f1);rewrite(f2);
read(f1,n,k);
if n<(k+3)*2 then write(f2,'NO') else
begin
for a:=1 to n do
read(f1,x[a]);
for a:=1 to n-1 do
if not(y[a]) then
begin
min:=99999999;
for b:=a+1 to n do
if (not(y[b])) then
if sqr(x[a]-x[b])<min then begin min:=sqr(x[a]-x[b]);mm:=b;end;
inc(sh);
s[sh]:=sqr(x[a]-x[mm]);y[a]:=true;y[mm]:=true;
end;
for a:=1 to k+3 do
for b:=a+1 to sh do
if s[a]>s[b] then begin t:=x[a];x[a]:=x[b];x[b]:=t;end;
for a:=1 to k+3 do
ss:=ss+s[a];
write(f2,ss);
end;
close(f1);close(f2);
end.