// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

#define pb push_back

#define rep(i,n) for(int i=0;i<n;i++)

#define rep1(i,n) for(int i=1;i<=n;i++)

#define mp make_pair

#define F first

#define S second

#define IOS ios_base::sync_with_stdio(0); cin.tie(0)

typedef long long ll;

vector<int> g[100005];

ll q,n;

ll a[1005];

int main()

{

    //IOS;

    while(cin>>n)

    {

        map<ll,ll> m;

        vector<ll> ans;

        rep(i,n)

        {

            ll tmp;

            cin>>tmp;

            m[tmp]++;

            if(m[tmp]%2==0) ans.pb(tmp);

        }

        sort(ans.begin(),ans.end());

        if(ans.size()<2) cout<<0<<"\n";

        else cout<<ans[ans.size()-1]*ans[ans.size()-2]<<"\n";

    }

    return 0;

}




// Faster C++ solution for the same problem (measured speedup: 3.5925842706565296x):
///CCCC

/*

#include<stdio.h>

#include<string.h>

#include<iostream>

#include<algorithm>

using namespace std;

int mp[1010][1010];

int sum[1010][1010];

int main()

{

    int t,p=1;

    scanf("%d",&t);

    while(t--)

    {

        int r,c;

        scanf("%d %d",&r,&c);

        memset(mp,0,sizeof(mp));

        memset(sum,0,sizeof(sum));

        for(int i=1; i<=r; i++)

        {

            for(int j=1; j<=c; j++)

            {

                scanf("%d",&mp[i][j]);

            }

        }

        for(int i=1; i<=r; i++)

        {

            for(int j=1; j<=c; j++)

            {

                int max1;

                max1=max(mp[i+1][j],mp[i][j+1]);

                sum[r][c]+=max(mp[i+1][j+1],max1);

                 printf("%d***\n",sum[r][c]);

            }

        }

        printf("Scenario #%d:\n",p++);

        printf("%d\n",sum[r][c]);

        printf("\n");

    }

    return 0;

}*/

///EEE

/*

#define MAX_INT 0x3f3f3f3f

#define MIN_INT -MAX_INT

int v[4100],w[4100];

int dp[13000];

int main()

{

    int n,m;

    scanf("%d %d",&n,&m);

    for(int i=0;i<n;i++)

    scanf("%d %d",&v[i],&w[i]);

    for(int i=0;i<n;i++)

    {

        for(int j=m;j>=v[i];j--)

        {

            dp[j]=max(dp[j],dp[j-v[i]]+w[i]);///啥意思？

        }

    }

    printf("%d\n",dp[m]);

    return 0;

}

*/



///FFFF

/*

int main()

{

    for(int j=m;j>=v[i];j--)

        {

            dp[j]=max( dp[j],dp[ j-v[i] ]+w[i] );

        }

    for(int j=v[i];j<=m;j++)

    {

        dp[i][j]=max( dp[j],dp[ j-v[i] ]+w[i] );

    }

    return 0;

}



*/

///DDDD

/*int a[41000];

int dp[41000];

int main()

{



    int T;

    scanf("%d",&T);

    while(T--)

    {

        int n;

        scanf("%d",&n);

        memset(a,0,sizeof(a));

        memset(dp,0,sizeof(dp));

        for(int i=0;i<n;i++)

            scanf("%d",&a[i]);

        int j=0;

        dp[0]=a[0];



        for(int i=1;i<n;i++)

        {

            if(a[i]>dp[j])

            {

                j++;

                dp[j]=a[i];

            }

            else

            {

                int pow=lower_bound( dp,dp+j,a[i] )-dp;

                dp[pow]=a[i];

                //printf("%d&&\n",pow);

            }

        }

        printf("%d\n",j+1);

    }

    return 0;

}*/

#include<stdio.h>

#include<string.h>

#include<iostream>

#include<algorithm>

#define ll long long

using namespace std;

ll n,a[100100],sum=1,k=0;

int main()

{

    scanf("%lld",&n);

    for(int i=1; i<=n; i++)

    {

        scanf("%lld",&a[i]);

    }

    sort(a+1,a+1+n);

    for(int i=n; i>=2; i--)

    {

        if(a[i]==a[i-1])

        {

            sum*=a[i];

            i-=1;

            k++;

            //printf("%d***\n",k);

            if(k==2) break;

        }

    }

    if(k<2) printf("0\n");

    else  printf("%lld\n",sum);

    return 0;

}