#include<stdio.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
ll num[100005];
bool cmp(ll x,ll y)
{
    return x>y;
}
int main()
{
    int n;
    int flag=1;
    ll a,c;
    while(~scanf("%d",&n))
    {
        for(int i=0; i<n; i++)
        {
            scanf("%lld",&num[i]);
        }
        sort(num,num+n,cmp);
        int f=0;
        for(int i=0; i<n; i++)
        {
            if(num[i]==num[i+1]&&f==0)
            {
                a=num[i+1];
                f=1;
                i++;
               ///  printf("%d\n",a);
            }
            else  if(num[i]==num[i+1]&&f==1)
            {
                c=num[i+1];
                i++;
             ///    printf("%d\n",c);
                break;
            }
            else if(i==n-1)
                flag=0;
        }
        ll sum=a*c;
        if(flag)
            printf("%lld\n",sum);
        else
            printf("0\n");
    }
    return 0;
}
/**
6
1 1 2 2 3 3
**/
