#include<bits/stdc++.h>
using namespace std;
bool cmp(const string& a, const string &b){
return a+b>b+a;
}
int main(){
if(fopen("BAI2.INP","r")){
freopen("BAI2.INP","r",stdin);
freopen("BAI2.OUT","w",stdout);
}
int n;
cin >> n;
vector<string> a(n);
for(int i = 0;i < n;i++){
cin >> a[i];
}
string res = "";
sort(a.begin(),a.end(),cmp);
for(const string& num : a){
res += num;
}
cout << res;
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmJvb2wgY21wKGNvbnN0IHN0cmluZyYgYSwgY29uc3Qgc3RyaW5nICZiKXsKICAgIHJldHVybiBhK2I+YithOwogICAgfQppbnQgbWFpbigpewogICAgaWYoZm9wZW4oIkJBSTIuSU5QIiwiciIpKXsKICAgICAgICBmcmVvcGVuKCJCQUkyLklOUCIsInIiLHN0ZGluKTsKICAgICAgICBmcmVvcGVuKCJCQUkyLk9VVCIsInciLHN0ZG91dCk7CiAgICB9CiAgICBpbnQgbjsKICAgIGNpbiA+PiBuOwogICAgdmVjdG9yPHN0cmluZz4gYShuKTsKICAgIGZvcihpbnQgaSA9IDA7aSA8IG47aSsrKXsKICAgICAgICBjaW4gPj4gYVtpXTsKICAgIH0KICAgIHN0cmluZyByZXMgPSAiIjsKICAgIHNvcnQoYS5iZWdpbigpLGEuZW5kKCksY21wKTsKCiAgICBmb3IoY29uc3Qgc3RyaW5nJiBudW0gOiBhKXsKICAgICAgICByZXMgKz0gbnVtOwogICAgfQogICAgY291dCA8PCByZXM7CiAgICByZXR1cm4gMDsKfQo=