/* My First Template
:P
*/
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mk make_pair
ll power(ll a, ll b) {
ll x = 1, y = a;
while(b > 0) {
if(b%2 == 1) {
x=(x*y);
if(x>mod) x%=mod;
}
y = (y*y);
if(y>mod) y%=mod;
b /= 2;
}
return x;
}
bool cmp(string a, string b)
{
if(a+b <= b+a) {
return true;
}
return false;
}
string s[50002];
int main()
{
int n;
int i;
cin>>n;
string s1;
for(i = 0; i < n; i++) {
cin>>s[i];
}
sort(s,s+n,cmp);
for(i = 0; i < n; i++) {
cout<<s[i];
}
cout<<endl;
return 0;
}
LyogTXkgRmlyc3QgVGVtcGxhdGUgIAogICA6UAoqLwojaW5jbHVkZSA8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2RlZmluZSBtb2QgMTAwMDAwMDAwNwojZGVmaW5lIGxsIGxvbmcgbG9uZyBpbnQKI2RlZmluZSBwYiBwdXNoX2JhY2sKI2RlZmluZSBtayBtYWtlX3BhaXIKbGwgcG93ZXIobGwgYSwgbGwgYikgewpsbCB4ID0gMSwgeSA9IGE7CiAgICB3aGlsZShiID4gMCkgewogICAgICAgIGlmKGIlMiA9PSAxKSB7CiAgICAgICAgICAgIHg9KHgqeSk7CiAgICAgICAgICAgIGlmKHg+bW9kKSB4JT1tb2Q7CiAgICAgICAgfQogICAgICAgIHkgPSAoeSp5KTsKICAgICAgICBpZih5Pm1vZCkgeSU9bW9kOwogICAgICAgIGIgLz0gMjsKICAgIH0KICAgIHJldHVybiB4Owp9CmJvb2wgY21wKHN0cmluZyBhLCBzdHJpbmcgYikKewoJaWYoYStiIDw9IGIrYSkgewoJCXJldHVybiB0cnVlOwoJfQoJcmV0dXJuIGZhbHNlOwp9CnN0cmluZyBzWzUwMDAyXTsKaW50IG1haW4oKSAKewoJaW50IG47CglpbnQgaTsKCWNpbj4+bjsKCXN0cmluZyBzMTsKCWZvcihpID0gMDsgaSA8IG47IGkrKykgewoJCWNpbj4+c1tpXTsKCX0KCXNvcnQocyxzK24sY21wKTsKCWZvcihpID0gMDsgaSA8IG47IGkrKykgewoJCWNvdXQ8PHNbaV07Cgl9Cgljb3V0PDxlbmRsOwoJcmV0dXJuIDA7Cn0=