#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#define MAXN 55
using namespace std;
bool cmp(string x, string y)
{
return x + y > y + x;
}
string str[MAXN];
int main(void)
{
int n;
while (scanf("%d", &n) != EOF && n)
{
for (int i = 0; i < n; i++)
cin >> str[i];
sort(str, str + n, cmp);
for (int i = 0; i < n; i++)
cout << str[i];
cout << endl;
}
return 0;
}