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

int n;
map<int,int> A;
vector<int> B;

int main(){
	cin >> n;

	for(int i=0;i<n;i++){
		int x;
		cin >> x;
		A[x]++;
		if(A[x]==2){
			B.push_back(x);
			A[x]=0;
		}
	}

	sort(B.begin(),B.end());
	reverse(B.begin(),B.end());

	if(B.size()>1)	cout << (long long)B[0]*B[1] << endl;
	else	cout << 0 << endl;

	return 0;
}