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

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i=0; i<n; i++) cin >> a[i];
	sort(a.begin(), a.end());
	
	vector<int> cand;
	for(int i=0; i<n-1; i++){
		if(a[i]==a[i+1]){
			cand.push_back(a[i]);
			i++;
		}
	}
	if((int)cand.size() < 2){
		cout << 0 << endl;
	}else{
		cout << (long long int)cand.back() * cand[cand.size()-2] << endl;
	}
	return 0;
}