using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using static System.Console;
using static System.Math;

class Program
{
    static void Main()
    {
        var N = FastIO.Int();
        var L = FastIO.Int();
        var A = new int[N];
        for (int i = 0; i < A.Length; i++)
        {
            A[i] = FastIO.Int();
        }
        WriteLine(string.Join(" ", SlideMin(A, L)));
    }

    public static int[] SlideMin(int[] a, int k)
    {
        var q = new Deque<int>();
        var ret = new int[a.Length - k + 1];
        for (int i = 0; i < a.Length; i++)
        {
            while (q.Count != 0 && a[q.PeekBack()] >= a[i])//>=ではなく>でもいいけど>=のほうが省メモリ
            {
                q.PopBack();
            }
            q.PushBack(i);
            var p = i - k + 1;
            if (p >= 0)
            {
                ret[p] = a[q.PeekFront()];
                if (p == q.PeekFront())
                {
                    q.PopFront();
                }
            }
        }
        return ret;
    }
}

public class Deque<T>
{
    T[] buffer;
    int front;
    int back;//半開区間
    int mask;//1ずつしか変化しないからMaskいらねとおもったけど-1とlength-1のとき分岐するよりMaskのほうが速いのかな

    public Deque() : this(1024)
    {

    }

    public Deque(int capacity)
    {
        var c = 1024;
        while (c < capacity) c <<= 1;//! 1 << (log2(x - 1) + 1)
        buffer = new T[c];
        mask = c - 1;
    }

    public int Count//プロパティはILで見ると結構命令数あって嫌だ
    {
        get
        {
            int count = back - front;
            if (count < 0) count += buffer.Length;
            return count;
        }
    }

    public void Extend()
    {
        var nb = new T[buffer.Length * 2];
        for (int i = 0; i < buffer.Length - 1; i++)
        {
            nb[i] = buffer[(front + i) & mask];
        }
        front = 0;
        back = buffer.Length - 1;
        buffer = nb;
        mask = mask << 1 | 1;
    }

    public void PushFront(T item)
    {
        if (Count == buffer.Length - 1) Extend();
        front = (front - 1) & mask;
        buffer[front] = item;
    }

    public void PushBack(T item)
    {
        if (Count == buffer.Length - 1) Extend();
        var e = back;
        back = (back + 1) & mask;
        buffer[e] = item;
    }

    public T PopFront()
    {
        var f = front;
        front = (front + 1) & mask;
        return buffer[f & mask];
    }

    public T PopBack()
    {
        back = (back - 1) & mask;
        return buffer[back];
    }

    public T PeekFront()
    {
        return buffer[front];
    }

    public T PeekBack()
    {
        return buffer[(back - 1) & mask];
    }

    public void Clear()
    {
        front = 0;
        back = 0;
        //if (default(T) == null) Array.Clear(buffer, 0, buffer.Length);
    }
}

public static class FastIO
{
    static System.IO.Stream str = System.Console.OpenStandardInput();
    const int size = 1024;
    static byte[] buffer = new byte[size];
    static int ptr = size;

    static byte Read()
    {
        if (ptr == size)
        {
            str.Read(buffer, 0, size);
            ptr = 0;
        }
        return buffer[ptr++];
    }

    public static int Int()
    {
        var c = Read();
        while (c < 0x21)
        {
            c = Read();
        }
        var n = false;
        if (c == '-')
        {
            n = true;
            c = Read();
        }
        var ret = 0;
        while (c > 0x20)
        {
            ret = ret * 10 + c - '0';
            c = Read();
        }
        return n ? -ret : ret;
    }
}



Measured memory_bytes: 70104