#include using namespace std; typedef pair P; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vector s(n); for (int i = 0; i < n; i++) cin >> s[i]; priority_queue, greater

> pq; for (int i = 0; i < n; i++) { s[i] += '}'; pq.push(P(s[i], i)); } string ans = ""; while (!pq.empty()) { P p = pq.top(); pq.pop(); ans += p.first[0]; if (p.first.length() == 2) continue; pq.push(P(p.first.substr(1, p.first.length() - 1), p.second)); } cout << ans << endl; return 0; }