#include<iostream>
#include<queue>
#include<stdio.h>
#include<vector>
#include<set>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    cin>>n;
    set<int>S;
    vector<int>B;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        if(S.count(x)){
        S.erase(x);
        B.push_back(x);}
        else
        S.insert(x);
    }
    sort(B.begin(),B.end());
    if((int)B.size()<2){
        printf("0\n");
    }
    else
    {
        int x=(int)B.size();
        printf("%lld",1LL*B[x-1]*B[x-2]);
    }
    return 0;
}
