#define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair i_i; typedef pair ll_i; typedef pair d_i; typedef pair ll_ll; typedef pair d_d; struct edge { int v, w; }; ll MOD = 1000000007; ll _MOD = 1000000009; double EPS = 1e-10; int main() { int N; cin >> N; vector S(N); for (int i = 0; i < N; i++) { cin >> S[i]; S[i].push_back('~'); } string T; for (;;) { int i = 0; for (int j = 0; j < N; j++) if (S[j] < S[i]) i = j; if (S[i][0] == '~') break; T.push_back(S[i][0]); S[i].erase(S[i].begin()); } cout << T << endl; }