var a,b:array[1..10000]of longint;
i,s,t,n,m,k,x:longint;
begin
readln(n);
readln(k);
readln(a[1]);
writeln(a[1]);
b[1]:=1;
s:=1;
t:=1;
for i:=2 to n do
begin
readln(x);
while (a[t]>x) and (t>0) do
t:=t-1;
t:=t+1;
a[t]:=x;
b[t]:=i;
while b[s]<=i-k do
s:=s+1;
writeln(a[s]);
end;
end.
i,s,t,n,m,k,x:longint;
begin
readln(n);
readln(k);
readln(a[1]);
writeln(a[1]);
b[1]:=1;
s:=1;
t:=1;
for i:=2 to n do
begin
readln(x);
while (a[t]>x) and (t>0) do
t:=t-1;
t:=t+1;
a[t]:=x;
b[t]:=i;
while b[s]<=i-k do
s:=s+1;
writeln(a[s]);
end;
end.