// Try AtCoder
/// author: Leonardone @ NEETSDKASU
import std.stdio     : readln, writeln;
import std.string    : chomp;
import std.array     : split;
import std.conv      : to;
import std.algorithm : sort;

auto getVals(T)() { return readln.chomp.split.to!(T[]); }

void main() {
    auto n = getVals!int()[0];
    auto xs = getVals!long();
    xs.sort!("a > b");
    int c = 0;
    long ans = 1;
    for (int i = 1; i < n; i++) {
        if (xs[i] == xs[i-1]) {
            ans *= xs[i];
            xs[i] = -1;
            c++;
            if (c == 2) {
                writeln(ans);
                return;
            }
        }
    }
    writeln(0);
}