#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
using namespace std;
bool Compare(const string &a, const string &b)
{
return ((a+b) > (b+a));
}
void GetResult(vector<int> vNums, string &strRlt)
{
strRlt = "";
vector<string> vec;
for(auto num : vNums)
{
stringstream ss;
string str;
ss << num;
ss >> str;
vec.push_back(str);
}
sort(vec.begin(), vec.end(), Compare);
for(auto v : vec)
strRlt += v;
}
int main()
{
int n = 0;
int x = 0;
while(cin >> n)
{
vector<int> vec;
string strRlt;
while(n-- > 0 && cin >> x)
{
if(x < 0) return -1;
vec.push_back(x);
}
if(!vec.empty())
{
GetResult(vec, strRlt);
cout << strRlt << endl;
}
}
return 0;
}