import java.util.*;
public class Main{
public static void main(String [] args){
Scanner input = new Scanner(System.in);
String [] fun = new String [55];
int n = input.nextInt();
while(n != 0){
for(int i = 0; i < n; i++){
fun[i] = input.next();
for(int j = i; j > 0; j--){
if(maxx(fun[j],fun[j - 1])){
String temp = fun[j];
fun[j] = fun[j - 1];
fun[j - 1] = temp;
}
else
break;
}
}
for(int i = 0; i < n; i++)
System.out.print(fun[i]);
System.out.println();
n = input.nextInt();
}
}
public static boolean maxx(String a,String b){
if((a + b).compareTo((b + a)) > 0)
return true;
else
}
public class Main{
public static void main(String [] args){
Scanner input = new Scanner(System.in);
String [] fun = new String [55];
int n = input.nextInt();
while(n != 0){
for(int i = 0; i < n; i++){
fun[i] = input.next();
for(int j = i; j > 0; j--){
if(maxx(fun[j],fun[j - 1])){
String temp = fun[j];
fun[j] = fun[j - 1];
fun[j - 1] = temp;
}
else
break;
}
}
for(int i = 0; i < n; i++)
System.out.print(fun[i]);
System.out.println();
n = input.nextInt();
}
}
public static boolean maxx(String a,String b){
if((a + b).compareTo((b + a)) > 0)
return true;
else
return false;
//123 1234 1234>123
}}