#include<iostream>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<climits>
#include<numeric>
#include<set>
#include<sstream>
#include<map>
#include<vector>
#include<string>

using namespace std;

vector<string> split(string haystack, string needle) {
	vector<string> result;
	int start_pos = 0;
	int found_pos = haystack.find(needle, start_pos);
	while (found_pos != string::npos) {
		int count = found_pos - start_pos;
		string token = haystack.substr(start_pos, count);
		if (!token.empty()) {
			result.push_back(token);
		}
		start_pos = found_pos + needle.length();
		found_pos = haystack.find(needle, start_pos);
	}
	string token = haystack.substr(start_pos, haystack.length()-start_pos);
	if (!token.empty()) {
		result.push_back(token);
	}
	return result;
}
string nameConvert(const string& name) {
	const string DELIMITER = " ";
	stringstream builder;
	auto parts = split(name, DELIMITER);
	for (auto part : parts) {
		part[0] = toupper(part[0]);
		transform(part.begin()+1, part.end(),part.begin()+1, ::tolower);
		builder << part << DELIMITER;
	}
	return builder.str();
}
string dateConvert(const string& date) {
	const string DELIMITER = "/";
	stringstream builder;
	auto parts = split(date, DELIMITER);
	builder << setw(2) << setfill('0') << parts[0] << DELIMITER;
	builder << setw(2) << setfill('0') << parts[1] << DELIMITER;
	builder << parts[2];
	return builder.str();

}

int main() {
	int n;cin >> n;
	vector<string> v;
	for (int i = 0;i < n;i++) {
		string s;cin >> s;
		v.push_back(s);
	}
	sort(v.begin(), v.end(), [](string a, string b) {
		string ab = a + b;
		string ba = b + a;
		return ab > ba;
	});

	for (auto value : v) {
		cout << value;
	}
}

