#include <bits/stdc++.h>
using namespace std;
bool cmp(string x, string y)
{
return x+y > y+x;
}
int main()
{
const char endl = '\n';
long n;
string s[107] = {0};
cin>>n;
for(int i; i<=n; i++)
{
cin>>s[i];
}
sort(s+1, s+n+1, cmp);
for(int i; i<=n; i++)
{
cout<<s[i];
}
cout<<endl;
return 0;
}