The shop has n items with different prices. When a customer purchases an item, the shop owner wants to know what would be the cheapest and the most expensive item in the inventory after the purchased item is gone. They ask you to help them with implementing the program that would calculate the cheapest and the most expensive items in the shop after removing each element in the inventory. Note that the removals are independent i.e. for each index we consider only removing that index without touching other elements.
Input
The first line of the input contains an integer n - the number of items in the shop (1 ≤ n ≤ ).
The next line contains n integers separated by a space, that represent the prices of those items .
Output
The program should print n lines. Line i should contain two numbers - the cheapest and the most expensive item in the inventory after removing item i.