#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
int n;
cin >> n;
vector<string> a(n);
vector<string> b(n);
string max = "";
for (int i = 0; i < n; i++)
{
cin >> a[i];
b[i] = a[i];
string reversed = "";
for (int j = a[i].size() - 1; j >= 0; j--)
{
reversed += a[i][j];
}
if (reversed == b[i])
{
if (b[i] > max)
{
max = b[i];
}
}
}
cout << max;
return 0;
}