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

bool cmp(int p1,int p2){

    return p1>p2;


}

int main(){



int n,temp1;
scanf("%d",&n);
vector<int> v;
vector<int> ans;
for(int i=0;i<n;i++){
    scanf("%d",&temp1);
    v.push_back(temp1);
}

sort(v.begin(),v.end());
int c = -1,b;
for(int j=0;j<n;j++){
if(c!=v[j]){
    c = v[j];
    b=1;
}
if(b==2){
    ans.push_back(c);
}
b++;
}

int answer =1;
vector<int>::iterator it;

if(!ans.empty()){
for(it = ans.end()-1;it!= ans.end()-3;it--){

answer = answer*(*it);
}
printf("%d",answer);
}
else printf("0");
}
