#include #define ll long long using namespace std; ll n; string s[110]; int a[110][110]; bool cmp(string a, string b) { return (a.size() < b.size()); } void poz(int x, int y) { string c = s[x], S = s[y]; int i = 0, j = 0; while (i < S.size()) { j = 0;bool u = 0; while (S[i] == c[j] && j < c.size() && i < S.size()) i++, j++, u = 1; if (j == c.size()) a[x][y] += c.size(); if (u) continue; else i++; } } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i = 1; i <= n; i++) cin >> s[i]; sort(s+1, s+n+1,cmp); for (int i = 1; i <= n; i++) { for (int j = i + 1; j <= n; j++) poz(i, j); } for (int i = n; i; i--) { int sum = 0; for (int j = 1; j < i; j++) sum += a[j][i]; if (sum >= s[i].size()) return cout << s[i], 0; } cout << -1; }