#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
int main()
{
    int n,i,a,x,y,k,sum=0;
    cin >> n;
    vector <int > v;
    map <int,int> m;
    for(i=0;i<n;i++) { cin>>a; v.push_back(a); }

    for(i=0;i<n;i++)
    {
        m[v[i]]=count(v.begin(),v.end(),v[i]);
        if(m[v[i]]<2) { m.erase(v[i]); replace(v.begin(),v.end(),v[i],0); }
        sum+=m[v[i]];
        if(sum==n) break;
        }

    x=*max_element(v.begin(),v.end());
    replace(v.begin(),v.end(),x,0);

    if(m[x]>=4){ cout << x*x; }
    else if (m[x]>=2)
    {
        x*=*max_element(v.begin(),v.end());
        cout << x;
    }
    else cout << "0";
}
