#include <iostream>
#include <vector>
#include<algorithm>
using namespace std;


bool comparation(string a,string b)
{
    return (a+b)<(b+a);
}

int main() 
{
    int i=0;
    int n=0;
    while(cin>>n)
    {
        vector <string> a;
        for(i=0;i<n;i++)
        {
            string b;
            cin>>b;
            a.push_back(b);
        }
        sort(a.begin(),a.end(),comparation);
        string ans;
        for(i=n-1;i>=0;i--)
        {
            ans+=a[i];
        }
        cout<<ans<<endl;
    }
    return 0;
}