#include <cstring>
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;
string word[55];
bool cmp(string a,string b){
return a+b>b+a;
}
int main(){
int n;
while(scanf("%d",&n),n)
{
for(int i=0;i<n;i++){
cin>>word[i];
}
sort(word,word+n,cmp);
for(int i=0;i<n;i++)
cout<<word[i];
cout<<endl;
}
return 0;
}
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;
string word[55];
bool cmp(string a,string b){
return a+b>b+a;
}
int main(){
int n;
while(scanf("%d",&n),n)
{
for(int i=0;i<n;i++){
cin>>word[i];
}
sort(word,word+n,cmp);
for(int i=0;i<n;i++)
cout<<word[i];
cout<<endl;
}
return 0;
}