"use strict"

const main = arg => {
  arg = arg.trim().split("\n");
  const N = parseInt(arg[0]);
  const A = arg[1].split(" ").map(n=>parseInt(n)).sort((a,b)=>a-b);
  
  let pairNums = [];

  for(let i=1; i<=N; i++) {
      if(A[i] === A[i - 1]) {
        pairNums.push(A[i]);
        i++;
      }
  }
  
  if(!pairNums.length) {
      console.log(0);
      return;
  }
  
  pairNums.sort((a,b)=>b-a);
  
  console.log(pairNums[0] * pairNums[1]);
}

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