//#include <algorithm>
//#include <iostream>
//#include <vector>
//#include <string>
#include <stdio.h>

int MAX = 2147483647;

int D[20000000];
int n;
int l;
int n_;


int min(int a, int b)
{
    if(a < b) return a;
    else return b;
}


int initRMQ(int n)
{
    int n_ = 1;

    while(n_ < n)
        n_ *= 2;

    for(int i = 0; i < 2*n_ - 1; i++)
        D[i] = MAX;

    return n_;
}


void update(int k, int a)
{
    k += n_ - 1;
    D[k] = a;
    //printf("%d : %d\n", k, D[k]);

    while(k > 0)
    {
        k = (int)((k - 1) / 2);
        D[k] = min(D[k*2 + 1], D[k*2 + 2]);
        //printf("%d : %d\n", k, D[k]);
    }
}


int query(int a, int b, int k, int l, int r)
{
    //printf("query : %d %d %d %d %d\n", a, b, k, l, r);
    if(r <= a || b <= l)
    {
        //printf(" : ret1 %d\n", MAX);
        return MAX;
    }

    if(a <= l && r <= b)
    {
        //printf(" : ret2 %d\n", D[k]);
        return D[k];
    }

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

    //printf(" : ret3 %d\n", min(vl, vr));
    return min(vl, vr);
}


int findMin(int a, int b)
{
    return query(a, b, 0, 0, n_);
}


int main(int argc, char const* argv[])
{
    scanf("%d %d", &n, &l);

    int A[10000000];

    for(int i = 0; i < n; i++)
    {
        int a;
        scanf("%d", &a);
        A[i] = a;
    }

    n_ = initRMQ(n);

    for(int i = 0; i < n; i++)
    {
        update(i, A[i]);
    }

    int m = findMin(0, l);
    printf("%d", m);

    for(int i = 1; i < n-l+1; i++)
    {
        int prev = D[n_-2+i];
        int next = D[n_-2+i+l];

        if(m >= next)
            m = next;

        if(m == prev)
            m = findMin(i, i+l);

        printf(" %d", m);

    }
    printf("\n");
}

