import std.stdio, std.string, std.conv, std.bigint, std.typecons, std.algorithm, std.array, std.math, std.range, std.functional;
 
void main() {
    auto N = readln.chomp.to!int;
    sort(readln.split.to!(int[])).group.filter!(g => g[1] >= 2).array.pipe!((g) {
        if (g.length == 0) return 0;
        if (g[$-1][1] >= 4) return g[$-1][0]^^2;
        if (g.length == 1) return 1;
        return g[$-1][0] * g[$-2][0];
    }).writeln;
}
