Program hotrotinhoc;
const fi='lientiep.inp';
fo='lientiep.out';
var f: text;
a,b: array[1..32000] of integer;
k,i,n,max,vtd,vtc: integer;
procedure ip;
begin
assign(f,fi);
reset(f);
readln(f,n,k);
for i:=1 to n do read(f,a[i]);
close(f);
end;
procedure out;
begin
assign(f,fo);
rewrite(f);
max:=0; i:=1;
while i<=n do
begin
j:=i;
t:=a[i];
while (a[j]<a[j+1]) and (j<=n) do
begin
inc(j);
t:=t+a[j];
end;
if t>max then
begin
max:=t;
vtd:=i;
vtc:=j;
end;
i:=j+1;
end;
for i:=vtc downto vtd do
begin
inc(d1);
b[d1]:=a[i];
end;
for i:= k dowto 1 do
write(f,b[i],' ');
close(f);
end;
begin
ip;
out;
end.