#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    long long a[n+10];
    int i,j;
    for(i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
    }
    sort(a,a+n);
    vector<long long>rect;
    vector<long long>square;
    for(i=1;i<n;i++)
    {
        if(a[i]==a[i-1])
        {
            rect.push_back(a[i]);
        }
    }
    int rects=rect.size();
    for(i=2;i<rects;i++)
    {
        if(rect[i]==rect[i-1]&&rect[i]==rect[i-2])
        {
            square.push_back(rect[i]);
        }
    }
    int sq=square.size();
    long long ans1=0,ans2=0;
    if(sq>=1)
    {
        ans1=square[sq-1]*square[sq-1];
    }
    if(rects>=2)
    {
        int x=0;
        for(i=rects-2;i>=0;i--)
        {
            if(rect[i]!=rect[rects-1])
            {
                x=1;
                break;
            }
        }
        if(x==1)
        {
            ans2=rect[rects-1]*rect[i];
        }
    }
    if(ans1>ans2)
    {
        printf("%lld\n",ans1);
    }
    else
    {
        printf("%lld\n",ans2);
    }
    return 0;

}
