A national park is famous for a long (though not very wide) mountain range that stretches across the whole park from west to east. Every year crowds of tourists visit, and many of them are not very good at finding their way. So the park management decided to prepare a map of the entire range, divided into segments of equal length. At each division point the management wants to record the height of that point together with two other numbers: the height of the highest division point to the west of it, and the height of the highest division point to the east of it.
The map is almost ready. All that remains is to compute the maximum heights to the west and to the east of each division point. The park management asks you to write a program that determines these values.
The first line of standard input contains one integer n (1≤n≤1000000), the length of the mountain range. Each of the next n lines contains one integer wi (1≤wi≤1000000000), the height of the i-th division point. The points are given in order from west to east.
Your program should print exactly n lines to standard output, corresponding to the successive division points (in order from west to east). Each of these lines should contain two integers ai and bi separated by a single space: the height of the highest division point to the west of point i, and the height of the highest division point to the east of it. If there is no peak higher than wi to the west of point i, take ai=wi. Likewise, if there is no peak higher than wi to the east of point i, take bi=wi.