#include #define rep(i,a,b) for(int i=int(a);i b.size())return a[i-1] < a[i]; else return b[i-1] < b[i]; } main(){ int N; cin >> N; //priority_queue, comp() > que; priority_queue, greater > que; /* priority_queue, function > que( [](string a, string b){ int i; for(i = 0;i < min(a.size(), b.size()); i++){ if(a[i] != b[i])return a[i] > b[i]; } if(a.size() > b.size())return a[i-1] <= a[i]; else return b[i-1] <= b[i]; } ); */ rep(i,0,N){ string s; cin >> s; que.push(s); } string ans; while(!que.empty()){ auto str = que.top(); que.pop(); if(str.length() != 0){ ans.push_back(str[0]); que.push(str.substr(1)); } } cout << ans << endl; }