#include <iostream>
using namespace std ;

int a[10005] = {0};
int b[10000000] = {0};

int main(){
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
      cin >> a[i];
      b[a[i]]++;
    }
    int x = 1, y = 1;
    bool ans = false;
    for(int i = 0; i < n; i++){
      if(b[a[i]] >= 2){
        ans = true;
        if(x * y < x * a[i]){
          y = a[i];
          b[a[i]] -= 2;
        }else if(x * y < a[i] * y){
          x = a[i];
          b[a[i]] -= 2;
        }
      }
    }
    if(ans){
      cout << x * y << endl;
    }else{
      cout << 0 << endl;
    }
}