#include using namespace std; string word[105]; bool ok[105][105]; int main() { int n; cin >> n; for(int i = 0; i < n; ++i) { cin >> word[i]; } string ans = ""; for(int i = 0; i < n; ++i) { ok[i][0] = true; for(int j = 0; j < word[i].size(); ++j) { if(!ok[i][j]) continue; for(int oth = 0; oth < n; ++oth) { if(word[i].substr(j, word[oth].size()) == word[oth]) ok[i][j + word[oth].size()] = true; } } if(ok[i][word[i].size()]) { ans = max(ans, word[i], [](string a, string b) {return a.size() < b.size();}); } } if(ans == "") cout << -1 << endl; else cout << ans << endl; return 0; }