#include using namespace std; #define rep(i, n) for(int i = 0; i < (int)n; ++i) #define FOR(i, a, b) for(int i = a; i < (int)b; ++i) #define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i) using ll = long long; using ld = long double; const int Inf = 1e9; const double EPS = 1e-9; const int MOD = 1e9 + 7; int main() { cin.tie(nullptr); ios::sync_with_stdio(0); int n; cin >> n; priority_queue, greater > pq; rep (i, n) { string s; cin >> s; s += '~'; pq.push(s); } while (!pq.empty()) { string s = pq.top(); pq.pop(); cout << s[0]; if (s.size() <= 2) continue; pq.push(s.substr(1)); } cout << endl; return 0; }