/* 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;
}