program A;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
 colvoF, colvoA: integer;
 data: array of integer;
 answer: integer;

procedure Mozg;
var
 i,t: integer;
 min,max: integer;
 temp: integer;
begin

 for t:=0 to colvoA-2 do
  for i:=0 to colvoA-2 do
  if data[i]>data[i+1] then begin
   temp:=data[i];
   data[i]:=data[i+1];
   data[i+1]:=temp;
  end;

 if colvoA=colvoF then answer:=0 else begin
  for i:=colvoF to colvoA-1 do inc(answer,data[i]);
 end;
end;

procedure LoadData;
var
 f: textfile;
 i: integer;
begin
 assignfile(f,'A.in');
 reset(f);
 readln(f,colvoA,colvoF);
 setLength(data,colvoA);
 for i:=0 to  colvoA-1 do
  read(f,data[i]);

 closefile(f);
end;

procedure WriteData;
var
 f: textfile;
 i,t: integer;
begin
 assignfile(f,'A.out');
 rewrite(f);
 WriteLn(f,answer);

 closefile(f);
end;


begin
 LoadData;
 Mozg;
 WriteData;

end.
