#include <iostream>
#include<algorithm>
using namespace std ;

int a[100005] = {0};

int main(){
  int n;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  sort(a, a + n);
  int ans = 0;
  int x = 1, y = 1;
  for(int  i = 0; i < n; i++){
    if(a[i] == a[i + 1]){
      ans++;
      if(x * y <= x * a[i] && ans % 2 == 1){
        y = a[i];
      }else if(x * y <= a[i] * y){
        x = a[i];
      }
      i++;
    }
  }
  if(ans >= 2){
    cout << x * y << '\n';
  }else{
    cout << 0 << '\n';
  }
}
