#include <iostream>
using namespace std;
int oglindit(int n)
{
int ogl = 0;
while (n)
{
ogl = ogl * 10 + n % 10;
n /= 10;
}
return ogl;
}
int main()
{
int n, maxi = -10000, cx;
cin >> n;
for (int i = 1; i <= n; ++i)
{
int x;
cin >> x;
if (oglindit(x) > maxi)
{
maxi = oglindit(x);
cx = x;
}
}
cout << cx;
return 0;
}