program kuaizi;
var
n,z,k,i,j,daiti,t:integer;
a:array[1..100]of integer;
begin
assign (input,'chop.in');
reset (input);
assign (output,'chop.out');
rewrite (output);
readln (n,k);
for i:=1 to n do
read (a[i]);
for i:=1 to n-1 do
for j:=i+1 to n do
if a[i]>a[j] then
begin
daiti:=a[i];
a[i]:=a[j];
a[j]:=daiti
end;
for t:=1 to k+3 do
z:=z+sqr(a[2*t-1]-a[2*t]);
if 2*(k+3)<n then
write ('-1')
else write (z);
close (input);
close (output)
end.