#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define int long long
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

int const MAXN=1e5+10;
int const INF=1e18;

void open(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
//    freopen(TASK".INP","r",stdin);
//    freopen(TASK".OUT","w",stdout);
}

bool compareVal(string a,string b){
    return a+b>b+a;
}

int n;
string a[MAXN];

signed main(){
    open();
    cin>>n;

    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    sort(a+1,a+n+1,compareVal);

    for(int i=1;i<=n;i++){
        cout<<a[i];
    }

    return 0;
}