// Sliding Minimum Elements
#include <iostream>
#include <stdlib.h>
#include <math.h>
#define INF pow(2, 31) - 1
using namespace std;
int n, l, *D;

void initRMQ(int *data){
    //global D, n
    int i, k, size = 1;
    while(size < l) size *= 2;
    //cout << size << endl;;
    D = (int *)malloc((2*size - 1)*sizeof(int));
    //cout << sizeof(D) << endl;
    //D = (int *)malloc(size_t(sizeof(char)));
    //cout << sizeof(int) << endl;
    //cout << sizeof((int *)malloc((2*size - 1)*sizeof(int))) << endl;
    //cout << sizeof(D[0]) << endl;
    //cout << int(sizeof(D)/sizeof(D[0])) << endl;
    //cout << "INF" << INF << endl;
    for(i = 0; i < 2*size - 1; ++i){
        D[i] = INF;
        //cout << D[i] << endl;
    }
    /*
    int i = 0
    while(i <= 2*size - 1 - 1){
        D.append(INF)
        ++i
    }
    */
    n = size;
    k = n - 1;
    //cout << "hello" << endl;
    for(i = 0; i < l; ++i){
        D[k+i] = data[i];
        //cout << D[k+i] << "  " <<data[i] << endl;
        //++i;
    /*
        k = n - 1
    D[k:k+len(data)] = data
    start = k
    #print(start)
    while start > 0:
        i = int((start - 1)/2)
        while i < start:
            D[i] = min(D[i*2 + 1], D[i*2 + 2])
            i += 1
        start = int((start - 1)/2)
        */
    }
    int start = n - 1;
    //#print(start)
    while(start > 0){
        i = int((start - 1)/2);
        while(i < start){
            D[i] = min(D[i*2 + 1], D[i*2 + 2]);
            ++i;
        }
        start = int((start - 1)/2);
    }
}

void update(int k, int a){
    //global n
    k += n - 1;
    D[k] = a;
    while(k > 0){
        k = int((k - 1)/2);
        D[k] = min(D[k*2 + 1], D[k*2 + 2]);
        //#array = np.array([D[k*2 + 1], D[k*2 + 2]]);
        //#D[k] = np.min(array)
    }
}

int main(void){
    //int n, l;
    cin >> n >> l;
    int data[n];
    for(int i = 0; i < n; ++i){
        cin >> data[i];
    }
    for(int i = 0; i < n; ++i){
        //cout << data[i] << " ";
    }
    //cout << endl;
    initRMQ(data);
    
    for(int i = 0; i < n; ++i){
        //cout << D[i] << " ";
    }
    //cout << endl;
    int index = 0;
    //cout << sizeof(data) << endl;
    int length = int(sizeof(data)/sizeof(data[0]));
    //cout << length << endl;
    
    while((length - index - l) >= 0){
        //time += 1
        if((length - (index + 1) - l) >= 0){
            //#print(time)
            cout << D[0] << " ";
            update(index%l, data[index+l]);
        }else{
            //#print(time)
            cout << D[0] << endl;
        }
        ++index;
    }
    return 0;
}  

/*
INF = 2**31 - 1
D = [INF]
[n, l] = list(map(int, input().split()))
data = list(map(int, input().split()))

#@jit
def initRMQ(data):
    global D, n
    size = 1
    while size < l:
        size *= 2
    i = 1
    while i <= 2*size - 1 - 1:
        D.append(INF)
        i += 1
    n = size
    
    k = n - 1
    D[k:k+len(data)] = data
    start = k
    #print(start)
    while start > 0:
        i = int((start - 1)/2)
        while i < start:
            D[i] = min(D[i*2 + 1], D[i*2 + 2])
            i += 1
        start = int((start - 1)/2)
    
#@jit('(i8, i8)')
def update(k, a):
    global n
    k += n - 1
    D[k] = a
    while k > 0:
        k = int((k - 1)/2)
        D[k] = min(D[k*2 + 1], D[k*2 + 2])
        #array = np.array([D[k*2 + 1], D[k*2 + 2]])
        #D[k] = np.min(array)
*/

/*
"""
def update(k, data):
    global D
    k += n - 1
    D[k:k+len(data)] = data
    for i in range(k, k+len(data), 2):
        while i > 0:
            i = int((i - 1)/2)
            D[i] = min(D[i*2 + 1], D[i*2 + 2])
"""
"""
def update(k, data):
    global D
    k += n - 1
    #D[k:k+len(data)] = data
    D[k:k+len(data)] = data
    start = k
    while start > 0:
        i = int((start - 1)/2)
        while i < start:
            D[i] = min(D[i*2 + 1], D[i*2 + 2])
            i += 1
        start = int((start - 1)/2)
"""
"""
def query(a, b, k, l, r):
    global INF, D
    if r <= a or b <= l:
        return INF
    if a <= l and r <= b:
        return D[k]

    vl = query(a, b, k*2 + 1, l, int((l + r)/2))
    vr = query(a, b, k*2 + 2, int((l + r)/2), r)
    return min(vl, vr)

def findMin(a, b):
    global n
    return query(a, b + 1, 0, 0, n)
"""
*/

/*
def main():
    index = 0
    initRMQ(data[index:index+l])
    #print(0, "", end="")
    #print(D)
    #update(0, data[index:index+l])
    #update(0, data)

    time = 0
    while (len(data) - index - l) >= 0:
        time += 1
        if (len(data) - (index + 1) - l) >= 0:
            #print(time)
            print(D[0], "", end="")
            #print(type(index%l), type(data[index+l]))
            update(index%l, data[index+l])
        else:
            #print(time)
            print(D[0])
        index += 1

main()
*/


Measured memory_bytes: 8032