#include #include #include #include #include #include #include using namespace std; typedef long long LL; const LL MOD=1000000000; struct Comp{ bool operator()(const string& s1, const string& s2){ int i = 0; for(; i < s1.size() && i < s2.size(); i++){ if(s1[i] < s2[i]) return true; else if(s1[i] > s2[i]) return false; } return s1.size() > s2.size(); } }; int main(){ LL N; cin >> N; vector s(N); string ans; for(int i = 0; i < N; i++){ cin >> s[i]; } while(true){ sort(s.begin(), s.end(), Comp()); if(s[0].empty()) break; ans += s[0][0]; s[0] = s[0].substr(1); } cout << ans << endl; return 0; }