#include <iostream>
#include <map>

using namespace std;

int main()
{
    map<int ,int> m;
    int n;
    cin>>n;
    for(int i=1,x;i<=n;++i)
        cin>>x,m[x]++;
    map<int,int>::reverse_iterator it;
    it=m.rbegin();
    int a=0,b=0,flag=0;
    while(flag!=2 && it != m.rend())
    {
        if((*it).second>=2)
            b=a,a=(*it).first,flag++;
        ++it;
    }
    if(flag==2)
        cout<<(long long)a*b<<endl;
    else
        cout<<"0"<<endl;
    return 0;
}