#include <stdio.h>
int main()
{
	int n,l,i,minSig=100000000,minR=10000000,bandera=0;
	scanf("%d%d",&n,&l);
	int ar[n], j=l-1;
	for(i = 0; i < n; i++)
	{
		//if(i == x) x += l -1; 
	 	scanf("%d",&ar[i]);
	 	if(ar[i] < minR)
		{ 
			minR=ar[i];
			if(bandera==1) minSig = minR;
		}
	 	bandera = 1;
		if(i == j)
		{
			printf("%d ", minR);
			minR= minSig;
		//	bandera = 0;
			j++;
		}
	}
	
	return 0;
}
