408860: GYM103351 J Maximal perfectionism

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

J. Maximal perfectionismtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

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?

Input

First 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.

Output

Output the largest number that can be constructed by rearranging the digits on the billboard.

ExamplesInput
3
2 1 4
Output
421
Input
3
6 0 8
Output
980
Input
3
0 0 1
Output
100

加入题单

算法标签: