function main(input){
    var max1 = 0;
    var max2 = 0;
    var once = [];

    var tmp = input.split('\n');
    var A = tmp[1].split(' ');

    var index;
    for(var i=0; i<A.length; i++){
        index = once.indexOf(A[i]);
        if(index===-1){
            once.push(A[i]);
        }
        else{
            once.splice(index,1);
            if(max2<A[i]){
                if(max1<A[i]){
                    max2 = max1;
                    max1 = A[i];
                }else{
                    max2 = A[i];
                }
            }
        }
    }
    console.log(max2*max1);

}

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