var a: array [1..100000] of integer;
   i,n,k,buf,res:longint;

begin
   assign(input,'A.in');
   reset(input);
   assign(output,'A.out');
   rewrite(output);

   readln(n,k);

   fillchar(a,sizeof(a),0);

   while not eoln(input) do begin
      read(buf);
      inc(a[buf]);
   end;

   buf:=n-k;
   i:=100000;
   res:=0;

   while buf>0 do begin
      if a[i]>0 then begin

         res:=res+i;
         dec(buf);
         dec(a[i]);
      end;
      if a[i]=0 then dec(i);
   end;

   {setlength(a,n-k+1);
   for i:=1 to n-k do read(a[i]);
   for i:=1 to n-k do
      for j:=1 to n-k-1 do
         if a[j+1]<a[j] then begin
            buf:=a[j];
            a[j]:=a[j+1];
            a[j+1]:=buf;
         end;

   for i:=n-k+1 to n do begin
        read(buf);
        if buf>a[1] then begin

           a[1]:=buf;
           for j:=1 to n-k-1 do begin
              buf:=a[j];
              a[j]:=a[j+1];
              a[j+1]:=buf;
           end;
        end;
   end;
   res:=0;
   for i:=1 to n-k do res:=res+a[i];
   }
   write(res);

   close(output);
end.
