#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;

int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    map<ll, ll> a;

    for(int i = 0; i < N; i++) {
        ll A;
        cin >> A;
        a[A]++;
    }

    vector<ll> x;

    for(auto i = begin(a); i != a.end(); i++) {
        for(int j = i -> second; j > 1; j -= 2) {
            x.push_back(i -> first);
        }
    }

    sort(x.begin(), x.end(), greater<ll>());

    if(x.size() < 2) cout << 0 << endl;
    else cout << x[0] * x[1] << endl;
}
#include <bits/stdc++.h>
using namespace std;
using pp=pair<int,char>;
using ll=long long;

int main() {
  int N;
  cin >> N;
  vector<int> A(N), V(2, 0);
  
  for (int i=0; i<N; i++) {
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  A.push_back(0);
  int s=1;
  for (int i=0; i<N; i++) {
    if (A[i]==A[i+1]) {
      s++;
    }
    else {
      int a=A[i];
      int n=s/2;
      //cout << N << endl;
      for (int j=0; j<n; j++) {
        V.push_back(a);
      }
      s=1;
    }
  }
  ll p=V[V.size()-1], q=V[V.size()-2];
  
  sort(V.begin(), V.end());
  cout << p*q << endl;
}
 