uses
  SysUtils;

var
  i,j:longint;
  n,k,sum,p:longint;
  a:array[1..1000000]of longint;
  ves:array[1..100000]of longint;
begin
assign(input,'a.in');
reset(input);
read(n,k);
for i:=1 to n do
  read(a[i]);
close(input);

for i:=1 to n do
begin
    inc(ves[a[i]]);
end;
p:=100000;
for i:=1 to p do
begin
    if ves[i]=1 then
    begin
         ves[i]:=0;
         dec(k);
    end;
    if ves[i]>1 then
    begin
        dec(ves[i]);
        dec(k);
    end;
    if k=0 then break;
end;
for i:=1 to p do
if  ves[i]<>0 then sum:=sum+ves[i]*i;
assign(output,'a.out');
rewrite(output);
write(sum);
close(output);
end.

