#include <bits/stdc++.h>

using namespace std;

priority_queue<int> pq;

int main()
{
    int n;
    scanf("%d",&n);
    for(int i = 0 ; i < n ; i++)
    {
        int a;
        scanf("%d",&a);
        pq.push(a);
    }
    int ma1 = INT_MIN;
    int ma2 = INT_MIN;
    while(ma1 == INT_MIN && !pq.empty())
    {
        int tmp;
        if(!pq.empty()){
            tmp = pq.top();
            pq.pop();
        }
        if(!pq.empty())
        {
            if(tmp == pq.top())
            {
                ma1 = tmp;
                pq.pop();
            }
        }
    }
    while(ma2 == INT_MIN && !pq.empty())
    {
        int tmp;
        if(!pq.empty()){
            tmp = pq.top();
            pq.pop();
        }
        if(!pq.empty())
        {
            if(tmp == pq.top())
            {
                ma2 = tmp;
                pq.pop();
            }
        }
    }
    long long result = 1;
    result *= ma1;
    result *= ma2;
    if(ma1 > 0 && ma2 > 0)
    printf("%lld",result);
    else
    printf("0");
}
