#include<iostream>
#include<stdlib.h>
#include<string.h>
using namespace std;
int check(char a[],char b[]);
int main()
{
char str[21][101];
char temp[100];
int n,i,j;
cin>>n;
for(i=0;i<n;i++)
cin>>str[i];
for(i=0;i<n-1;i++)//大数上浮
for(j=n-1;j>i;j--)
{
if(strcmp(str[j-1],str[j])<0)//后者大
{
strcpy(temp,str[j]);
strcpy(str[j],str[j-1]);
strcpy(str[j-1],temp);
}
if(strcmp(str[j-1],str[j])>0&&check(str[j-1],str[j]))//前者大但还是要换
{
strcpy(temp,str[j]);
strcpy(str[j],str[j-1]);
strcpy(str[j-1],temp);
}
}
for(i=0;i<n;i++)
cout<<str[i];
system("pause");
return 0;
}
int check(char a[],char b[])//已知a比b大了,现在看a是不是短
{
char s1[100],s2[100];
strcpy(s1,a);
strcpy(s2,b);
strcat(s1,b);//strcat会破坏字符串。要新建字符串操作
strcat(s2,a);
if(strcmp(s1,s2)>0) return 0;
else return 1;
}