#include<bits/stdc++.h>
#define X first
#define Y second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define mm(x,n) memset(x,n,sizeof(x))
#define IOS cin.tie(0); ios::sync_with_stdio(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

bool cmp(int a,int b){
	return a > b;
}

int main(){
	int N;
	while(cin >> N){
	    int arr[N];
	    bool flag = 0;
		rep(i,0,N-1) cin>>arr[i];
		sort(arr , arr + N , cmp);
		rep(i,0,N-4){
			if(arr[i] == arr[i+1] && arr[i+2] == arr[i+3]){
			    cout << arr[i] * arr[i+2] << "\n";
			    flag = 1;
			    break;
			}
		}	
		if(!flag) puts("0");
	}
}