unittest
{
	assert( [ "6", "3 1 2 4 2 1" ].parse.expand.solve == 2 );
	assert( [ "4", "1 2 3 4" ].parse.expand.solve == 0 );
	assert( [ "10", "3 3 3 3 4 4 4 5 5 5" ].parse.expand.solve == 20 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.strip.to!( long );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( as );
}

auto solve( long[] as )
{
	auto gs = as.sort!( ( a, b ) => b < a ).group;
	
	auto a = 0L;
	auto b = 0L;
	foreach( g; gs )
	{
		if( a == 0 && 4 <= g[ 1 ] )
		{
			a = g[ 0 ];
			b = g[ 0 ];
			break;
		}
		if( 2 <= g[ 1 ] )
		{
			if( a == 0 )
			{
				a = g[ 0 ];
				// まだ片方の辺しか決まってないので続行
			}
			else
			{
				b = g[ 0 ];
				break;
			}
		}
	}
	
	return a * b;
}
