#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<set>
using namespace std;
int mapp[100005];

int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0; i<n; i++)
        scanf("%d",&mapp[i]);
    sort(mapp,mapp+n);
    int p=n-1;
    int res=1;
    int  flag=0;
              while(p)
    {
        p--;
        if(mapp[p+1]==mapp[p])
        {
            res*=mapp[p];
            flag++;
            p--;
            break;
        }

    }
    while(p)
    {
        p--;
        if(mapp[p+1]==mapp[p])
        {
            res*=mapp[p];
            flag++;
            p--;
            break;
        }

    }
    if(flag==2)
        cout<<res;
    else cout<<"0";

}
