#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define vec(x) vector<x>
#define pb push_back
#define pii pair<ll,ll>
#define vi vector<ll>
#define vii vector<pair<ll,ll>>
#define matrix(x) vector<vector<x>>
#define all(v) v.begin(),v.end()
#define mem(a,b) memset(a, b, sizeof a)
#define ff first
#define ss second
#define mp make_pair
const int INF = 1e9;
const int MOD = 1e9 + 7;
int main()
{
ll t;
cin>>t;
ll a[t];
for(ll i=0;i<t;i++)
{
    cin>>a[i];
}
sort(a,a+t);
ll x=a[t-1];
ll cont=0;
ll s=0;
ll res=1;
for(ll i=t-1;i>=0;i--)
{

    if(x==a[i])
    {
        cont++;
    }
    else
    {
        cont=1;
        x=a[i];
    }
     if(cont==2)
    {
        s=s+1;
        cont=0;
        res=res*x;
        x=a[i-1];

    }
    if(s==2)
        break;

}
if(s>=2)
cout<<res<<endl;
else
    cout<<0<<endl;
}

#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long N;
    cin >> N;
    map<long, long> A;
    for(size_t i=0;i<N; i++)
    {
        long a;
        cin >> a;
        A[a]++;
    }
    ll max_area = 0;
    ll first_edge=0,second_edge =0;
    for(auto a:A)
    {
        if(a.second >=2)
        {
            if(first_edge == 0) first_edge = a.first;
            if(a.second >= 4)
            {
                first_edge = a.first;
                second_edge = a.first;
            }else
            {
                first_edge = second_edge;
                second_edge = a.first;
            }

        }
        if(first_edge != 0 && second_edge != 0) max_area = max(max_area, first_edge * second_edge);
    }
    cout << max_area << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}