function main(input){
    var hen = [0,0];
    var tmp = input.split('\n');
    var n = Number(tmp[0]);
    var A = tmp[1].split(' ');

    A.sort(function(a,b){return a - b;});

    var j=0;
    var sq = 1;
    for(var i=n-1; i>0; i--){
        if(A[i]==A[i-1]){
            sq=sq*A[i];
            i--;
            j++;
            if(j>=2){
                break;
            }
        }
    }

    if(j<2)
        console.log(Number(0));
    //console.log(A);
    else{
        console.log(Number(sq));
    }
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));