#include<bits/stdc++.h>
using namespace std;
bool cmp(string a,string b)
{
return a+b>b+a;
}
main()
{
int n;cin>>n;
string a;
string str[1001] ; int dem=0;
for(int i=0;i<n;i++)
{
cin>>a;
str[dem]=a; dem++;
}
sort(str,str+dem,cmp);
for(int i=0;i<dem;i++) cout<<str[i];
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKYm9vbCBjbXAoc3RyaW5nIGEsc3RyaW5nIGIpCnsKCXJldHVybiBhK2I+YithOwp9Cm1haW4oKQp7CglpbnQgbjtjaW4+Pm47CglzdHJpbmcgYTsgCglzdHJpbmcgc3RyWzEwMDFdIDsgaW50IGRlbT0wOwoJZm9yKGludCBpPTA7aTxuO2krKykKCXsKCQljaW4+PmE7CgkJc3RyW2RlbV09YTsgZGVtKys7Cgl9Cglzb3J0KHN0cixzdHIrZGVtLGNtcCk7Cglmb3IoaW50IGk9MDtpPGRlbTtpKyspIGNvdXQ8PHN0cltpXTsKfQ==