import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container;
import std.numeric, std.math;
import core.bitop;

T RD(T = string)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }

long mod = pow(10, 9) + 7;
long moda(long x, long y) { return (x + y) % mod; }
long mods(long x, long y) { return ((x + mod) - (y % mod)) % mod; }
long modm(long x, long y) { return (x * y) % mod; }

void main()
{
	auto N = RD!long;
	auto A = RDR.split.to!(long[]);
	A.sort();
	
	long last = -1, cnt;
	long[] ans;
	foreach_reverse (e; A)
	{
		if (e == last)
		{
			++cnt;
			if (cnt == 2)
			{
				ans ~= e;
				cnt -= 2;
			}
		}
		else
		{
			cnt = 1;
			last = e;
		}
		if (ans.length == 2) break;
	}

	writeln(ans.length != 2 ? 0 : ans[0] * ans[1]);
	stdout.flush();
}