#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int n;
while( cin >> n )
{
int x = 0 , y = 0 , k[ n ] , l;
for ( int i = 0 ; i < n ; i++ ) cin >> k[ i ];
sort( k , k + n );
for( int i = n - 1 ; i >= 0 ; i-- )
{
if ( x <= y )
{
x *= 10;
x += k[ i ];
}
else
{
y *= 10;
y += k[ i ];
}
}
l = x * y;
cout << l << endl;
}
return 0;
}