#include<bits/stdc++.h>

using namespace std;

#define in(a,x,y) (a>=x && a<=y)
#define out(a,x,y) (!in(a,x,y))
#define sz(a) ((int)a.size())
#define repv(i,a) for(int i=0;i<sz(a);i++)
#define revv(i,a) for(int i=sz(a)-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back

#define AND(a,b) ((a) & (b))
#define OR(a,b) ((a)|(b))
#define XOR(a,b) ((a) ^ (b))
#define xx first
#define yy second
#define mp make_pair
#define sqr(x) ((x)*(x))
#define sqrt(x) sqrt(1.0*(x))

#define LB(a,x) (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x) (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define left nokol_left
#define right nokol_right
#define countbit(x) __builtin_popcountll((ll)x)
#define PQ priority_queue
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);
#define Unique(store) store.resize(unique(store.begin(),store.end())-store.begin())
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> vi;
typedef vector<long long> vll;

template<class T>T __sqr(const T x){return x*x;}
template< class T, class X > inline T __pow(T a,X y) {T z=1; rep(i,1,y){z*=a;} return z; }
template< class T > inline T gcd(T a,T b) {a=abs(a);b=abs(b); if(!b) return a; return __gcd(b,a%b);}
template< class T > inline T lcm(T a,T b) {a=abs(a);b=abs(b); return (a/__gcd(a,b))*b;}
inline bool ispow2(int x){return (x!=0 && (x&(x-1))==0);}
template<class T>void UpdateMin(T &x,T y){  if(y<x){x=y;}}
template<class T>void UpdateMax(T &x,T y){if(x<y){x=y;}}
template<class T,class X, class Y > inline T bigmod(T n,X m,Y mod){ull ret=1, a = n%mod ; while(m){ if(m&1)ret=(ret*a)%mod; m>>=1; a=(a*a)%mod; }ret%=mod;return (T)ret;}
template<class T, class Y > inline T modinv(T n,Y mod) {return bigmod(n,mod-2,mod);}

template<class T,class X> int getbit(T s,X i) { return (s >> i) & 1; }
template<class T,class X> T onbit(T s, X i) { return s | (T(1) << i); }
template<class T,class X> T offbit(T s, X i) { return s & (~(T(1) << i)); }
template<class T> inline void read(T &n){char c;for (c = getchar(); !(c >= '0' && c <= '9'); c = getchar()); n = c - '0';for (c = getchar(); c >= '0' && c <= '9'; c = getchar()) n = n * 10 + c - '0';}

void extended_euclid(ll a,ll b,ll &x,ll &y){ if(!b){ x = 1 , y = 0  ;  return ;} ll xx,yy; extended_euclid(b,a%b,xx,yy); x = yy; y = xx - (a/b)*yy; }
pair<ll, pair<ll, ll> > extendedEuclid(ll a, ll b) { ll x = 1, y = 0; ll xLast = 0, yLast = 1; ll q, r, m, n; while(a != 0) {q = b / a; r = b % a; m = xLast - q * x; n = yLast - q * y; xLast = x, yLast = y; x = m, y = n; b = a, a = r; } return make_pair(b, make_pair(xLast, yLast)); }

const ll mod[]  ={0,1000000007,1000000009,1000000021,1000000033,1000000097,1000000093,1000000097,1000000103};
const ll base[] ={0,1000003,1000033,1000037,1000039,1000081,1000099,1000117,1000121};

#define pi acos(-1.0)
#define eps  1e-12
#define MX   (lmt+20)
#define inf  1000000000000000000LL
#define MOD  1000000007LL
//---------->0123456789123465789
#define lmt  500000

struct DT{
    string a ;
    bool operator<(const DT &b) const {

        return (a + b.a) <= (b.a + a);
    }
}d[MX];

int main()
{

    int n;
    cin>>n;
    rep(i,0,n-1){
        cin>>d[i].a;
    }

    sort(d,d+n);

    rep(i,0,n-1) cout<<d[i].a;
    cout<<endl;

//    string ans= "abaabaabaacaabaacacacaaaabbacbaacbbbbcabcabbcccaabcc";
//    cout<<ans<<endl;

    return 0;
}
/*
2
baa
baab

2
aab
aaba
*/


#include<bits/stdc++.h>

using namespace std;

#define in(a,x,y) (a>=x && a<=y)
#define out(a,x,y) (!in(a,x,y))
#define sz(a) ((int)a.size())
#define repv(i,a) for(int i=0;i<sz(a);i++)
#define revv(i,a) for(int i=sz(a)-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back

#define AND(a,b) ((a) & (b))
#define OR(a,b) ((a)|(b))
#define XOR(a,b) ((a) ^ (b))
#define xx first
#define yy second
#define mp make_pair
#define sqr(x) ((x)*(x))
#define sqrt(x) sqrt(1.0*(x))

#define LB(a,x) (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x) (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define left nokol_left
#define right nokol_right
#define countbit(x) __builtin_popcountll((ll)x)
#define PQ priority_queue
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);
#define Unique(store) store.resize(unique(store.begin(),store.end())-store.begin())
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> vi;
typedef vector<long long> vll;

template<class T>T __sqr(const T x){return x*x;}
template< class T, class X > inline T __pow(T a,X y) {T z=1; rep(i,1,y){z*=a;} return z; }
template< class T > inline T gcd(T a,T b) {a=abs(a);b=abs(b); if(!b) return a; return __gcd(b,a%b);}
template< class T > inline T lcm(T a,T b) {a=abs(a);b=abs(b); return (a/__gcd(a,b))*b;}
inline bool ispow2(int x){return (x!=0 && (x&(x-1))==0);}
template<class T>void UpdateMin(T &x,T y){  if(y<x){x=y;}}
template<class T>void UpdateMax(T &x,T y){if(x<y){x=y;}}
template<class T,class X, class Y > inline T bigmod(T n,X m,Y mod){ull ret=1, a = n%mod ; while(m){ if(m&1)ret=(ret*a)%mod; m>>=1; a=(a*a)%mod; }ret%=mod;return (T)ret;}
template<class T, class Y > inline T modinv(T n,Y mod) {return bigmod(n,mod-2,mod);}

template<class T,class X> int getbit(T s,X i) { return (s >> i) & 1; }
template<class T,class X> T onbit(T s, X i) { return s | (T(1) << i); }
template<class T,class X> T offbit(T s, X i) { return s & (~(T(1) << i)); }
template<class T> inline void read(T &n){char c;for (c = getchar(); !(c >= '0' && c <= '9'); c = getchar()); n = c - '0';for (c = getchar(); c >= '0' && c <= '9'; c = getchar()) n = n * 10 + c - '0';}

void extended_euclid(ll a,ll b,ll &x,ll &y){ if(!b){ x = 1 , y = 0  ;  return ;} ll xx,yy; extended_euclid(b,a%b,xx,yy); x = yy; y = xx - (a/b)*yy; }
pair<ll, pair<ll, ll> > extendedEuclid(ll a, ll b) { ll x = 1, y = 0; ll xLast = 0, yLast = 1; ll q, r, m, n; while(a != 0) {q = b / a; r = b % a; m = xLast - q * x; n = yLast - q * y; xLast = x, yLast = y; x = m, y = n; b = a, a = r; } return make_pair(b, make_pair(xLast, yLast)); }

const ll mod[]  ={0,1000000007,1000000009,1000000021,1000000033,1000000097,1000000093,1000000097,1000000103};
const ll base[] ={0,1000003,1000033,1000037,1000039,1000081,1000099,1000117,1000121};

#define pi acos(-1.0)
#define eps  1e-12
#define MX   (lmt+20)
#define inf  1000000000000000000LL
#define MOD  1000000007LL
//---------->0123456789123465789
#define lmt  50000

struct DT{
    string a ;
    int len;
    bool operator<(const DT &b) const {

        return (a + b.a) <= (b.a + a);
    }
}d[MX];

int main()
{

    int n;
    scanf("%d",&n);
    rep(i,1,n){
        cin>>d[i].a;
//        int len = d[i].len = d[i].a.size();
//        rep(j,len,50-1) d[i].a += (char)d[i].a[j%len];
    }

    sort(d+1,d+1+n);

    rep(i,1,n) repv(j,d[i].a) cout<<d[i].a[j];
    puts("");

//    string ans= "abaabaabaacaabaacacacaaaabbacbaacbbbbcabcabbcccaabcc";
//    cout<<ans<<endl;

    return 0;
}
/*
2
baa
baab

2
aab
aaba
*/


#include<bits/stdc++.h>

using namespace std;

#define in(a,x,y) (a>=x && a<=y)
#define out(a,x,y) (!in(a,x,y))
#define sz(a) ((int)a.size())
#define repv(i,a) for(int i=0;i<sz(a);i++)
#define revv(i,a) for(int i=sz(a)-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back

#define AND(a,b) ((a) & (b))
#define OR(a,b) ((a)|(b))
#define XOR(a,b) ((a) ^ (b))
#define xx first
#define yy second
#define mp make_pair
#define sqr(x) ((x)*(x))
#define sqrt(x) sqrt(1.0*(x))

#define LB(a,x) (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x) (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define left nokol_left
#define right nokol_right
#define countbit(x) __builtin_popcountll((ll)x)
#define PQ priority_queue
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);
#define Unique(store) store.resize(unique(store.begin(),store.end())-store.begin())
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> vi;
typedef vector<long long> vll;

template<class T>T __sqr(const T x){return x*x;}
template< class T, class X > inline T __pow(T a,X y) {T z=1; rep(i,1,y){z*=a;} return z; }
template< class T > inline T gcd(T a,T b) {a=abs(a);b=abs(b); if(!b) return a; return __gcd(b,a%b);}
template< class T > inline T lcm(T a,T b) {a=abs(a);b=abs(b); return (a/__gcd(a,b))*b;}
inline bool ispow2(int x){return (x!=0 && (x&(x-1))==0);}
template<class T>void UpdateMin(T &x,T y){  if(y<x){x=y;}}
template<class T>void UpdateMax(T &x,T y){if(x<y){x=y;}}
template<class T,class X, class Y > inline T bigmod(T n,X m,Y mod){ull ret=1, a = n%mod ; while(m){ if(m&1)ret=(ret*a)%mod; m>>=1; a=(a*a)%mod; }ret%=mod;return (T)ret;}
template<class T, class Y > inline T modinv(T n,Y mod) {return bigmod(n,mod-2,mod);}

template<class T,class X> int getbit(T s,X i) { return (s >> i) & 1; }
template<class T,class X> T onbit(T s, X i) { return s | (T(1) << i); }
template<class T,class X> T offbit(T s, X i) { return s & (~(T(1) << i)); }
template<class T> inline void read(T &n){char c;for (c = getchar(); !(c >= '0' && c <= '9'); c = getchar()); n = c - '0';for (c = getchar(); c >= '0' && c <= '9'; c = getchar()) n = n * 10 + c - '0';}

void extended_euclid(ll a,ll b,ll &x,ll &y){ if(!b){ x = 1 , y = 0  ;  return ;} ll xx,yy; extended_euclid(b,a%b,xx,yy); x = yy; y = xx - (a/b)*yy; }
pair<ll, pair<ll, ll> > extendedEuclid(ll a, ll b) { ll x = 1, y = 0; ll xLast = 0, yLast = 1; ll q, r, m, n; while(a != 0) {q = b / a; r = b % a; m = xLast - q * x; n = yLast - q * y; xLast = x, yLast = y; x = m, y = n; b = a, a = r; } return make_pair(b, make_pair(xLast, yLast)); }

const ll mod[]  ={0,1000000007,1000000009,1000000021,1000000033,1000000097,1000000093,1000000097,1000000103};
const ll base[] ={0,1000003,1000033,1000037,1000039,1000081,1000099,1000117,1000121};

#define pi acos(-1.0)
#define eps  1e-12
#define MX   (lmt+20)
#define inf  1000000000000000000LL
#define MOD  1000000007LL
//---------->0123456789123465789
#define lmt  500000

struct DT{
    string a ;
    bool operator<(const DT &b) const {

        return (a + b.a) <= (b.a + a);
    }
}d[MX];

int main()
{

    int n;
    cin>>n;
    rep(i,1,n){
        cin>>d[i].a;
    }

    sort(d+1,d+1+n);

    rep(i,1,n) cout<<d[i].a;
    cout<<endl;

//    string ans= "abaabaabaacaabaacacacaaaabbacbaacbbbbcabcabbcccaabcc";
//    cout<<ans<<endl;

    return 0;
}
/*
2
baa
baab

2
aab
aaba
*/


#include<bits/stdc++.h>

using namespace std;

#define in(a,x,y) (a>=x && a<=y)
#define out(a,x,y) (!in(a,x,y))
#define sz(a) ((int)a.size())
#define repv(i,a) for(int i=0;i<sz(a);i++)
#define revv(i,a) for(int i=sz(a)-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back

#define AND(a,b) ((a) & (b))
#define OR(a,b) ((a)|(b))
#define XOR(a,b) ((a) ^ (b))
#define xx first
#define yy second
#define mp make_pair
#define sqr(x) ((x)*(x))
#define sqrt(x) sqrt(1.0*(x))

#define LB(a,x) (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x) (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define left nokol_left
#define right nokol_right
#define countbit(x) __builtin_popcountll((ll)x)
#define PQ priority_queue
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);
#define Unique(store) store.resize(unique(store.begin(),store.end())-store.begin())
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> vi;
typedef vector<long long> vll;

template<class T>T __sqr(const T x){return x*x;}
template< class T, class X > inline T __pow(T a,X y) {T z=1; rep(i,1,y){z*=a;} return z; }
template< class T > inline T gcd(T a,T b) {a=abs(a);b=abs(b); if(!b) return a; return __gcd(b,a%b);}
template< class T > inline T lcm(T a,T b) {a=abs(a);b=abs(b); return (a/__gcd(a,b))*b;}
inline bool ispow2(int x){return (x!=0 && (x&(x-1))==0);}
template<class T>void UpdateMin(T &x,T y){  if(y<x){x=y;}}
template<class T>void UpdateMax(T &x,T y){if(x<y){x=y;}}
template<class T,class X, class Y > inline T bigmod(T n,X m,Y mod){ull ret=1, a = n%mod ; while(m){ if(m&1)ret=(ret*a)%mod; m>>=1; a=(a*a)%mod; }ret%=mod;return (T)ret;}
template<class T, class Y > inline T modinv(T n,Y mod) {return bigmod(n,mod-2,mod);}

template<class T,class X> int getbit(T s,X i) { return (s >> i) & 1; }
template<class T,class X> T onbit(T s, X i) { return s | (T(1) << i); }
template<class T,class X> T offbit(T s, X i) { return s & (~(T(1) << i)); }
template<class T> inline void read(T &n){char c;for (c = getchar(); !(c >= '0' && c <= '9'); c = getchar()); n = c - '0';for (c = getchar(); c >= '0' && c <= '9'; c = getchar()) n = n * 10 + c - '0';}

void extended_euclid(ll a,ll b,ll &x,ll &y){ if(!b){ x = 1 , y = 0  ;  return ;} ll xx,yy; extended_euclid(b,a%b,xx,yy); x = yy; y = xx - (a/b)*yy; }
pair<ll, pair<ll, ll> > extendedEuclid(ll a, ll b) { ll x = 1, y = 0; ll xLast = 0, yLast = 1; ll q, r, m, n; while(a != 0) {q = b / a; r = b % a; m = xLast - q * x; n = yLast - q * y; xLast = x, yLast = y; x = m, y = n; b = a, a = r; } return make_pair(b, make_pair(xLast, yLast)); }

const ll mod[]  ={0,1000000007,1000000009,1000000021,1000000033,1000000097,1000000093,1000000097,1000000103};
const ll base[] ={0,1000003,1000033,1000037,1000039,1000081,1000099,1000117,1000121};

#define pi acos(-1.0)
#define eps  1e-12
#define MX   (lmt+20)
#define inf  1000000000000000000LL
#define MOD  1000000007LL
//---------->0123456789123465789
#define lmt  50000

struct DT{
    string a ;
    int len;
    bool operator<(const DT &b) const {
        return a < b.a;
    }

}d[MX];

int main()
{
//    cout<<(char)('z'+1)<<endl;
//    string ret = "",w = "AA";
////    ret += w[1];
//    cout<<ret<<endl;

    int n;
    scanf("%d",&n);
    rep(i,1,n){
        cin>>d[i].a;
        int len = d[i].len = d[i].a.size();
        rep(j,len,50) d[i].a += (char)d[i].a[j%len];
    }

    sort(d+1,d+1+n);

    string ans = "";
    rep(i,1,n) rep(j,0,d[i].len-1) {
        printf("%c",d[i].a[j]);
        ans += d[i].a[j];
    }
    puts("");

//    if(ans != "bvwzpuutclgknjjojyuvdtvclgknjjojyuvdtvjgcwarwvgilcctdiytmvmvfxxkezymtclgknjjojyuvdtvjgcwarwvgilcctdiytmvmvfxxkezymthclgknjjojyuvdtvjgcwarwvgilcctdiytmvmvfxxkezymtlkdlclgknjjojyuvdtvzxzclgknjjojyuvdtvzxzxradqhmenngvhxvpaoiyhctddyscasyqtilvbvgfphayykjeoylcvmjzgvzpnckalbaubfviyhijosiixvxaydxagvymqlhxtkfjrrwcvzuamizotupjqckaqqlvkfkshkxyrfefigtngifxsuhpjgkbrbwvaayhhunlvmwexvkmqbquypsnjbdkkeytthekttywypudxkazwk"){
//        cout<<"kutta "<<endl;
//    }

    return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define in(a,x,y) (a>=x && a<=y)
#define out(a,x,y) (!in(a,x,y))
#define sz(a) ((int)a.size())
#define repv(i,a) for(int i=0;i<sz(a);i++)
#define revv(i,a) for(int i=sz(a)-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back

#define AND(a,b) ((a) & (b))
#define OR(a,b) ((a)|(b))
#define XOR(a,b) ((a) ^ (b))
#define xx first
#define yy second
#define mp make_pair
#define sqr(x) ((x)*(x))
#define sqrt(x) sqrt(1.0*(x))

#define LB(a,x) (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x) (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define left nokol_left
#define right nokol_right
#define countbit(x) __builtin_popcountll((ll)x)
#define PQ priority_queue
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);
#define Unique(store) store.resize(unique(store.begin(),store.end())-store.begin())
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> vi;
typedef vector<long long> vll;

template<class T>T __sqr(const T x){return x*x;}
template< class T, class X > inline T __pow(T a,X y) {T z=1; rep(i,1,y){z*=a;} return z; }
template< class T > inline T gcd(T a,T b) {a=abs(a);b=abs(b); if(!b) return a; return __gcd(b,a%b);}
template< class T > inline T lcm(T a,T b) {a=abs(a);b=abs(b); return (a/__gcd(a,b))*b;}
inline bool ispow2(int x){return (x!=0 && (x&(x-1))==0);}
template<class T>void UpdateMin(T &x,T y){  if(y<x){x=y;}}
template<class T>void UpdateMax(T &x,T y){if(x<y){x=y;}}
template<class T,class X, class Y > inline T bigmod(T n,X m,Y mod){ull ret=1, a = n%mod ; while(m){ if(m&1)ret=(ret*a)%mod; m>>=1; a=(a*a)%mod; }ret%=mod;return (T)ret;}
template<class T, class Y > inline T modinv(T n,Y mod) {return bigmod(n,mod-2,mod);}

template<class T,class X> int getbit(T s,X i) { return (s >> i) & 1; }
template<class T,class X> T onbit(T s, X i) { return s | (T(1) << i); }
template<class T,class X> T offbit(T s, X i) { return s & (~(T(1) << i)); }
template<class T> inline void read(T &n){char c;for (c = getchar(); !(c >= '0' && c <= '9'); c = getchar()); n = c - '0';for (c = getchar(); c >= '0' && c <= '9'; c = getchar()) n = n * 10 + c - '0';}

void extended_euclid(ll a,ll b,ll &x,ll &y){ if(!b){ x = 1 , y = 0  ;  return ;} ll xx,yy; extended_euclid(b,a%b,xx,yy); x = yy; y = xx - (a/b)*yy; }
pair<ll, pair<ll, ll> > extendedEuclid(ll a, ll b) { ll x = 1, y = 0; ll xLast = 0, yLast = 1; ll q, r, m, n; while(a != 0) {q = b / a; r = b % a; m = xLast - q * x; n = yLast - q * y; xLast = x, yLast = y; x = m, y = n; b = a, a = r; } return make_pair(b, make_pair(xLast, yLast)); }

const ll mod[]  ={0,1000000007,1000000009,1000000021,1000000033,1000000097,1000000093,1000000097,1000000103};
const ll base[] ={0,1000003,1000033,1000037,1000039,1000081,1000099,1000117,1000121};

#define pi acos(-1.0)
#define eps  1e-12
#define MX   (lmt+20)
#define inf  1000000000000000000LL
#define MOD  1000000007LL
//---------->0123456789123465789
#define lmt  50000

struct DT{
    string a ;
    int len;
    bool operator<(const DT &b) const {

        if(a==b.a) return len < b.len;
        return a < b.a;
    }
}d[MX];

int main()
{

    int n;
    scanf("%d",&n);
    rep(i,1,n){
        cin>>d[i].a;
        int len = d[i].len = d[i].a.size();
        rep(j,len,50-1) d[i].a += (char)d[i].a[j%len];
    }

    sort(d+1,d+1+n);

    rep(i,1,n) rep(j,0,d[i].len-1) printf("%c",d[i].a[j]);
    puts("");

//    string ans= "abaabaabaacaabaacacacaaaabbacbaacbbbbcabcabbcccaabcc";
//    cout<<ans<<endl;

    return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define in(a,x,y) (a>=x && a<=y)
#define out(a,x,y) (!in(a,x,y))
#define sz(a) ((int)a.size())
#define repv(i,a) for(int i=0;i<sz(a);i++)
#define revv(i,a) for(int i=sz(a)-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back

#define AND(a,b) ((a) & (b))
#define OR(a,b) ((a)|(b))
#define XOR(a,b) ((a) ^ (b))
#define xx first
#define yy second
#define mp make_pair
#define sqr(x) ((x)*(x))
#define sqrt(x) sqrt(1.0*(x))

#define LB(a,x) (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x) (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define left nokol_left
#define right nokol_right
#define countbit(x) __builtin_popcountll((ll)x)
#define PQ priority_queue
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);
#define Unique(store) store.resize(unique(store.begin(),store.end())-store.begin())
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> vi;
typedef vector<long long> vll;

template<class T>T __sqr(const T x){return x*x;}
template< class T, class X > inline T __pow(T a,X y) {T z=1; rep(i,1,y){z*=a;} return z; }
template< class T > inline T gcd(T a,T b) {a=abs(a);b=abs(b); if(!b) return a; return __gcd(b,a%b);}
template< class T > inline T lcm(T a,T b) {a=abs(a);b=abs(b); return (a/__gcd(a,b))*b;}
inline bool ispow2(int x){return (x!=0 && (x&(x-1))==0);}
template<class T>void UpdateMin(T &x,T y){  if(y<x){x=y;}}
template<class T>void UpdateMax(T &x,T y){if(x<y){x=y;}}
template<class T,class X, class Y > inline T bigmod(T n,X m,Y mod){ull ret=1, a = n%mod ; while(m){ if(m&1)ret=(ret*a)%mod; m>>=1; a=(a*a)%mod; }ret%=mod;return (T)ret;}
template<class T, class Y > inline T modinv(T n,Y mod) {return bigmod(n,mod-2,mod);}

template<class T,class X> int getbit(T s,X i) { return (s >> i) & 1; }
template<class T,class X> T onbit(T s, X i) { return s | (T(1) << i); }
template<class T,class X> T offbit(T s, X i) { return s & (~(T(1) << i)); }
template<class T> inline void read(T &n){char c;for (c = getchar(); !(c >= '0' && c <= '9'); c = getchar()); n = c - '0';for (c = getchar(); c >= '0' && c <= '9'; c = getchar()) n = n * 10 + c - '0';}

void extended_euclid(ll a,ll b,ll &x,ll &y){ if(!b){ x = 1 , y = 0  ;  return ;} ll xx,yy; extended_euclid(b,a%b,xx,yy); x = yy; y = xx - (a/b)*yy; }
pair<ll, pair<ll, ll> > extendedEuclid(ll a, ll b) { ll x = 1, y = 0; ll xLast = 0, yLast = 1; ll q, r, m, n; while(a != 0) {q = b / a; r = b % a; m = xLast - q * x; n = yLast - q * y; xLast = x, yLast = y; x = m, y = n; b = a, a = r; } return make_pair(b, make_pair(xLast, yLast)); }

const ll mod[]  ={0,1000000007,1000000009,1000000021,1000000033,1000000097,1000000093,1000000097,1000000103};
const ll base[] ={0,1000003,1000033,1000037,1000039,1000081,1000099,1000117,1000121};

#define pi acos(-1.0)
#define eps  1e-12
#define MX   (lmt+20)
#define inf  1000000000000000000LL
#define MOD  1000000007LL
//---------->0123456789123465789
#define lmt  500000

struct DT{
    string a ;
    bool operator<(const DT &b) const {

        return (a + b.a) < (b.a + a);
    }
}d[MX];

int main()
{

    int n;
    cin>>n;
    rep(i,0,n-1){
        cin>>d[i].a;
    }

    sort(d,d+n);

    rep(i,0,n-1) cout<<d[i].a;
    cout<<endl;

//    string ans= "abaabaabaacaabaacacacaaaabbacbaacbbbbcabcabbcccaabcc";
//    cout<<ans<<endl;

    return 0;
}
/*
2
baa
baab

2
aab
aaba
*/


#include<bits/stdc++.h>

using namespace std;

#define in(a,x,y) (a>=x && a<=y)
#define out(a,x,y) (!in(a,x,y))
#define sz(a) ((int)a.size())
#define repv(i,a) for(int i=0;i<sz(a);i++)
#define revv(i,a) for(int i=sz(a)-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back

#define AND(a,b) ((a) & (b))
#define OR(a,b) ((a)|(b))
#define XOR(a,b) ((a) ^ (b))
#define xx first
#define yy second
#define mp make_pair
#define sqr(x) ((x)*(x))
#define sqrt(x) sqrt(1.0*(x))

#define LB(a,x) (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x) (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define left nokol_left
#define right nokol_right
#define countbit(x) __builtin_popcountll((ll)x)
#define PQ priority_queue
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);
#define Unique(store) store.resize(unique(store.begin(),store.end())-store.begin())
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> vi;
typedef vector<long long> vll;

template<class T>T __sqr(const T x){return x*x;}
template< class T, class X > inline T __pow(T a,X y) {T z=1; rep(i,1,y){z*=a;} return z; }
template< class T > inline T gcd(T a,T b) {a=abs(a);b=abs(b); if(!b) return a; return __gcd(b,a%b);}
template< class T > inline T lcm(T a,T b) {a=abs(a);b=abs(b); return (a/__gcd(a,b))*b;}
inline bool ispow2(int x){return (x!=0 && (x&(x-1))==0);}
template<class T>void UpdateMin(T &x,T y){  if(y<x){x=y;}}
template<class T>void UpdateMax(T &x,T y){if(x<y){x=y;}}
template<class T,class X, class Y > inline T bigmod(T n,X m,Y mod){ull ret=1, a = n%mod ; while(m){ if(m&1)ret=(ret*a)%mod; m>>=1; a=(a*a)%mod; }ret%=mod;return (T)ret;}
template<class T, class Y > inline T modinv(T n,Y mod) {return bigmod(n,mod-2,mod);}

template<class T,class X> int getbit(T s,X i) { return (s >> i) & 1; }
template<class T,class X> T onbit(T s, X i) { return s | (T(1) << i); }
template<class T,class X> T offbit(T s, X i) { return s & (~(T(1) << i)); }
template<class T> inline void read(T &n){char c;for (c = getchar(); !(c >= '0' && c <= '9'); c = getchar()); n = c - '0';for (c = getchar(); c >= '0' && c <= '9'; c = getchar()) n = n * 10 + c - '0';}

void extended_euclid(ll a,ll b,ll &x,ll &y){ if(!b){ x = 1 , y = 0  ;  return ;} ll xx,yy; extended_euclid(b,a%b,xx,yy); x = yy; y = xx - (a/b)*yy; }
pair<ll, pair<ll, ll> > extendedEuclid(ll a, ll b) { ll x = 1, y = 0; ll xLast = 0, yLast = 1; ll q, r, m, n; while(a != 0) {q = b / a; r = b % a; m = xLast - q * x; n = yLast - q * y; xLast = x, yLast = y; x = m, y = n; b = a, a = r; } return make_pair(b, make_pair(xLast, yLast)); }

const ll mod[]  ={0,1000000007,1000000009,1000000021,1000000033,1000000097,1000000093,1000000097,1000000103};
const ll base[] ={0,1000003,1000033,1000037,1000039,1000081,1000099,1000117,1000121};

#define pi acos(-1.0)
#define eps  1e-12
#define MX   (lmt+20)
#define inf  1000000000000000000LL
#define MOD  1000000007LL
//---------->0123456789123465789
#define lmt  50000

struct DT{
    string a ;
    int len;
    bool operator<(const DT &b) const {
        return a < b.a;
    }

}d[MX];

int main()
{
//    cout<<(char)('z'+1)<<endl;
//    string ret = "",w = "AA";
////    ret += w[1];
//    cout<<ret<<endl;

    int n;
    scanf("%d",&n);
    rep(i,1,n){
        cin>>d[i].a;
        int len = d[i].len = d[i].a.size();

//        cout<<"len "<<1%len<<endl;
//        char ch = d[i].a[1%len];
//
//        d[i].a += d[i].a[1%len];

        rep(j,len,50-1) d[i].a += (char)d[i].a[j%len];
//        cout<<"hello"<<endl;
    }

    sort(d+1,d+1+n);

    rep(i,1,n) rep(j,0,d[i].len-1) printf("%c",d[i].a[j]);
    puts("");

    return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define in(a,x,y) (a>=x && a<=y)
#define out(a,x,y) (!in(a,x,y))
#define sz(a) ((int)a.size())
#define repv(i,a) for(int i=0;i<sz(a);i++)
#define revv(i,a) for(int i=sz(a)-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back

#define AND(a,b) ((a) & (b))
#define OR(a,b) ((a)|(b))
#define XOR(a,b) ((a) ^ (b))
#define xx first
#define yy second
#define mp make_pair
#define sqr(x) ((x)*(x))
#define sqrt(x) sqrt(1.0*(x))

#define LB(a,x) (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x) (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define left nokol_left
#define right nokol_right
#define countbit(x) __builtin_popcountll((ll)x)
#define PQ priority_queue
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);
#define Unique(store) store.resize(unique(store.begin(),store.end())-store.begin())
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> vi;
typedef vector<long long> vll;

template<class T>T __sqr(const T x){return x*x;}
template< class T, class X > inline T __pow(T a,X y) {T z=1; rep(i,1,y){z*=a;} return z; }
template< class T > inline T gcd(T a,T b) {a=abs(a);b=abs(b); if(!b) return a; return __gcd(b,a%b);}
template< class T > inline T lcm(T a,T b) {a=abs(a);b=abs(b); return (a/__gcd(a,b))*b;}
inline bool ispow2(int x){return (x!=0 && (x&(x-1))==0);}
template<class T>void UpdateMin(T &x,T y){  if(y<x){x=y;}}
template<class T>void UpdateMax(T &x,T y){if(x<y){x=y;}}
template<class T,class X, class Y > inline T bigmod(T n,X m,Y mod){ull ret=1, a = n%mod ; while(m){ if(m&1)ret=(ret*a)%mod; m>>=1; a=(a*a)%mod; }ret%=mod;return (T)ret;}
template<class T, class Y > inline T modinv(T n,Y mod) {return bigmod(n,mod-2,mod);}

template<class T,class X> int getbit(T s,X i) { return (s >> i) & 1; }
template<class T,class X> T onbit(T s, X i) { return s | (T(1) << i); }
template<class T,class X> T offbit(T s, X i) { return s & (~(T(1) << i)); }
template<class T> inline void read(T &n){char c;for (c = getchar(); !(c >= '0' && c <= '9'); c = getchar()); n = c - '0';for (c = getchar(); c >= '0' && c <= '9'; c = getchar()) n = n * 10 + c - '0';}

void extended_euclid(ll a,ll b,ll &x,ll &y){ if(!b){ x = 1 , y = 0  ;  return ;} ll xx,yy; extended_euclid(b,a%b,xx,yy); x = yy; y = xx - (a/b)*yy; }
pair<ll, pair<ll, ll> > extendedEuclid(ll a, ll b) { ll x = 1, y = 0; ll xLast = 0, yLast = 1; ll q, r, m, n; while(a != 0) {q = b / a; r = b % a; m = xLast - q * x; n = yLast - q * y; xLast = x, yLast = y; x = m, y = n; b = a, a = r; } return make_pair(b, make_pair(xLast, yLast)); }

const ll mod[]  ={0,1000000007,1000000009,1000000021,1000000033,1000000097,1000000093,1000000097,1000000103};
const ll base[] ={0,1000003,1000033,1000037,1000039,1000081,1000099,1000117,1000121};

#define pi acos(-1.0)
#define eps  1e-12
#define MX   (lmt+20)
#define inf  1000000000000000000LL
#define MOD  1000000007LL
//---------->0123456789123465789
#define lmt  50000

string a[MX];

int main()
{
//    cout<<(char)('z'+1)<<endl;

    int n;
    scanf("%d",&n);
    rep(i,1,n){
        cin>>a[i];
        a[i]+='{';
    }

    sort(a+1,a+1+n);

    rep(i,1,n) repv(j,a[i]) if(a[i][j]!='{')printf("%c",a[i][j]);
    puts("");

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <vector>
#include <string>
#include <queue>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
typedef pair<int, int> pii;
typedef long long ull;
typedef long long ll;
typedef vector<int> vi;
#define xx first
#define yy second
#define rep(i, a, n) for (int i = a; i < n; i++)
#define sa(n) scanf("%d", &(n))
#define vep(c) for(decltype((c).begin()) it = (c).begin(); it != (c).end(); it++)
const int mod = int(1e9) + 7, INF = 0x3fffffff, maxn = 1e5 + 12;
string a[50005];

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

int main(void)
{
    int n;
    cin >> n;
    rep (i, 0, n) {
        cin >> a[i];
    }
    sort(a, a + n, cmp);
    rep (i, 0, n) {
        cout << a[i];
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <vector>
#include <string>
#include <queue>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
typedef pair<int, int> pii;
typedef long long ull;
typedef long long ll;
typedef vector<int> vi;
#define xx first
#define yy second
#define rep(i, a, n) for (int i = a; i < n; i++)
#define sa(n) scanf("%d", &(n))
#define vep(c) for(decltype((c).begin()) it = (c).begin(); it != (c).end(); it++)
const int mod = int(1e9) + 7, INF = 0x3fffffff, maxn = 1e5 + 12;
string a[maxn / 10 * 5];

bool cmp(string &a, string &b)
{
    return a + b <= b + a;
}

int main(void)
{
    int n;
    cin >> n;
    rep (i, 0, n) {
        cin >> a[i];
    }
    sort(a, a + n, cmp);
    rep (i, 0, n) {
        cout << a[i];
    }
    cout << endl;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <vector>
#include <string>
#include <queue>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
typedef pair<int, int> pii;
typedef long long ull;
typedef long long ll;
typedef vector<int> vi;
#define xx first
#define yy second
#define rep(i, a, n) for (int i = a; i < n; i++)
#define sa(n) scanf("%d", &(n))
#define vep(c) for(decltype((c).begin()) it = (c).begin(); it != (c).end(); it++)
const int mod = int(1e9) + 7, INF = 0x3fffffff, maxn = 1e5 + 12;
string s[50005];
bool cmp(string a,string b)
{
	string c=a+b,d=b+a;
	return c<d;
}
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	cin>>s[i];
	sort(s+1,s+n+1,cmp);
	for(int i=1;i<=n;i++)
	cout<<s[i];
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <vector>
#include <string>
#include <queue>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
typedef pair<int, int> pii;
typedef long long ull;
typedef long long ll;
typedef vector<int> vi;
#define xx first
#define yy second
#define rep(i, a, n) for (int i = a; i < n; i++)
#define sa(n) scanf("%d", &(n))
#define vep(c) for(decltype((c).begin()) it = (c).begin(); it != (c).end(); it++)
const int mod = int(1e9) + 7, INF = 0x3fffffff, maxn = 1e5 + 12;
string a[50005];

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

int main(void)
{
    int n;
    sa(n);
    rep (i, 0, n) {
        cin >> a[i];
    }
    sort(a, a + n, cmp);
    rep (i, 0, n) {
        cout << a[i];
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <vector>
#include <string>
#include <queue>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
typedef pair<int, int> pii;
typedef long long ull;
typedef long long ll;
typedef vector<int> vi;
#define xx first
#define yy second
#define rep(i, a, n) for (int i = a; i < n; i++)
#define sa(n) scanf("%d", &(n))
#define vep(c) for(decltype((c).begin()) it = (c).begin(); it != (c).end(); it++)
const int mod = int(1e9) + 7, INF = 0x3fffffff, maxn = 1e5 + 12;
string s[50005];
bool cmp(string a,string b)
{
    return a + b < b + a;
}
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	cin>>s[i];
	sort(s+1,s+n+1,cmp);
	for(int i=1;i<=n;i++)
	cout<<s[i];
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <vector>
#include <string>
#include <queue>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
typedef pair<int, int> pii;
typedef long long ull;
typedef long long ll;
typedef vector<int> vi;
#define xx first
#define yy second
#define rep(i, a, n) for (int i = a; i < n; i++)
#define sa(n) scanf("%d", &(n))
#define vep(c) for(decltype((c).begin()) it = (c).begin(); it != (c).end(); it++)
const int mod = int(1e9) + 7, INF = 0x3fffffff, maxn = 1e5 + 12;
string a[maxn / 10 * 5];

bool cmp(string &a, string &b)
{

    for (int i = 0; i < min(a.size(), b.size()); i++) {
        if (a[i] < b[i]) return true;
        if (a[i] > b[i]) return false;
    }
    if (a.size() > b.size()) {
        for (int i = b.size(); i < a.size(); i++) {
            if (a[i] < a[i - b.size()]) return true;
            else if (a[i] > a[i - b.size()]) return false;
        }
    }
    else if (a.size() < b.size()) {
        for (int i = a.size(); i < b.size(); i++) {
            if (b[i] < b[i - a.size()]) return false;
            else if (b[i] > b[i - a.size()]) return true;
        }
    }
    return true;
}

int main(void)
{
    int n;
    cin >> n;
    rep (i, 0, n) {
        cin >> a[i];
    }
    sort(a, a + n, cmp);
    rep (i, 0, n) {
        cout << a[i];
    }
    cout << endl;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <vector>
#include <string>
#include <queue>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
typedef pair<int, int> pii;
typedef long long ull;
typedef long long ll;
typedef vector<int> vi;
#define xx first
#define yy second
#define rep(i, a, n) for (int i = a; i < n; i++)
#define sa(n) scanf("%d", &(n))
#define vep(c) for(decltype((c).begin()) it = (c).begin(); it != (c).end(); it++)
const int mod = int(1e9) + 7, INF = 0x3fffffff, maxn = 1e5 + 12;
string a[maxn / 10 * 5];

bool cmp(string &a, string &b)
{

    for (int i = 0; i < min(a.size(), b.size()); i++) {
        if (a[i] < b[i]) return true;
        if (a[i] > b[i]) return false;
    }
    if (a.size() > b.size()) {
        string aa;
        for (int i = b.size(); i < a.size(); i++) {
//            if (a[i] < a[i - b.size()]) return true;
//            else if (a[i] > a[i - b.size()]) return false;
            aa += a[i];

        }
        return cmp(aa, b);
    }
    else if (a.size() < b.size()) {
        string bb;
        for (int i = a.size(); i < b.size(); i++) {

//            if (b[i] < b[i - a.size()]) return false;
//            else if (b[i] > b[i - a.size()]) return true;
            bb += b[i];
        }
        return cmp(a, bb);
    }
    return true;
}

int main(void)
{
    int n;
    cin >> n;
    rep (i, 0, n) {
        cin >> a[i];
    }
    sort(a, a + n, cmp);
    rep (i, 0, n) {
        cout << a[i];
    }
    cout << endl;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <vector>
#include <string>
#include <queue>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
typedef pair<int, int> pii;
typedef long long ull;
typedef long long ll;
typedef vector<int> vi;
#define xx first
#define yy second
#define rep(i, a, n) for (int i = a; i < n; i++)
#define sa(n) scanf("%d", &(n))
#define vep(c) for(decltype((c).begin()) it = (c).begin(); it != (c).end(); it++)
const int mod = int(1e9) + 7, INF = 0x3fffffff, maxn = 1e5 + 12;
string a[maxn];

bool cmp(string &a, string &b)
{
    return a + b <= b + a;
}

int main(void)
{
    int n;
    cin >> n;
    rep (i, 0, n) {
        cin >> a[i];
    }
    sort(a, a + n, cmp);
    rep (i, 0, n) {
        cout << a[i];
    }
    cout << endl;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <vector>
#include <string>
#include <queue>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
typedef pair<int, int> pii;
typedef long long ull;
typedef long long ll;
typedef vector<int> vi;
#define xx first
#define yy second
#define rep(i, a, n) for (int i = a; i < n; i++)
#define sa(n) scanf("%d", &(n))
#define vep(c) for(decltype((c).begin()) it = (c).begin(); it != (c).end(); it++)
const int mod = int(1e9) + 7, INF = 0x3fffffff, maxn = 1e5 + 12;
string a[50005];

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

int main(void)
{
    int n;
    cin >> n;
    rep (i, 0, n) {
        cin >> a[i];
    }
    sort(a, a + n, cmp);
    rep (i, 0, n) {
        cout << a[i];
    }
    cout << endl;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <vector>
#include <string>
#include <queue>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
typedef pair<int, int> pii;
typedef long long ull;
typedef long long ll;
typedef vector<int> vi;
#define xx first
#define yy second
#define rep(i, a, n) for (int i = a; i < n; i++)
#define sa(n) scanf("%d", &(n))
#define vep(c) for(decltype((c).begin()) it = (c).begin(); it != (c).end(); it++)
const int mod = int(1e9) + 7, INF = 0x3fffffff, maxn = 1e5 + 12;
string a[50005];

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

int main(void)
{
    int n;
    sa(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a, a + n, cmp);
    for (int i = 0; i < n; i++) {
        cout << a[i];
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <vector>
#include <string>
#include <queue>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
typedef pair<int, int> pii;
typedef long long ull;
typedef long long ll;
typedef vector<int> vi;
#define xx first
#define yy second
#define rep(i, a, n) for (int i = a; i < n; i++)
#define sa(n) scanf("%d", &(n))
#define vep(c) for(decltype((c).begin()) it = (c).begin(); it != (c).end(); it++)
const int mod = int(1e9) + 7, INF = 0x3fffffff, maxn = 1e5 + 12;
string a[50005];

bool cmp(string &a, string &b)
{
    return a + b <= b + a;
}

int main(void)
{
    int n;
    cin >> n;
    rep (i, 0, n) {
        cin >> a[i];
    }
    sort(a, a + n, cmp);
    rep (i, 0, n) {
        cout << a[i];
    }
    cout << endl;
    return 0;
}


#include <bits/stdc++.h>

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define nfor(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define fore(i, l, r) for (int i = int(l); i < int(r); i++)
#define correct(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define pb(a) push_back(a)
#define mp(x, y) make_pair((x), (y))
#define x first
#define y second

using namespace std;

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }

template<typename A, typename B> inline ostream& operator<< (ostream& out, const pair<A, B>& p) { return out << "(" << p.x << ", " << p.y << ")"; }
template<typename T> inline ostream& operator<< (ostream& out, const vector<T>& a) { out << "["; forn(i, sz(a)) { if (i) out << ','; out << ' ' << a[i]; } return out << " ]"; }
template<typename T> inline ostream& operator<< (ostream& out, const set<T>& a) { return out << vector<T>(all(a)); }

inline ld gett() { return clock() / ld(CLOCKS_PER_SEC); }

const int INF = int(1e9);
const li INF64 = li(1e18);
const ld EPS = 1e-9, PI = 3.1415926535897932384626433832795;

const int N = 500500, L = 111;

int n;
string a[N];

bool read() {
    if (!(cin >> n)) return false;
    forn(i, n) {
        cin >> a[i];
    }
    return true;
}

inline bool cmp(const string& a, const string& b) {
    return a + b < b + a;
}

void solve() {
    sort(a, a + n, cmp);
for (int i = 0; i < n; ++i)
cout << ans;
cout << "\n";
}

int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
#ifdef SU1
    assert(freopen("input.txt", "rt", stdin));
    //assert(freopen("output.txt", "wt", stdout));
#endif

    cout << setprecision(10) << fixed;
    cerr << setprecision(5) << fixed;

    while (read()) {
        ld stime = gett();
        solve();
     //   cerr << "Time: " << gett() - stime << endl;
        //break;
    }

    return 0;
}


#include <bits/stdc++.h>

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define nfor(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define fore(i, l, r) for (int i = int(l); i < int(r); i++)
#define correct(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define pb(a) push_back(a)
#define mp(x, y) make_pair((x), (y))
#define x first
#define y second

using namespace std;

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }

template<typename A, typename B> inline ostream& operator<< (ostream& out, const pair<A, B>& p) { return out << "(" << p.x << ", " << p.y << ")"; }
template<typename T> inline ostream& operator<< (ostream& out, const vector<T>& a) { out << "["; forn(i, sz(a)) { if (i) out << ','; out << ' ' << a[i]; } return out << " ]"; }
template<typename T> inline ostream& operator<< (ostream& out, const set<T>& a) { return out << vector<T>(all(a)); }

inline ld gett() { return clock() / ld(CLOCKS_PER_SEC); }

const int INF = int(1e9);
const li INF64 = li(1e18);
const ld EPS = 1e-9, PI = 3.1415926535897932384626433832795;

const int N = 500500, L = 111;

int n;
string a[N];

bool read() {
    if (!(cin >> n)) return false;
    forn(i, n) {
        static char buf[L];
        assert(scanf("%s", buf) == 1);
        a[i] = string(buf);
    }
    return true;
}

inline bool cmp(const string& a, const string& b) {
    return a + b < b + a;
}

void solve() {
    sort(a, a + n, cmp);
    string ans = accumulate(a, a + n, string());
    puts(ans.c_str());
}

int main() {
#ifdef SU1
    assert(freopen("input.txt", "rt", stdin));
    //assert(freopen("output.txt", "wt", stdout));
#endif

    cout << setprecision(10) << fixed;
    cerr << setprecision(5) << fixed;

    while (read()) {
        ld stime = gett();
        solve();
        cerr << "Time: " << gett() - stime << endl;
        //break;
    }

    return 0;
}


#include <bits/stdc++.h>

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define nfor(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define fore(i, l, r) for (int i = int(l); i < int(r); i++)
#define correct(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define pb(a) push_back(a)
#define mp(x, y) make_pair((x), (y))
#define x first
#define y second

using namespace std;

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }

template<typename A, typename B> inline ostream& operator<< (ostream& out, const pair<A, B>& p) { return out << "(" << p.x << ", " << p.y << ")"; }
template<typename T> inline ostream& operator<< (ostream& out, const vector<T>& a) { out << "["; forn(i, sz(a)) { if (i) out << ','; out << ' ' << a[i]; } return out << " ]"; }
template<typename T> inline ostream& operator<< (ostream& out, const set<T>& a) { return out << vector<T>(all(a)); }

inline ld gett() { return clock() / ld(CLOCKS_PER_SEC); }

const int INF = int(1e9);
const li INF64 = li(1e18);
const ld EPS = 1e-9, PI = 3.1415926535897932384626433832795;

const int N = 500500, L = 111;

int n;
string a[N];

bool read() {
    if (!(cin >> n)) return false;
    forn(i, n) {
        cin >> a[i];
    }
    return true;
}

inline bool cmp(const string& a, const string& b) {
    return a + b < b + a;
}

void solve() {
    sort(a, a + n, cmp);
for (int i = 0; i < n; ++i)
cout << a[i];
cout << "\n";
}

int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
#ifdef SU1
    assert(freopen("input.txt", "rt", stdin));
    //assert(freopen("output.txt", "wt", stdout));
#endif

    cout << setprecision(10) << fixed;
    cerr << setprecision(5) << fixed;

    while (read()) {
        ld stime = gett();
        solve();
     //   cerr << "Time: " << gett() - stime << endl;
        //break;
    }

    return 0;
}


#include <bits/stdc++.h>

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define nfor(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define fore(i, l, r) for (int i = int(l); i < int(r); i++)
#define correct(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define pb(a) push_back(a)
#define mp(x, y) make_pair((x), (y))
#define x first
#define y second

using namespace std;

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }

template<typename A, typename B> inline ostream& operator<< (ostream& out, const pair<A, B>& p) { return out << "(" << p.x << ", " << p.y << ")"; }
template<typename T> inline ostream& operator<< (ostream& out, const vector<T>& a) { out << "["; forn(i, sz(a)) { if (i) out << ','; out << ' ' << a[i]; } return out << " ]"; }
template<typename T> inline ostream& operator<< (ostream& out, const set<T>& a) { return out << vector<T>(all(a)); }

inline ld gett() { return clock() / ld(CLOCKS_PER_SEC); }

const int INF = int(1e9);
const li INF64 = li(1e18);
const ld EPS = 1e-9, PI = 3.1415926535897932384626433832795;

const int N = 500500, L = 111;

int n;
string a[N];

bool read() {
    if (!(cin >> n)) return false;
    forn(i, n) {
        cin >> a[i];
    }
    return true;
}

inline bool cmp(const string& a, const string& b) {
    return a + b < b + a;
}

void solve() {
    sort(a, a + n, cmp);
string ans;
ans.reserve(1000000);
for (int i = 0; i < n; ++i)
ans += a[i];
    puts(ans.c_str());
}

int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
#ifdef SU1
    assert(freopen("input.txt", "rt", stdin));
    //assert(freopen("output.txt", "wt", stdout));
#endif

    cout << setprecision(10) << fixed;
    cerr << setprecision(5) << fixed;

    while (read()) {
        ld stime = gett();
        solve();
     //   cerr << "Time: " << gett() - stime << endl;
        //break;
    }

    return 0;
}


#include <bits/stdc++.h>

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define nfor(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define fore(i, l, r) for (int i = int(l); i < int(r); i++)
#define correct(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define pb(a) push_back(a)
#define mp(x, y) make_pair((x), (y))
#define x first
#define y second

using namespace std;

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }

template<typename A, typename B> inline ostream& operator<< (ostream& out, const pair<A, B>& p) { return out << "(" << p.x << ", " << p.y << ")"; }
template<typename T> inline ostream& operator<< (ostream& out, const vector<T>& a) { out << "["; forn(i, sz(a)) { if (i) out << ','; out << ' ' << a[i]; } return out << " ]"; }
template<typename T> inline ostream& operator<< (ostream& out, const set<T>& a) { return out << vector<T>(all(a)); }

inline ld gett() { return clock() / ld(CLOCKS_PER_SEC); }

const int INF = int(1e9);
const li INF64 = li(1e18);
const ld EPS = 1e-9, PI = 3.1415926535897932384626433832795;

const int N = 500500, L = 111;

int n;
string a[N];

bool read() {
    if (!(cin >> n)) return false;
    forn(i, n) {
        cin >> a[i];
    }
    return true;
}

inline bool cmp(const string& a, const string& b) {
    return a + b < b + a;
}

void solve() {
    sort(a, a + n, cmp);
    string ans = accumulate(a, a + n, string());
    puts(ans.c_str());
}

int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
#ifdef SU1
    assert(freopen("input.txt", "rt", stdin));
    //assert(freopen("output.txt", "wt", stdout));
#endif

    cout << setprecision(10) << fixed;
    cerr << setprecision(5) << fixed;

    while (read()) {
        ld stime = gett();
        solve();
     //   cerr << "Time: " << gett() - stime << endl;
        //break;
    }

    return 0;
}


#include <bits/stdc++.h>

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define nfor(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define fore(i, l, r) for (int i = int(l); i < int(r); i++)
#define correct(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define pb(a) push_back(a)
#define mp(x, y) make_pair((x), (y))
#define x first
#define y second

using namespace std;

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }

template<typename A, typename B> inline ostream& operator<< (ostream& out, const pair<A, B>& p) { return out << "(" << p.x << ", " << p.y << ")"; }
template<typename T> inline ostream& operator<< (ostream& out, const vector<T>& a) { out << "["; forn(i, sz(a)) { if (i) out << ','; out << ' ' << a[i]; } return out << " ]"; }
template<typename T> inline ostream& operator<< (ostream& out, const set<T>& a) { return out << vector<T>(all(a)); }

inline ld gett() { return clock() / ld(CLOCKS_PER_SEC); }

const int INF = int(1e9);
const li INF64 = li(1e18);
const ld EPS = 1e-9, PI = 3.1415926535897932384626433832795;

const int N = 500500, L = 111;

int n;
string a[N];

bool read() {
    if (!(cin >> n)) return false;
    forn(i, n) {
        cin >> a[i];
    }
    return true;
}

inline bool cmp(const string& a, const string& b) {
    return a + b < b + a;
}

void solve() {
    sort(a, a + n, cmp);
string ans;
for (int i = 0; i < n; ++i)
ans += a[i];
    puts(ans.c_str());
}

int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
#ifdef SU1
    assert(freopen("input.txt", "rt", stdin));
    //assert(freopen("output.txt", "wt", stdout));
#endif

    cout << setprecision(10) << fixed;
    cerr << setprecision(5) << fixed;

    while (read()) {
        ld stime = gett();
        solve();
     //   cerr << "Time: " << gett() - stime << endl;
        //break;
    }

    return 0;
}


#include <bits/stdc++.h>

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define nfor(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define fore(i, l, r) for (int i = int(l); i < int(r); i++)
#define correct(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define pb(a) push_back(a)
#define mp(x, y) make_pair((x), (y))
#define x first
#define y second

using namespace std;

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }

template<typename A, typename B> inline ostream& operator<< (ostream& out, const pair<A, B>& p) { return out << "(" << p.x << ", " << p.y << ")"; }
template<typename T> inline ostream& operator<< (ostream& out, const vector<T>& a) { out << "["; forn(i, sz(a)) { if (i) out << ','; out << ' ' << a[i]; } return out << " ]"; }
template<typename T> inline ostream& operator<< (ostream& out, const set<T>& a) { return out << vector<T>(all(a)); }

inline ld gett() { return clock() / ld(CLOCKS_PER_SEC); }

const int INF = int(1e9);
const li INF64 = li(1e18);
const ld EPS = 1e-9, PI = 3.1415926535897932384626433832795;

const int N = 500500, L = 111;

int n;
string a[N];

bool read() {
    if (!(cin >> n)) return false;
    forn(i, n) {
        cin >> a[i];
    }
    return true;
}

inline bool cmp(const string& a, const string& b) {
    return a + b < b + a;
}

void solve() {
    sort(a, a + n, cmp);
    string ans = accumulate(a, a + n, string());
    puts(ans.c_str());
}

int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
#ifdef SU1
    assert(freopen("input.txt", "rt", stdin));
    //assert(freopen("output.txt", "wt", stdout));
#endif

    cout << setprecision(10) << fixed;
    cerr << setprecision(5) << fixed;

    while (read()) {
        ld stime = gett();
        solve();
        cerr << "Time: " << gett() - stime << endl;
        //break;
    }

    return 0;
}


#include <bits/stdc++.h>

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define nfor(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define fore(i, l, r) for (int i = int(l); i < int(r); i++)
#define correct(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define pb(a) push_back(a)
#define mp(x, y) make_pair((x), (y))
#define x first
#define y second

using namespace std;

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }

template<typename A, typename B> inline ostream& operator<< (ostream& out, const pair<A, B>& p) { return out << "(" << p.x << ", " << p.y << ")"; }
template<typename T> inline ostream& operator<< (ostream& out, const vector<T>& a) { out << "["; forn(i, sz(a)) { if (i) out << ','; out << ' ' << a[i]; } return out << " ]"; }
template<typename T> inline ostream& operator<< (ostream& out, const set<T>& a) { return out << vector<T>(all(a)); }

inline ld gett() { return clock() / ld(CLOCKS_PER_SEC); }

const int INF = int(1e9);
const li INF64 = li(1e18);
const ld EPS = 1e-9, PI = 3.1415926535897932384626433832795;

const int N = 500500, L = 111;

int n;
string a[N];

bool read() {
    if (!(cin >> n)) return false;
    forn(i, n) {
        static char buf[L];
        assert(scanf("%s", buf) == 1);
        a[i] = string(buf);
    }
    return true;
}

inline bool cmp(const string& a, const string& b) {
    return a + b < b + a;
}

void solve() {
    sort(a, a + n, cmp);
    string ans = accumulate(a, a + n, string());
    puts(ans.c_str());
}

int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
#ifdef SU1
    assert(freopen("input.txt", "rt", stdin));
    //assert(freopen("output.txt", "wt", stdout));
#endif

    cout << setprecision(10) << fixed;
    cerr << setprecision(5) << fixed;

    while (read()) {
        ld stime = gett();
        solve();
        cerr << "Time: " << gett() - stime << endl;
        //break;
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n;
string s[50001];

bool cmd(string a , string b)
{
    for(int i = 0 ; i < min(a.size(),b.size()) ; i ++)
        if(a[i]!=b[i])
            return (a[i] < b[i]);
    return (a.size() < b.size());
}

int main()
{
    cin>>n;
    for(int i = 0 ; i < n ; i ++)
        cin>>s[i];
    sort(s , s+n , cmd);
    for(int i = 0 ; i < n ; i ++)
        cout<<s[i];
}


#include<bits/stdc++.h>
using namespace std;
int n;
string s[50001];

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

int main()
{
    cin>>n;
    for(int i = 0 ; i < n ; i ++)
        cin>>s[i];
    sort(s , s+n , cmd);
    for(int i = 0 ; i < n ; i ++)
        cout<<s[i];
}


#include<bits/stdc++.h>
using namespace std;
int n;
string s[50001];

bool cmd(string a , string b)
{
    for(int i = 0 ; i < min(a.size(),b.size()) ; i ++)
        if(a[i]!=b[i])
            return (a[i] < b[i]);
    return (a.size() > b.size());
}

int main()
{
    cin>>n;
    for(int i = 0 ; i < n ; i ++)
        cin>>s[i];
    sort(s , s+n , cmd);
    for(int i = 0 ; i < n ; i ++)
        cout<<s[i];
}


#include<bits/stdc++.h>
using namespace std;
int n;
string s[50001];

bool cmd(string a , string b)
{
    for(int i = 0 ; i < min(a.size(),b.size()) ; i ++)
        if(a[i]!=b[i])
            return (a[i] < b[i]);
    return (a.size() < b.size());
}

int main()
{
    cin>>n;
    for(int i = 0 ; i < n ; i ++)
        cin>>s[i];
    sort(s , s+n , cmp);
    for(int i = 0 ; i < n ; i ++)
        cout<<s[i];
}


#include<bits/stdc++.h>
using namespace std;
int n;
string s[50001];

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

int main()
{
    cin>>n;
    for(int i = 0 ; i < n ; i ++)
        cin>>s[i];
    sort(s , s+n , cmd);
    for(int i = 0 ; i < n ; i ++)
        cout<<s[i];
}


#include <bits/stdc++.h>
using namespace std;
struct stc
{
	char s[55];
	int len;
}s[50005];
bool comp(stc a,stc b)
{
	for (int i=0;i<2*max(a.len,b.len);i++)
	{
		if (a.s[i%a.len]!=b.s[i%b.len]) return  a.s[i%a.len]<b.s[i%b.len];
	}
	return 1;
}
int n;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%s",s[i].s);
		s[i].len=strlen(s[i].s);
	}
	sort(s+1,s+n+1,comp);
	for (int i=1;i<=n;i++) printf("%s",s[i].s);
	printf("\n");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
struct stc
{
	char s[75];
	int len;
}s[50005];
bool comp(stc a,stc b)
{
	for (int i=0;i<2*max(a.len,b.len);i++)
	{
		if (a.s[i%a.len]!=b.s[i%b.len]) return  a.s[i%a.len]<b.s[i%b.len];
	}
	return true;
}
int n;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%s",s[i].s);
		s[i].len=strlen(s[i].s);
	}
	sort(s+1,s+n+1,comp);
	for (int i=1;i<=n;i++) printf("%s",s[i].s);
	printf("\n");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
long long ans=0,num=0;
int n,p,a[45];
char s[10];
int main()
{
	scanf("%d%d",&n,&p);
	for (int i=1;i<=n;i++)
	{
		scanf("%s",s);
		if (strlen(s)==4) a[i]=1;
		else a[i]=2;
	}
	for (int i=n;i>=1;i--)
	{
		if (a[i]==1)
		{
			ans+=num*p;
			num*=2;
		}
		else
		{
			ans+=p/2*(num*2+1);
			num=num*2+1;
		}
	}
	printf("%I64d\n",ans);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
struct stc
{
	char s[55];
	int len;
}s[50005];
bool comp(stc a,stc b)
{
	for (int i=0;i<max(a.len,b.len);i++)
	{
		if (a.s[i%a.len]!=b.s[i%b.len]) return  a.s[i%a.len]<b.s[i%b.len];
	}
	return 1;
}
int n;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%s",s[i].s);
		s[i].len=strlen(s[i].s);
	}
	sort(s+1,s+n+1,comp);
	for (int i=1;i<=n;i++) printf("%s",s[i].s);
	printf("\n");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n;
string s[50005];
bool comp(string a,string b)
{
	if (a=="") return 1;
	else if (b=="") return 0;
	for (int i=0;i<2*max(a.length(),b.length());i++)
	{
		if (a[i%a.length()]!=b[i%b.length()])
			return a[i%a.length()]<b[i%b.length()];
	}
	return true;
}
int main()
{
	cin>>n;
	for (int i=1;i<=n;i++) cin>>s[i];
	sort(s+1,s+n+1,comp);
	for (int i=1;i<=n;i++) cout<<s[i]; cout<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
struct stc
{
	char s[55];
	int len;
}s[500005];
bool comp(stc a,stc b)
{
	for (int i=0;i<2*max(a.len,b.len);i++)
	{
		if (a.s[i%a.len]!=b.s[i%b.len]) return  a.s[i%a.len]<b.s[i%b.len];
	}
	return 1;
}
int n;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%s",s[i].s);
		s[i].len=strlen(s[i].s);
	}
	sort(s+1,s+n+1,comp);
	for (int i=1;i<=n;i++) printf("%s",s[i].s);
	printf("\n");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n;
string s[50005];
inline int max(int a,int b)
{
	if (a>b) return a;
	return b;
}
bool comp(string a,string b)
{
	if (a=="") return 1;
	else if (b=="") return 0;
	for (int i=0;i<2*max(a.length(),b.length());i++)
	{
		if (a[i%a.length()]!=b[i%b.length()])
			return a[i%a.length()]<b[i%b.length()];
	}
	return true;
}
int main()
{
	cin>>n;
	for (int i=1;i<=n;i++) cin>>s[i];
	sort(s+1,s+n+1,comp);
	for (int i=1;i<=n;i++) cout<<s[i]; cout<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n;
string s[50005];
bool comp(const string& a,const string &b)
{
	return a+b<b+a;
}
int main()
{
	cin>>n;
	for (int i=1;i<=n;i++) cin>>s[i];
	sort(s+1,s+n+1,comp);
	for (int i=1;i<=n;i++) cout<<s[i]; cout<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n;
string s[50005];
bool comp(string a,string b)
{
	for (int i=0;i<2*max(a.length(),b.length());i++)
	{
		if (a[i%a.length()]!=b[i%b.length()])
			return a[i%a.length()]<b[i%b.length()];
	}
	return true;
}
int main()
{
	cin>>n;
	for (int i=1;i<=n;i++) cin>>s[i];
	sort(s+1,s+n+1,comp);
	for (int i=1;i<=n;i++) cout<<s[i]; cout<<endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

bool cmp(string a, string b) {
  while (a.size() < b.size()) a += char('z' + 1);
  while (b.size() < a.size()) b += char('z' + 1);
  return a < b;
}

int main() {
  ios_base::sync_with_stdio(false);
  int n; cin >> n;
  vector<string> a(n);
  for (auto &s : a) cin >> s;
  sort(a.begin(), a.end(), cmp);
  string ans;
  for (auto &s : a) ans += s;
  cout << ans << endl;
}


#include <bits/stdc++.h>

using namespace std;

bool cmp(string a, string b) {
  while (a.size() < b.size()) a += a[0];
  while (b.size() < a.size()) b += a[0];
  return a < b;
}

vector<string> a[26];

int main() {
  ios_base::sync_with_stdio(false);
  int n; cin >> n;
  while (n--) {
    string s; cin >> s;
    a[s[0] - 'a'].push_back(s);
  }
  for (auto &v : a) {
    sort(v.begin(), v.end(), cmp);
    for (auto &s : v) cout << s;
  }
  cout << endl;
}


#include <bits/stdc++.h>

using namespace std;

string ans;
vector <string> ts;
void rec(vector<string> &a, int l, int r, int dep = 0) {
  if (l == r) {
    rotate(a[l].begin(), a[l].end() - (dep % a[l].size()), a[l].end());
    ans += a[l];
    return;
  }
  if (dep > 60)
  {
    for (int i = l; i <= r; ++i) {
      rec(a, i, i, dep);
    }
    return;
  }
  sort(a.begin() + l, a.begin() + r + 1);
  if (dep != -1)
  {
    for (int i = l; i <= r; ++i) {
      a[i] += a[i][0];
    }
  }
  vector<int> L(26, -1), R(26, -1);
  for (int i = l; i <= r; ++i) {
    int cur = a[i][0] - 'a';
    if (L[cur] == -1) L[cur] = i;
    R[cur] = i;
  }
  for (int i = l; i <= r; ++i) {
    a[i].erase(a[i].begin());
  }
  for (int i = 0; i < 26; ++i) {
    if (L[i] != -1) {
      rec(a, L[i], R[i], dep + 1);
    }
  }
}

string get(vector<string> a) {
  ans.clear();
  sort(a.begin(), a.end());
  stack<string> sp;
  for (int i = 0; i < a.size(); ++i) {
    if (sp.size() == 0) {
      sp.push(a[i]);
    } else {
      string t1 = sp.top();
      if (t1 + a[i] == a[i] + t1) {
        sp.pop();
        sp.push(t1 + a[i]);
      } else {
        sp.push(a[i]);
      }
    }
  }
  a.clear();
  while (sp.size()) {
    a.push_back(sp.top());
    sp.pop();
  }
  reverse(a.begin(), a.end());
  rec(a, 0, a.size() - 1);
  return ans;
}

string stupid(vector<string> inp) {
  sort(inp.begin(), inp.end());
  string ans = accumulate(inp.begin(), inp.end(), string());
  do {
    string cur = accumulate(inp.begin(), inp.end(), string());
    if (cur < ans) ans = cur;
  } while (next_permutation(inp.begin(), inp.end()));
  return ans;
}

string rnd() {
  int n = 3;
  string s((rand() % n) + 1, 'a');
  for (char &c : s) c += rand() % 5;
  return s;
}

vector<string> gen() {
  int n = 3;
  vector<string> s;
  for (int i = 0; i < n; ++i) s.push_back(rnd());
  return s;
}

void test() {
  while (true) {
    auto v = gen();
    ts = v;
    auto v1 = get(v);
    auto v2 = stupid(v);
    if (v1 != v2) {
      cout << v.size() << endl;
      for (auto s : v) cout << s << endl;
      cout << endl;

      cout << "JOPA!" << endl;
      cout << v1 << endl;
      cout << v2 << endl;
      exit(0);
    }
  }
}

int main() {
  //test();
  //freopen("input.txt", "r", stdin);
  ios_base::sync_with_stdio(false);
  int n; cin >> n;
  vector<string> a(n);
  for (auto &s : a) cin >> s;
  cout << get(a) << endl;
  //cout << stupid(a) << endl;
}


#include <bits/stdc++.h>

using namespace std;

string ans;

void rec(vector<string> &a, int l, int r, int dep = 0) {
  if (l == r) {
    rotate(a[l].begin(), a[l].end() - dep % a[l].size(), a[l].end());
    ans += a[l];
    return;
  }
  sort(a.begin() + l, a.begin() + r + 1);
  for (int i = l; i <= r; ++i) {
    a[i] += a[i][0];
    a[i].erase(a[i].begin());
  }
  vector<int> L(26, -1), R(26, -1);
  for (int i = l; i <= r; ++i) {
    int cur = a[i][0] - 'a';
    if (L[cur] == -1) L[cur] = i;
    R[cur] = i;
  }
  for (int i = 0; i < 26; ++i) {
    if (L[i] != -1) {
      rec(a, L[i], R[i], dep + 1);
    }
  }
}

string get(vector<string> a) {
  ans.clear();
  sort(a.begin(), a.end());
  stack<string> sp;
  for (int i = 0; i < a.size(); ++i) {
    if (sp.size() == 0) {
      sp.push(a[i]);
    } else {
      string t1 = sp.top();
      if (t1 + a[i] == a[i] + t1) {
        sp.pop();
        sp.push(t1 + a[i]);
      } else {
        sp.push(a[i]);
      }
    }
  }
  a.clear();
  while (sp.size()) {
    a.push_back(sp.top());
    sp.pop();
  }
  reverse(a.begin(), a.end());
  rec(a, 0, a.size() - 1);
  return ans;
}

string stupid(vector<string> inp) {
  sort(inp.begin(), inp.end());
  string ans = accumulate(inp.begin(), inp.end(), string());
  do {
    string cur = accumulate(inp.begin(), inp.end(), string());
    if (cur < ans) ans = cur;
  } while (next_permutation(inp.begin(), inp.end()));
  return ans;
}

int main() {
  //freopen("input.txt", "r", stdin);
  ios_base::sync_with_stdio(false);
  int n; cin >> n;
  vector<string> a(n);
  for (auto &s : a) cin >> s;
  cout << get(a) << endl;
  //cout << stupid(a) << endl;
}


#include <bits/stdc++.h>

using namespace std;

bool cmp(string a, string b) {
  a += a[0];
  b += b[0];
  return a < b;
}

string get(const vector<string> &inp) {
  vector<string> a[26];
  for (auto &s : inp) {
    a[s[0] - 'a'].push_back(s);
  }
  string ans;
  for (auto &v : a) {
    sort(v.begin(), v.end(), cmp);
    for (auto &s : v) {
      ans += s;
    }
  }
  return ans;
}

string stupid(vector<string> inp) {
  sort(inp.begin(), inp.end());
  string ans = accumulate(inp.begin(), inp.end(), string());
  do {
    string cur = accumulate(inp.begin(), inp.end(), string());
    if (cur < ans) ans = cur;
  } while (next_permutation(inp.begin(), inp.end()));
  return ans;
}

int main() {
  ios_base::sync_with_stdio(false);
  int n; cin >> n;
  vector<string> a(n);
  for (auto &s : a) cin >> s;
  cout << get(a) << endl;
  //cout << stupid(a) << endl;
}


#include <bits/stdc++.h>

using namespace std;

string ans;

void rec(vector<string> &a, int l, int r, int dep = -1) {
  if (l == r) {
    rotate(a[l].begin(), a[l].end() - (dep % a[l].size()), a[l].end());
    ans += a[l];
    return;
  }
  sort(a.begin() + l, a.begin() + r + 1);
  if (dep != -1)
  {
    for (int i = l; i <= r; ++i) {
      a[i] += a[i][0];
      a[i].erase(a[i].begin());
    }
  }
  vector<int> L(26, -1), R(26, -1);
  for (int i = l; i <= r; ++i) {
    int cur = a[i][0] - 'a';
    if (L[cur] == -1) L[cur] = i;
    R[cur] = i;
  }
  for (int i = 0; i < 26; ++i) {
    if (L[i] != -1) {
      rec(a, L[i], R[i], dep + 1);
    }
  }
}

string get(vector<string> a) {
  ans.clear();
  sort(a.begin(), a.end());
  stack<string> sp;
  for (int i = 0; i < a.size(); ++i) {
    if (sp.size() == 0) {
      sp.push(a[i]);
    } else {
      string t1 = sp.top();
      if (t1 + a[i] == a[i] + t1) {
        sp.pop();
        sp.push(t1 + a[i]);
      } else {
        sp.push(a[i]);
      }
    }
  }
  a.clear();
  while (sp.size()) {
    a.push_back(sp.top());
    sp.pop();
  }
  reverse(a.begin(), a.end());
  rec(a, 0, a.size() - 1);
  return ans;
}

string stupid(vector<string> inp) {
  sort(inp.begin(), inp.end());
  string ans = accumulate(inp.begin(), inp.end(), string());
  do {
    string cur = accumulate(inp.begin(), inp.end(), string());
    if (cur < ans) ans = cur;
  } while (next_permutation(inp.begin(), inp.end()));
  return ans;
}

string rnd() {
  int n = 3;
  string s((rand() % n) + 1, 'a');
  for (char &c : s) c += rand() % 5;
  return s;
}

vector<string> gen() {
  int n = 3;
  vector<string> s;
  for (int i = 0; i < n; ++i) s.push_back(rnd());
  return s;
}

void test() {
  while (true) {
    auto v = gen();
    auto v1 = get(v);
    auto v2 = stupid(v);
    if (v1 != v2) {
      cout << v.size() << endl;
      for (auto s : v) cout << s << endl;
      cout << endl;

      cout << "JOPA!" << endl;
      cout << v1 << endl;
      cout << v2 << endl;
      exit(0);
    }
  }
}

int main() {
  //test();
  //freopen("input.txt", "r", stdin);
  ios_base::sync_with_stdio(false);
  int n; cin >> n;
  vector<string> a(n);
  for (auto &s : a) cin >> s;
  cout << get(a) << endl;
  //cout << stupid(a) << endl;
}


#include <bits/stdc++.h>

using namespace std;

string ans;

void rec(vector<string> &a, int l, int r, int dep = -1) {
  if (l == r) {
    if (dep == -1) dep++;
    rotate(a[l].begin(), a[l].end() - (dep % a[l].size()), a[l].end());
    ans += a[l];
    return;
  }
  sort(a.begin() + l, a.begin() + r + 1);
  if (dep != -1)
  {
    for (int i = l; i <= r; ++i) {
      a[i] += a[i][0];
      a[i].erase(a[i].begin());
    }
  }
  vector<int> L(26, -1), R(26, -1);
  for (int i = l; i <= r; ++i) {
    int cur = a[i][0] - 'a';
    if (L[cur] == -1) L[cur] = i;
    R[cur] = i;
  }
  for (int i = 0; i < 26; ++i) {
    if (L[i] != -1) {
      rec(a, L[i], R[i], dep + 1);
    }
  }
}

string get(vector<string> a) {
  ans.clear();
  sort(a.begin(), a.end());
  stack<string> sp;
  for (int i = 0; i < a.size(); ++i) {
    if (sp.size() == 0) {
      sp.push(a[i]);
    } else {
      string t1 = sp.top();
      if (t1 + a[i] == a[i] + t1) {
        sp.pop();
        sp.push(t1 + a[i]);
      } else {
        sp.push(a[i]);
      }
    }
  }
  a.clear();
  while (sp.size()) {
    a.push_back(sp.top());
    sp.pop();
  }
  reverse(a.begin(), a.end());
  rec(a, 0, a.size() - 1);
  return ans;
}

string stupid(vector<string> inp) {
  sort(inp.begin(), inp.end());
  string ans = accumulate(inp.begin(), inp.end(), string());
  do {
    string cur = accumulate(inp.begin(), inp.end(), string());
    if (cur < ans) ans = cur;
  } while (next_permutation(inp.begin(), inp.end()));
  return ans;
}

string rnd() {
  int n = 3;
  string s((rand() % n) + 1, 'a');
  for (char &c : s) c += rand() % 5;
  return s;
}

vector<string> gen() {
  int n = 3;
  vector<string> s;
  for (int i = 0; i < n; ++i) s.push_back(rnd());
  return s;
}

void test() {
  while (true) {
    auto v = gen();
    auto v1 = get(v);
    auto v2 = stupid(v);
    if (v1 != v2) {
      cout << v.size() << endl;
      for (auto s : v) cout << s << endl;
      cout << endl;

      cout << "JOPA!" << endl;
      cout << v1 << endl;
      cout << v2 << endl;
      exit(0);
    }
  }
}

int main() {
  //test();
  //freopen("input.txt", "r", stdin);
  ios_base::sync_with_stdio(false);
  int n; cin >> n;
  vector<string> a(n);
  for (auto &s : a) cin >> s;
  cout << get(a) << endl;
  //cout << stupid(a) << endl;
}


#include<bits/stdc++.h>
using namespace std;

char ch[50005][55];

struct cp
{
    int e;
    int ind;
}arr[50005];

bool acompare(cp lhs, cp rhs)
{
    return lhs.e > rhs.e;
}
main()
{
    int i,j,k,n,m,a,b;
    scanf("%d",&i);

    k=1;
    for(j=0; j<i; j++)
    {
      scanf("%s",&ch[j]);
       b=strlen(ch[j]);
        arr[j].e=b;
        arr[j].ind=j;
    }
    sort(arr,arr+(i+1),acompare);
    for(a=0;a<i;a++)
    {
        m=arr[a].ind;
        printf("%s",ch[m]);
    }
  return 0;
}


#include<bits/stdc++.h>
using namespace std;

bool cmp(string &a,string &b)
{
    return a+b < b+a;
}
main()
{
    int n,a,b,c;
    scanf("%d",&n);
    string arr[n];
    for(a=0;a<n;a++)
    {
        cin>>arr[a];
    }
    sort(arr,arr+n,cmp);
    for(b=0;b<n;b++)
    {
        cout<<arr[b];
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

struct cm
{
   string ch;
}str[50005];

bool cp(string& lhs,string& rhs)
{
    lhs+rhs < rhs+lhs;
}
main()
{
    int n,m,i,j;
    scanf("%d",&n);

    for(m=1;m<=n;m++)
      cin>>str[m].ch;

      sort(str+1,str+n+1,cp);

      for(i=1;i<=n;i++)
        cout<<str[i].ch;

      return 0;
}


#include<bits/stdc++.h>
using namespace std;

char ch[50005][55];

struct cp
{
    int e;
    int ind;
}arr[50005];

bool acompare(cp lhs, cp rhs)
{
    return lhs.e >= rhs.e;
}
main()
{
    int i,j,k,n,m,a,b;
    scanf("%d",&i);

    k=1;
    for(j=0; j<i; j++)
    {
      scanf("%s",&ch[j]);
       b=strlen(ch[j]);
        arr[j].e=b;
        arr[j].ind=j;
    }
    sort(arr,arr+i,acompare);
    for(a=0;a<i;a++)
    {
        m=arr[a].ind;
        printf("%s",ch[m]);
    }
  return 0;
}


#include<bits/stdc++.h>
using namespace std;

char ch[50005][55];

struct cp
{
    int e;
    int ind;
}arr[50005];

bool acompare(cp lhs, cp rhs)
{
    return lhs.e > rhs.e;
}
main()
{
    int i,j,k,n,m,a,b;
    scanf("%d",&i);

    k=1;
    for(j=0; j<i; j++)
    {
      scanf("%s",&ch[j]);
       b=strlen(ch[j]);
        arr[j].e=b;
        arr[j].ind=j;
    }
    sort(arr,arr+i,acompare);
    for(a=0;a<i;a++)
    {
        m=arr[a].ind;
        printf("%s",ch[m]);
    }
  return 0;
}


#include<bits/stdc++.h>
using namespace std;

struct cm
{
   string ch;
}str[50005];

bool cp(cm l,cm r)
{
    return (l.ch+r.ch) < (r.ch+l.ch);
}
main()
{
    int n,m,i,j;
    scanf("%d",&n);

    for(m=1;m<=n;m++)
      cin>>str[m].ch;

      sort(str+1,str+n+1,cp);

      for(i=1;i<=n;i++)
        cout<<str[i].ch;

      return 0;
}


#include <iostream>
//#include <algorithm>
using namespace std;
inline void boost()
{
	ios_base :: sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
}
int main ()
{
	boost();
	int n;
	cin>>n;
	string s[n], c;
	for(int i = 0; i < n; i++)
	{
		cin>>s[i];
	}

	for(int i = 0; i < n - 1; i++)
	{
		for(int j = i + 1; j < n ; j++)
		{
//			cout<<"i="<<i<<","<<s[i]<<"<"<<"j="<<j<<","<<s[j]<<"="<<s[i].compare(s[j])<<endl;
			if((s[i]+s[j]).compare(s[j] + s[i]) > 0)
			{
				swap(s[i], s[j]);
			}
		}
	}

	for(int i = 0; i < n; i++)
	{
		cout<<s[i];
	}
	return 0;
}


#include <iostream>
//#include <algorithm>
using namespace std;
int main ()
{
	int n;
	cin>>n;
	string s[n], c;
	for(int i = 0; i < n; i++)
	{
		cin>>s[i];
	}

	for(int i = 0; i < n - 1; i++)
	{
		for(int j = i + 1; j < n ; j++)
		{
//			cout<<"i="<<i<<","<<s[i]<<"<"<<"j="<<j<<","<<s[j]<<"="<<s[i].compare(s[j])<<endl;
			if(s[i].compare(s[j]) > 0)
			{
				swap(s[i], s[j]);
			}
		}
	}

	for(int i = 0; i < n; i++)
	{
		cout<<s[i];
	}
	return 0;
}


#include <iostream>
//#include <algorithm>
using namespace std;
int main ()
{
	int n;
	cin>>n;
	string s[n], c;
	for(int i = 0; i < n; i++)
	{
		cin>>s[i];
	}

	for(int i = 0; i < n - 1; i++)
	{
		for(int j = i + 1; j < n ; j++)
		{
//			cout<<"i="<<i<<","<<s[i]<<"<"<<"j="<<j<<","<<s[j]<<"="<<s[i].compare(s[j])<<endl;
			if(s[i].compare(s[j]) < 0)
			{
				swap(s[i], s[j]);
			}
		}
	}

	for(int i = 0; i < n; i++)
	{
		cout<<s[i];
	}
	return 0;
}


#include <iostream>
//#include <algorithm>
using namespace std;
int main ()
{
	int n;
	cin>>n;
	string s[n], c;
	for(int i = 0; i < n; i++)
	{
		cin>>s[i];
	}

	for(int i = 0; i < n - 1; i++)
	{
		for(int j = i + 1; j < n ; j++)
		{
//			cout<<"i="<<i<<","<<s[i]<<"<"<<"j="<<j<<","<<s[j]<<"="<<s[i].compare(s[j])<<endl;
			if((s[i]+s[j]).compare(s[j] + s[i]) > 0)
			{
				swap(s[i], s[j]);
			}
		}
	}

	for(int i = 0; i < n; i++)
	{
		cout<<s[i];
	}
	return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
inline void boost()
{
	ios_base :: sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
}
bool cmp(const string a, const string b)
{
	return a + b < b + a;
}
int main ()
{
	boost();
	int n;
	cin>>n;
	string s[n], c;
	for(int i = 0; i < n; i++)
	{
		cin>>s[i];
	}

	sort(s, s + n, cmp);
//	for(int i = 0; i < n - 1; i++)
//	{
//		for(int j = i + 1; j < n ; j++)
//		{
//			cout<<"i="<<i<<","<<s[i]<<"<"<<"j="<<j<<","<<s[j]<<"="<<s[i].compare(s[j])<<endl;
//			if((s[i]+s[j]).compare(s[j] + s[i]) > 0)
//			{
//				swap(s[i], s[j]);
//			}
//		}
//	}

	for(int i = 0; i < n; i++)
	{
		cout<<s[i];
	}
	return 0;
}


#include<cstdio>
#include<string>
#include<algorithm>

int n;
char c[55];
std::string s[50005], ans;

bool cmp(std::string x, std::string y) {
	int lx = x.length(), ly = y.length();
	int z = std::max(x.length(), y.length());
	for (int i = 0; i < z; i++) if (x[i % lx] != y[i % ly]) return x[i % lx] < y[i % ly];
	return true;
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s", c);
		s[i] = c;
	}
	std::sort(s, s + n, cmp);
	for (int i = 0; i < n; i++) ans += s[i];
	printf("%s\n", ans.c_str());
	scanf("\n");
	return 0;
}


#include<cstdio>
#include<string>
#include<algorithm>

int n;
char c[55];
std::string s[50005], ans;

bool cmp(std::string x, std::string y) {
	return x + y < y + x;
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s", c);
		s[i] = c;
	}
	std::sort(s, s + n, cmp);
	for (int i = 0; i < n; i++) ans += s[i];
	printf("%s\n", ans.c_str());
	scanf("\n");
	return 0;
}


#include<cstdio>
#include<string>
#include<algorithm>

int n;
char c[55];
std::string s[50005], ans;

bool cmp(std::string x, std::string y) {
	if (x.length() == y.length()) return x < y;
	if (x.length() < y.length()) {
		std::string z = x;
		while (z.length() < y.length()) z += x[0];
		return z < y;
	}
	if (x.length() > y.length()) {
		std::string z = y;
		while (x.length() > z.length()) z += y[0];
		return x < z;
	}
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s", c);
		s[i] = c;
	}
	std::sort(s, s + n, cmp);
	for (int i = 0; i < n; i++) ans += s[i];
	printf("%s\n", ans.c_str());
	scanf("\n");
	return 0;
}


#include<cstdio>
#include<string>
#include<algorithm>

int n;
char c[55];
std::string s[50005], ans;

bool cmp(std::string x, std::string y) {
	if (x.length() == y.length()) return x < y;
	if (x.length() < y.length()) {
		std::string z = x;
		while (z.length() < y.length()) z += x;
		return z < y;
	}
	if (x.length() > y.length()) {
		std::string z = y;
		while (x.length() > z.length()) z += y;
		return x < z;
	}
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s", c);
		s[i] = c;
	}
	std::sort(s, s + n, cmp);
	for (int i = 0; i < n; i++) ans += s[i];
	printf("%s\n", ans.c_str());
	scanf("\n");
	return 0;
}


#include<cstdio>
#include<string>
#include<algorithm>

int n;
char c[55];
std::string s[50005], ans;

bool cmp(std::string x, std::string y) {
	if (x.length() == y.length()) return x < y;
	if (x.length() < y.length()) return x + x[0] < y;
	if (x.length() > y.length()) return x < y + y[0];
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s", c);
		s[i] = c;
	}
	std::sort(s, s + n, cmp);
	for (int i = 0; i < n; i++) ans += s[i];
	printf("%s\n", ans.c_str());
	scanf("\n");
	return 0;
}


#include<cstdio>
#include<string>
#include<algorithm>

int n;
char c[55];
std::string s[50005], ans;

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s", c);
		s[i] = c;
	}
	std::sort(s, s + n);
	for (int i = 0; i < n; i++) ans += s[i];
	printf("%s\n", ans.c_str());
	scanf("\n");
	return 0;
}


#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <cstdio>
#include <cstring>
#include <utility>
#include <algorithm>
#include <stack>

using namespace std ;

#define ff first
#define ss second
#define pb push_back

typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;
typedef vector<int> vi;
typedef pair<ll,ll> pll;

inline int in(){ int x ; scanf ("%d" , &x ); return x ; }

const int N = 1e5 + 10 ;
const int MOD = 1e9 + 7 ;
const ld eps = 1e-12 ;

//////////////////////////////////////////////////////////////////////

int n ;
vector<string> vec ;

int main() {

	n = in() ;
	for ( int i = 0 ; i < n ; i++ )
	{
		string s ;
		cin >> s ;
		vec.pb(s) ;
	}

	sort ( vec.begin() , vec.end() ) ;

	for ( int i = 0 ; i < vec.size() ; i++ )
		cout << vec[i] ;

	return 0;
}


#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <cstdio>
#include <cstring>
#include <utility>
#include <algorithm>
#include <stack>

using namespace std ;

#define ff first
#define ss second
#define pb push_back

typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;
typedef vector<int> vi;
typedef pair<ll,ll> pll;

inline int in(){ int x ; scanf ("%d" , &x ); return x ; }

const int N = 1e5 + 10 ;
const int MOD = 1e9 + 7 ;
const ld eps = 1e-12 ;

//////////////////////////////////////////////////////////////////////

int n ;
vector<string> vec ;

bool cmp( string a , string b )
{
	if ( a.length() > b.length() ) swap ( a , b ) ;
	for ( int i = 0 ; i < a.length() ; i++ )
		if ( a[i] < b[i] )
			return 1 ;
		else if ( b[i] < a[i] )
			return 0 ;
	return 1 ;
}

int main() {

	n = in() ;
	for ( int i = 0 ; i < n ; i++ )
	{
		string s ;
		cin >> s ;
		vec.pb(s) ;
	}

	sort ( vec.begin() , vec.end() , cmp ) ;

	for ( int i = 0 ; i < vec.size() ; i++ )
		cout << vec[i] ;

	return 0;
}


#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <cstdio>
#include <cstring>
#include <utility>
#include <algorithm>
#include <stack>

using namespace std ;

#define ff first
#define ss second
#define pb push_back

typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;
typedef vector<int> vi;
typedef pair<ll,ll> pll;

inline int in(){ int x ; scanf ("%d" , &x ); return x ; }

const int N = 1e5 + 10 ;
const int MOD = 1e9 + 7 ;
const ld eps = 1e-12 ;

//////////////////////////////////////////////////////////////////////

int n ;
vector<string> vec ;

bool cmp( string a , string b )
{
	bool flg = 0 ;
	if ( a.length() > b.length() )
	{
		flg = 1 ;
		swap ( a , b ) ;
	}

	for ( int i = 0 ; i < a.length() ; i++ )
		if ( a[i] < b[i] )
			return  1^flg ;
		else if ( b[i] < a[i] )
			return 0^flg ;

	return 0^flg ;
}

int main() {

	n = in() ;
	for ( int i = 0 ; i < n ; i++ )
	{
		string s ;
		cin >> s ;
		vec.pb(s) ;
	}

	sort ( vec.begin() , vec.end() , cmp ) ;

	for ( int i = 0 ; i < vec.size() ; i++ )
		cout << vec[i] ;

	return 0;
}


#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <cstdio>
#include <cstring>
#include <utility>
#include <algorithm>
#include <stack>

using namespace std ;

#define ff first
#define ss second
#define pb push_back

typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;
typedef vector<int> vi;
typedef pair<ll,ll> pll;

inline int in(){ int x ; scanf ("%d" , &x ); return x ; }

const int N = 1e5 + 10 ;
const int MOD = 1e9 + 7 ;
const ld eps = 1e-12 ;

//////////////////////////////////////////////////////////////////////

int n ;
vector<string> vec ;

bool lex( string a , string b )
{
	if ( a.length() != b.length() )
	{
		for ( int i = 0 ; i < 4 ; i-- )
			cout << "WTF" << endl ;
	}
	for ( int i = 0 ; i < a.length() ; i++ )
		if ( a[i] < b[i] )
			return 1 ;
		else if ( a[i] > b[i] )
			return 0 ;
	return 1 ;
}

bool cmp( string a , string b )
{
	return lex( a + b , b + a ) ;
}

int main() {

	n = in() ;
	for ( int i = 0 ; i < n ; i++ )
	{
		string s ;
		cin >> s ;
		vec.pb(s) ;
	}

	sort ( vec.begin() , vec.end() , cmp ) ;

	for ( int i = 0 ; i < vec.size() ; i++ )
		cout << vec[i] ;

	return 0;
}


#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <cstdio>
#include <cstring>
#include <utility>
#include <algorithm>
#include <stack>

using namespace std ;

#define ff first
#define ss second
#define pb push_back

typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;
typedef vector<int> vi;
typedef pair<ll,ll> pll;

inline int in(){ int x ; scanf ("%d" , &x ); return x ; }

const int N = 1e5 + 10 ;
const int MOD = 1e9 + 7 ;
const ld eps = 1e-12 ;

//////////////////////////////////////////////////////////////////////

int n ;
vector<string> vec ;

bool lex( string a , string b )
{
	for ( int i = 0 ; i < a.length() ; i++ )
		if ( a[i] < b[i] )
			return 1 ;
		else if ( a[i] > b[i] )
			return 0 ;
	return 0 ;
}

bool cmp( string a , string b )
{
	return lex( a + b , b + a ) ;
}

int main() {

	n = in() ;
	for ( int i = 0 ; i < n ; i++ )
	{
		string s ;
		cin >> s ;
		vec.pb(s) ;
	}

	sort ( vec.begin() , vec.end() , cmp ) ;

	for ( int i = 0 ; i < vec.size() ; i++ )
		cout << vec[i] ;

	return 0;
}


#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <cstdio>
#include <cstring>
#include <utility>
#include <algorithm>
#include <stack>

using namespace std ;

#define ff first
#define ss second
#define pb push_back

typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;
typedef vector<int> vi;
typedef pair<ll,ll> pll;

inline int in(){ int x ; scanf ("%d" , &x ); return x ; }

const int N = 1e5 + 10 ;
const int MOD = 1e9 + 7 ;
const ld eps = 1e-12 ;

//////////////////////////////////////////////////////////////////////

int n ;
vector<string> vec ;

bool cmp( string a , string b )
{
	bool flg = 0 ;
	if ( a.length() > b.length() )
	{
		flg = 1 ;
		swap ( a , b ) ;
	}

	for ( int i = 0 ; i < a.length() ; i++ )
		if ( a[i] < b[i] )
			return  1^flg ;
		else if ( b[i] < a[i] )
			return 0^flg ;
	return 1^flg ;
}

int main() {

	n = in() ;
	for ( int i = 0 ; i < n ; i++ )
	{
		string s ;
		cin >> s ;
		vec.pb(s) ;
	}

	sort ( vec.begin() , vec.end() , cmp ) ;

	for ( int i = 0 ; i < vec.size() ; i++ )
		cout << vec[i] ;

	return 0;
}


#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <cstdio>
#include <cstring>
#include <utility>
#include <algorithm>
#include <stack>

using namespace std ;

#define ff first
#define ss second
#define pb push_back

typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;
typedef vector<int> vi;
typedef pair<ll,ll> pll;

inline int in(){ int x ; scanf ("%d" , &x ); return x ; }

const int N = 1e5 + 10 ;
const int MOD = 1e9 + 7 ;
const ld eps = 1e-12 ;

//////////////////////////////////////////////////////////////////////

int n ;
vector<string> vec ;

bool lex( string a , string b )
{
	for ( int i = 0 ; i < a.length() ; i++ )
		if ( a[i] < b[i] )
			return 1 ;
		else if ( a[i] > b[i] )
			return 0 ;
	return 1 ;
}

bool cmp( string a , string b )
{
	return lex( a + b , b + a ) ;
}

int main() {

	n = in() ;
	for ( int i = 0 ; i < n ; i++ )
	{
		string s ;
		cin >> s ;
		vec.pb(s) ;
	}

	sort ( vec.begin() , vec.end() , cmp ) ;

	for ( int i = 0 ; i < vec.size() ; i++ )
		cout << vec[i] ;

	return 0;
}


/*
    AUTHOR:         BHUVNESH JAIN
    INSTITUITION:   BITS PILANI, PILANI
*/
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <iterator>
#include <cmath>
#include <cassert>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <climits>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<int,pii> piii;

#define fastio          std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define PAUSE_EXE       assert(false)
#define inchar          getchar
#define outchar(x)      putchar(x)
#define MAX             200005
#define MOD             1000000007LL
#define REP(i,n)        for(__typeof(n) i=0; i<n; ++i)
#define CREP(i,n)       for(__typeof(n) i=n-1; i>=0; --i)
#define MYREP(i,a,b)    for(__typeof(a) i=a; i<=b; ++i)
#define MYCREP(i,a,b)   for(__typeof(a) i=b; i>=a; --i)
#define SET(a, b)       memset(a, b, sizeof(a))
#define count_one(a)    __builtin_popcountll(a)
#define power_2(a)      (a)&(a-1)==0
#define sz(a)           int((a).size())
#define pb              push_back
#define mp              make_pair
#define fi              first
#define sec             second
#define all(c)          (c).begin(),(c).end()
#define allr(c)         (c).rbegin(),(c).rend()
#define loop(c,i)       for(typeof(c.begin()) i = c.begin(); i != c.end(); i++)
#define loopr(c,i)      for(typeof(c.end()) i = c.end(); i != c.begin(); )
#define UNIQUE(a)       sort(all(a)), (a).erase(unique(all(a)),(a).end())
#define present(c,x)    ((c).find(x) != (c).end())
#define cpresent(c,x)   (find(all(c),x) != (c).end())

const double EPS = 1e-10;
const double PI = acos(-1.0);

template <typename T> void inPos(T &x)
{x=0;register T c=inchar();while(((c<48)||(c>57))&&(c!='-'))c=inchar();bool neg=false;if(c=='-')neg=true;for(;c<48||c>57;c=inchar());for(;c>47&&c<58;c=inchar())x=(x<<3)+(x<<1)+(c&15);if(neg)x=-x;}

template <typename T> void outPos (T n)
{char snum[65];int i=0;do {snum[i++]=n%10+'0';n/=10;}while(n);i=i-1;while(i>=0)outchar(snum[i--]);outchar('\n');}

// === tick a time ===
#include <ctime>
double tick() {static clock_t oldtick;clock_t newtick=clock();double diff = 1.0*(newtick-oldtick)/CLOCKS_PER_SEC;oldtick = newtick;return diff;}

template <typename T> T mod(T a, T b) {return (a < b ? a : a % b);}
LL mulmod(LL a,LL b, LL m){LL q=(LL)(((LD)a*(LD)b)/(LD)m);LL r=a*b-q*m;if(r>m)r%=m;if(r<0)r+=m;return r;}
template <typename T, typename S>T expo(T e, S n){T x=1,p=e;while(n){if(n&1)x=x*p;p=p*p;n>>=1;}return x;}
template <typename T>T power(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=mod(x*p,m);p=mod(p*p,m);n>>=1;}return x;}
template <typename T>T powerL(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=mulmod(x,p,m);p=mulmod(p,p,m);n>>=1;}return x;}
template <typename T> T InverseEuler(T a, T m){return (a==1? 1 : power(a, m-2, m));}
template <typename T> T gcd(T a, T b){return __gcd(a,b);}
template <typename T> T lcm(T a, T b){return (a*(b/gcd(a,b)));}

int cmp(string a, string b)
{
    if (a.length()==b.length())
    {
        if (a<b)
            return -1;
        else if (a>b)
            return 1;
        else if (a==b)
            return 0;
    }
    else if (a.length() < b.length())
    {
        int m = 0;
        for(int i=0; i<b.length(); ++i)
        {
            if (b[i]==a[m])
            {
                m++;
                if (m==a.length())
                    m = 0;
            }
            else
            {
                if (b[i]<a[m])
                    return 1;
                else
                    return -1;
            }
        }
        return 0;
    }
    else
    {
        int m = 0;
        for(int i=0; i<a.length(); ++i)
        {
            if (a[i]==b[m])
            {
                m++;
                if (m==b.length())
                    m = 0;
            }
            else
            {
                if (a[i]<b[m])
                    return -1;
                else
                    return 1;
            }
        }
        return 0;
    }
}

vector < string > temp;

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("inp.txt", "r", stdin);
    #endif
    fastio;
    int n;
    cin>>n;
    REP(i, n)
    {
    	string x;
    	cin>>x;
    	temp.pb(x);
    }
    REP(i, n)
    {
        REP(j, n)
        {
            if (j<=i)
                continue;
            else if (cmp(temp[i], temp[j]) == 1)
                swap(temp[i], temp[j]);
        }
    }
    REP(i, n)
    {
    	cout<<temp[i];
    }
    // cerr<<tick();
    return 0;
}