function Main(input) {
  input = input.split("\n");
  var n = parseInt(input[0].split(" ")[0]);
  tmp = input[1].split(" ");
  a = new Array(n).fill(0);
  for(i=0;i<n;i++){
    a[i]=parseInt(tmp[i]);
  }
  var ans = 0;
  a.sort(function(a,b){
    if( a > b ) return -1;
    if( a < b ) return 1;
    return 0;
  });
  var x =0;
  var y =0;
  for(i=0;i<n-1;i++){
    if(a[i]==a[i+1]){
      if(a[i]>x){
        x=a[i];
      }else if(a[i]>y&&a[i]!=x){
        y=a[i];
      }
    }
  }
  ans = x * y;
  if(x!=0&&y==0){

    var reg = new RegExp(x,"g");
    if(a.match(reg).length>=4){
      ans=x**2;
    }
  }
  console.log('%s', ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));