#include using namespace std; void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } int main() { fast_io(); int n; cin >> n; vector s(n); for (int i = 0; i < n; i++) { cin >> s[i]; s[i] += 'z' + 1; } priority_queue, greater<>> pq(s.begin(), s.end()); string ans = ""; while (!pq.empty()) { string t = pq.top(); pq.pop(); reverse(t.begin(), t.end()); ans += t.back(); t.pop_back(); reverse(t.begin(), t.end()); if (t.size() > 1) { pq.push(t); } } cout << ans << endl; }