#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

using namespace std ;

/*ifstream cin ("input") ;
ofstream cout ("output") ;*/


map <string, int> H ;
set <string> S ; 

int solve (string &s, int ind, vector <string> &words) {
	// cout << s << '\n' ;
	if (s == "") {
		H [s] = 1 ;
		return 1 ; 
	}
	if (H.find (s) != H.end()) {
		return H [s] ;
	}
	if (S.find (s) != S.end()) {
		return 1 ; 
	}
	int best = 0 ; 
	for (int j = 0 ; j <(int)words.size() ; ++ j) {
		if (j == ind) continue ; 
		int i = 0 ; 
		while (i < (int)s.size() and i < (int)words[j].size() and s [i] == words[j][i]) {
			++ i ;
		}
		int lim = s.size();
		string suf = "" ; 
		while (i < lim) {
			suf += s [i] ; 
			++ i ; 
		}
		if (suf.size() == s.size()) continue ; 
		 // cout << "sufixul este " << suf << '\n' ;
		best = max(best, solve (suf, ind, words)) ;
	}
	if (best == 0)
		return 0 ; 
	H [s] = 1 ;
	return 1 ;
}
int main(int argc, char const *argv[])
{
	int n ; 
	cin >> n ; 
	vector <string> v (n) ; 
	for (int i = 0 ; i < n ; ++ i) {
		cin >> v [i] ; 
	}
	int best = 0 ;
	string str = "" ; 
	for (int i = 0 ; i < (int)v.size() ; ++ i) {
		if (v [i].size() < best) continue ; 
		S.erase (v[i]) ;
		if (solve (v[i], i, v)) {
			if (best < v [i].size()) {
				best = v [i].size() ;
				str = v [i] ; 
			}
		}
		S.insert (v[i]) ;
		// cout << "=======================\n" ;
	}
	if (best == 0) 
		cout << -1 ;
	else cout << str ;
	return 0;
}