{$A+,B-,D+,E+,F+,G-,I+,L+,N+,O-,P-,Q+,R+,S+,T+,V+,X+,Y+}
{ $DEFINE init_ECHO}
{$M 65520,0,655360}
VAR
n,k,m,delta,max,maxi,i,j: longint;
a: array[1..1000000] of int64;
BEGIN
assign(input,'A.in');
reset(input);
assign(output,'A.out');
rewrite(output);
read(input,n);
read(input);
read(input,k);
readln(input);
 {$ifdef init_ECHO} writeln('n= ',n,'k= ',k); {$endif}
for i:=1 to n do
 begin read(input,a[i]); {read(input);} {$ifdef init_ECHO}write(a[i],', ') {$endif} end;
m:=0;
delta:=n-k;

for j:=1 to delta do begin
  max:=a[1]; maxi:=1;
 for i:=1 to n do if a[i]>max then begin maxi:=i; max:=a[i]; end;

 m:=m+max; a[maxi]:=0;
  {$ifdef init_ECHO} writeln('m= ',m,'max= ',max); {$endif}
 end;

write(output,m);
close(input);
close(output);
END.
