#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N,s,count;
  s=1;
  count=0;
  cin >> N;
  vector<long long> A(N);
  for(long long i=0;i<N;i++){cin >> A[i];}
  sort(A.begin(), A.end());
  for(long long i=N-1;i>=0;i--){
    if(A[i-1]==A[i]){
      count++; 
      s*=A[i];
      i--;
    }
    if(count==2){
      cout << s << endl;
      return 0;
    }
  }
  cout << 0 << endl;
}