You are not allowed to search for problem "skyscrapers" on Codeforces.
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along a highway. It is known that the company has already bought plots along the highway and is preparing to build skyscrapers, one on each plot.
Architects must consider several requirements when planning the skyscrapers:
- Each plot has a limit on the maximum number of floors due to land properties.
- According to the city’s design code, it is unacceptable for a skyscraper to have both a taller skyscraper on its left and a taller skyscraper on its right.
Formally, label the plots from to . Let be the number of floors of the skyscraper on plot . Then:
- , for all , and
- There must not exist an index , , such that .
The company wants to maximize the total number of floors, i.e. .
Task
Find any valid configuration that satisfies all constraints and maximizes the total number of floors.
Input data
The first line contains a single integer .
The second line contains integers , where is the maximum allowed number of floors on plot .
Output data
Print integers — the number of floors for each skyscraper, such that all constraints are satisfied and the total number of floors is maximized.
If there are multiple valid answers, print any of them.
Constraints and clarifications
Example 1
stdin
5
1 2 3 2 1
stdout
1 2 3 2 1
Explanation
Assigning maximum heights to all skyscrapers is valid.
Example 2
stdin
3
10 6 8
stdout
10 6 6
Explanation
Assigning maximum heights to all plots violates the constraint. The configuration is optimal. Another valid configuration is , but it is not optimal since the total sum is smaller.