#T579. 大合照
大合照
Description
The COIers of CodesOnline are taking a group photo!
"How should we arrange the order?"
"By user ID?"
"Or by each user's height?"
"Let's base it on user IDs then. But not simply sorting them by numerical value—we should arrange them so that when the IDs are concatenated, they form the smallest possible integer."
Input Format
There are multiple test cases.
For each test case:
The first line contains a positive integer n (n ≤ 10000), representing the number of members.
The second line contains n positive integers (each ≤ 10,000,000), representing the IDs of the members. Duplicate IDs may exist.
Output Format
For each test case, output a single positive integer—the smallest possible integer formed by concatenating the member IDs in the optimal order.
7
14 36 154 58 36 3 8
9
5534 5226 5636 99956 30 135 35 8 77
1415433636588
135303552265534563677899956
## Source
CodesOnline