408860: GYM103351 J Maximal perfectionism
Description
Tima is known for his perfectionism. If he sees a number, he immediately starts rearranging its digits so that the resulting number is as large as possible. He can place the digits in any order he wants and he can flip some of the digits, as long as the resulting number does not have any leading zeroes and remains an actual number.
For example, Tima can rearrange 214 to be 421, rearrange 2016 to be 9210 (digit 6 can be flipped to 9) and rearrange 1010 to be 1100. But note that 0011 would be invalid because it has leading zeroes.
One day, walking across the street, a big billboard caught Tima's attention and there were in total $$$n$$$ digits written on it at different places. Of course he could not resist the urge to rearrange its digits. What number did he get at the end?
InputFirst line of input contains a single integer $$$n$$$ — number of digits on a billboard ($$$1 \le n \le 100$$$).
Second line contains $$$n$$$ space-separated digits $$$a_1, \ldots, a_n$$$ ($$$0 \le a_i \le 9$$$).
It it guaranteed that Tima can construct at least one valid number.
OutputOutput the largest number that can be constructed by rearranging the digits on the billboard.
ExamplesInput3 2 1 4Output
421Input
3 6 0 8Output
980Input
3 0 0 1Output
100