#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#define ll long long
using namespace std;
int main(){
	int n;
	cin>>n;
	ll a[n];
	int j=0;
	map<ll,ll> m;
	ll num;
	for(int i=0;i<n;i++){
		cin>>num;
		m[num]++;
	}

	map<ll, ll>::iterator  iter;
    for(iter = m.begin(); iter != m.end(); iter++){
        if(iter->second>=2){
        	a[j++]=iter->first;
		}
		//cout<<iter->first<<" "<<iter->second<<endl;
    }

    sort(a,a+n);
    /*for(int i=0;i<j;i++){
    	cout<<a[i]<<" ";
	}*/
	if(j<2){
        cout<<0<<endl;
	}else{
        cout<<a[j-1]*a[j-2]<<endl;
	}
	return 0;
}
