#include using namespace std; using ll = long long; using ul = unsigned long; using ull = unsigned long long; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); const string G{ 'z' + 1 }; int n; cin >> n; priority_queue, greater > pq; for (int i = 0; i < n; ++i) { string s; cin >> s; pq.push(s + G); } stringstream ss; while (!pq.empty()) { string s = pq.top(); ss << s[0]; pq.pop(); if (s.size() > 1 && s.substr(1) != G) pq.push(s.substr(1)); } cout << ss.str() << "\n"; return 0; }