#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
using namespace std;
int n, now_max;
string num[1005];
bool out[1005];
string ans;
bool cmp(string a, string b) {
return a + b > b + a;
}
int main() {
freopen("brick.in", "r", stdin);
freopen("brick.out", "w", stdout);
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
cin >> num[i];
}
sort(num + 1, num + n + 1, cmp);
for (int i = 1; i <= n; i++) {
ans += num[i];
}
cout << ans << "\n";
return 0;
}