# include <bits/stdc++.h>
using namespace std;
long long n;
string ls[100];
int d(char i) {
return i - 48;
}
bool cmp(string a, string b) {
for (int i = 0; i < min(a.size(), b.size()); i++) {
if (d(a[i]) > d(b[i]))
return b < a;
if (d(a[i]) < d(b[i]))
return a < b;
}
if (a.size() > b.size())
return b < a;
else
return a < b;
}
int main() {
cin >> n;
for (int i = 0; i < n; i ++)
cin >> ls[i];
sort(ls, ls + n, cmp);
for (int i = 0; i < n; i ++)
cout << ls[i];
return 0;
}
https://www.luogu.com.cn/record/113156911