'use strict'

function Main(input) {
  const inputs = input.split('\n');
  const bars = inputs[1].split(' ').sort().reverse();
  const sides = [];
  let current = 0;
  let flag = false;
  for (let i = 0; i < bars.length; i++) {
	const bar1 = bars[i];
    const bar2 = bars[i + 1] ? bars[i + 1] : null;
    if (bar1 === bar2 && !flag) {
      sides.push(bar1);
      flag = true;
    } else {
      flag = false;
    }
    if (sides.length === 2) break;
  }

  if (sides.length === 2) {
    console.log(sides[0] * sides[1]);
  } else {
    console.log(0);
  }
}

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