class Node:
    def __init__(self, x):
        self.data = x
        self.left = None
        self.right = None
        self.balance = 0    # ?????????

# ????????¢
def rotate_right(node):
    lnode = node.left
    node.left = lnode.right
    lnode.right = node
    return lnode

# ????????¢
def rotate_left(node):
    rnode = node.right
    node.right = rnode.left
    rnode.left = node
    return rnode

#
# ??????????????¢?´¢
#
def search(node, x):
    while node is not None:
        if node.data == x: return True
        if x < node.data:
            node = node.left
        else:
            node = node.right
    return False

#
# ??????????????´??° (???????????¢??????)
#
def update_balance(node):
    if node.balance == 1:
        node.right.balance = -1
        node.left.balance = 0
    elif node.balance == -1:
        node.right.balance = 0
        node.left.balance = 1
    else:
        node.right.balance = 0
        node.left.balance = 0
    node.balance = 0


#
# ?????????????????\
#

# ?????\????????????????????????????????¨?????¨????¨???\
LEFT  = 0
RIGHT = 1

# ????????????????´?????????????????????£??????
def balance(root, path):
    new_node = None
    while len(path) > 0:
        pnode, dir = path.pop()   # pnode ???, dir ??¨?????¨????¨???\
        if dir == LEFT:
            pnode.balance += 1
        else:
            pnode.balance -= 1
        b = pnode.balance
        if b == 0: return root    # ?????£?????? root ?????????
        if b > 1:
            if pnode.left.balance < 0:
                # LR ???????????¢
                pnode.left = rotate_left(pnode.left)
                new_node = rotate_right(pnode)
                update_balance(new_node)
            else:
                # LL ???????????¢
                new_node = rotate_right(pnode)
                new_node.balance = 0
                pnode.balance = 0
            break
        elif b < -1:
            if pnode.right.balance > 0:
                # RL ???????????¢
                pnode.right = rotate_right(pnode.right)
                new_node = rotate_left(pnode)
                update_balance(new_node)
            else:
                # RR ???????????¢
                new_node = rotate_left(pnode)
                new_node.balance = 0
                pnode.balance = 0
            break
    # ??????????????????
    if len(path) > 0:
        # pnode ?????????????±???????
        gnode, gdir = path.pop()
        if gdir == LEFT:
            gnode.left = new_node
        else:
            gnode.right = new_node
    elif new_node is not None:
        return new_node
    return root

# ?????\
def insert(root, x):
    if root is None: return Node(x)
    path = []
    node = root
    while True:
        if node.data == x: return root
        elif x < node.data:
            path.append((node, LEFT))
            if node.left is None:
                node.left = Node(x)
                break
            node = node.left
        else:
            path.append((node, RIGHT))
            if node.right is None:
                node.right = Node(x)
                break
            node = node.right
    return balance(root, path)

#
# ??????????????????
#

# ????????????????´?????????????????????£??????
def balance_delete(root, path):
    while len(path) > 0:
        new_node = None
        pnode, dir = path.pop()  # pnode = ???, dir = ??????????????¨?????¨
        if dir == LEFT:
            pnode.balance -= 1   # ?????\??¨?????§ left ??? -1, right ??? +1
        else:
            pnode.balance += 1
        b = pnode.balance
        if b > 1:
            if pnode.left.balance < 0:
                # ???????????¢
                pnode.left = rotate_left(pnode.left)
                new_node = rotate_right(pnode)
                update_balance(new_node)
            else:
                # ???????????¢
                new_node = rotate_right(pnode)
                if new_node.balance == 0:
                    new_node.balance = -1
                    pnode.balance = 1
                else:
                    new_node.balance = 0
                    pnode.balance = 0
        elif b < -1:
            if pnode.right.balance > 0:
                # ???????????¢
                pnode.right = rotate_right(pnode.right)
                new_node = rotate_left(pnode)
                update_balance(new_node)
            else:
                # ???????????¢
                new_node = rotate_left(pnode)
                if new_node.balance == 0:
                    new_node.balance = 1
                    pnode.balance = -1
                else:
                    new_node.balance = 0
                    pnode.balance = 0
        elif b != 0:
            break      # b == 1 or b == -1 ????????£??????
        # ??????????????????
        if new_node is not None:
            if len(path) == 0: return new_node   # root ?????????
            gnode, gdir = path[len(path) - 1]    # pnode ??????
            if gdir == LEFT:
                gnode.left = new_node
            else:
                gnode.right = new_node
            if new_node.balance != 0: break      # ?????£??????
    return root

# ??????????????¢???
def _search(node, x, path):
    while node is not None:
        if node.data == x: return node
        if x < node.data:
            path.append((node, LEFT))
            node = node.left
        else:
            path.append((node, RIGHT))
            node = node.right
    return None

# ????°?????????¢???
def _search_min(node, path):
    while node.left is not None:
        path.append((node, LEFT))
        node = node.left
    return node

# ??????
def delete(root, x):
    if root is None: return None    # ????????¨
    path = []                       # ??????
    node = _search(root, x, path)   # ??¢?´¢
    if node is None: return root    # ?????????????????????
    if node.left is not None and node.right is not None:
        # ????????????????????´???
        # ?????¨?????¨???????°?????????¢?????????????????????
        path.append((node, RIGHT))
        min_node = _search_min(node.right, path)
        node.data = min_node.data
        node = min_node
    if len(path) > 0:
        pnode, dir = path[len(path) - 1]
    else:
        pnode = None
    # ??????????????????
    if node.left is None:
        cnode = node.right
    else:
        cnode = node.left
    if pnode is None:
        return cnode
    elif dir == LEFT:
        pnode.left = cnode
    else:
        pnode.right = cnode
    return balance_delete(root, path)
            
[N,L] = [int(x) for x in input().split()]
A = [[int(x),int(i)] for i,x in enumerate(input().split())]
Tree = None
for i in range(L) : Tree = insert(Tree,A[i])
ANS = [str(search_min(Tree)[0])]

for i in range(L,N):
    Tree = delete(Tree, A[i-L])
    Tree = insert(Tree, A[i])
    ANS.append(str(search_min(Tree)[0]))
    
print(" ".join(ANS))

### FIXED CODE ###

def ascend(a,b):
    mini = min(A[a:a+L])
    ans[a] = mini
    for i in range(a+1,b):
        if A[i+L-1] <= mini : mini = A[i+L-1]
        elif A[i-1] == mini : mini = min(A[i:i+L])
        ans[i] = mini

def descend(a,b):
    mini = min(A[b-1:b+L-1])
    ans[b-1] = mini
    for i in range(b-2,a-1,-1):
        if A[i] <= mini : mini = A[i]
        elif A[i+L] == mini: mini = min(A[i:i+L])
        ans[i] = mini
    
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = [None]*(N-L+1)
count = 0;
if N > 10 ** 4:
    for i in range(100):
        if A[i+1] > A[i] : count += 1
    if count > 80 : descend(0, N-L+1)
    else : ascend(0,N-L+1)
else :
    ascend(0, N-L+1)
for i in ans[:-1] : print(i, end=" ")
print(ans[-1])