Question
Traveler’s Watchtower View

A traveler is journeying through KaTeX can only parse string typed expression cities arranged in a straight line. Each city has a watchtower with a certain height. To stay safe, the traveler observes the route using a magical scope that can view exactly KaTeX can only parse string typed expression consecutive cities at a time.

For every such group of KaTeX can only parse string typed expression consecutive cities, the traveler wants to know the height of the tallest watchtower visible in that view.

Your task is to help the traveler by determining the maximum watchtower height in each contiguous group of KaTeX can only parse string typed expression cities.

Input
The first line contains two integers KaTeX can only parse string typed expression and KaTeX can only parse string typed expression — the total number of cities and the number of cities visible through the scope at once.
The second line contains KaTeX can only parse string typed expression integers — KaTeX can only parse string typed expression, where KaTeX can only parse string typed expression represents the height of the watchtower in the KaTeX can only parse string typed expression-th city.
Output
Print KaTeX can only parse string typed expression space-separated integers — the maximum watchtower height for each group of KaTeX can only parse string typed expression consecutive cities, in the order they appear.
Example
Input
8 3
1 3 2 0 5 3 6 7
Output
3 3 5 5 6 7
Explanation
The traveler checks the cities in groups of 3:
Cities (1, 3, 2) → tallest tower is 3
Cities (3, 2, 0) → tallest tower is 3
Cities (2, 0, 5) → tallest tower is 5
Cities (0, 5, 3) → tallest tower is 5
Cities (5, 3, 6) → tallest tower is 6
Cities (3, 6, 7) → tallest tower is 7

Online