import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
public class Main{
public static void main
(String[] args
) { Scanner scanner
= new Scanner
(System.
in);
int n = scanner.nextInt();
for (int i = 0; i < n; i++) {
numbers
[i
] = String.
valueOf(scanner.
nextInt()); }
// Custom comparator for sorting
Comparator<String> comparator = new Comparator<String>() {
@Override
// Compare concatenated results
return (x + y).compareTo(y + x);
}
};
// Sort using the custom comparator
Arrays.
sort(numbers, comparator
);
// Output the result
}
}
aW1wb3J0IGphdmEudXRpbC5BcnJheXM7CmltcG9ydCBqYXZhLnV0aWwuQ29tcGFyYXRvcjsKaW1wb3J0IGphdmEudXRpbC5TY2FubmVyOwoKcHVibGljIGNsYXNzIE1haW57CiAgICBwdWJsaWMgc3RhdGljIHZvaWQgbWFpbihTdHJpbmdbXSBhcmdzKSB7CiAgICAgICAgU2Nhbm5lciBzY2FubmVyID0gbmV3IFNjYW5uZXIoU3lzdGVtLmluKTsKICAgICAgICAKICAgICAgICBpbnQgbiA9IHNjYW5uZXIubmV4dEludCgpOwogICAgICAgIFN0cmluZ1tdIG51bWJlcnMgPSBuZXcgU3RyaW5nW25dOwogICAgICAgIAogICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbjsgaSsrKSB7CiAgICAgICAgICAgIG51bWJlcnNbaV0gPSBTdHJpbmcudmFsdWVPZihzY2FubmVyLm5leHRJbnQoKSk7CiAgICAgICAgfQogICAgICAgIAogICAgICAgIC8vIEN1c3RvbSBjb21wYXJhdG9yIGZvciBzb3J0aW5nCiAgICAgICAgQ29tcGFyYXRvcjxTdHJpbmc+IGNvbXBhcmF0b3IgPSBuZXcgQ29tcGFyYXRvcjxTdHJpbmc+KCkgewogICAgICAgICAgICBAT3ZlcnJpZGUKICAgICAgICAgICAgcHVibGljIGludCBjb21wYXJlKFN0cmluZyB4LCBTdHJpbmcgeSkgewogICAgICAgICAgICAgICAgLy8gQ29tcGFyZSBjb25jYXRlbmF0ZWQgcmVzdWx0cwogICAgICAgICAgICAgICAgcmV0dXJuICh4ICsgeSkuY29tcGFyZVRvKHkgKyB4KTsKICAgICAgICAgICAgfQogICAgICAgIH07CiAgICAgICAgCiAgICAgICAgLy8gU29ydCB1c2luZyB0aGUgY3VzdG9tIGNvbXBhcmF0b3IKICAgICAgICBBcnJheXMuc29ydChudW1iZXJzLCBjb21wYXJhdG9yKTsKICAgICAgICAKICAgICAgICAvLyBPdXRwdXQgdGhlIHJlc3VsdAogICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbihTdHJpbmcuam9pbigiICIsIG51bWJlcnMpKTsKICAgIH0KfQo=