import java.util.*;
import java.util.concurrent.LinkedBlockingDeque;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int arrayLength = in.nextInt();

        Deque<Integer> indexQueue = new LinkedBlockingDeque<>();
        int maxLength = in.nextInt();
        int[] array = new int[arrayLength];
    
        for (int i = 0; i < array.length; i++) {
            array[i] = in.nextInt();
            int preIndex = i - maxLength;
            if (indexQueue.size() > 0) {

                if (indexQueue.peekFirst() == preIndex) {
                    indexQueue.pollFirst();
                }
            }

            if (indexQueue.size() == 0) {
                indexQueue.add(i);
            } else {
                while (true) {
                    if (indexQueue.size() == 0) {
                        indexQueue.addLast(i);
                        break;
                    }

                    int lastIndex = indexQueue.peekLast();
                    int value = array[lastIndex];
                    if (array[i] <= value) {
                        indexQueue.addLast(i);
                        break;
                    } else {
                        indexQueue.pollLast();
                    }

                }
            }

            if (i -maxLength + 1 >= 0) {
                System.out.print(array[indexQueue.peekFirst()] + " ");
            }
        }
    }
}