stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <bits/stdc++.h>

#define ll long long

using namespace std;

bool cmp(ll a, ll b)

{

    return a > b;

}

int main()

{

    int n;

    while (cin >> n)

    {

        ll b[n];

        map<int, int> a;

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

            cin >> b[i];

        sort(b, b + n, cmp);

        ll x[3];

        int cnt = 0;

        int tmp = -1;

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

        {

            a[b[i]]++;

            if (a[b[i]] == 2)

            {

                x[cnt++] = b[i];

                tmp = b[i];

            }

            else if (a[b[i]] == 4 && b[i] == tmp)



            {

                x[cnt++] = b[i];

            }

            if (cnt == 2)

                break;

        }

        if (cnt != 2)

        {

            cout << "0" << endl;

            continue;

        }

        ll ans = x[0] * x[1];

        cout << ans << endl;

    }

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.30253612664689x):
#include<stdio.h>

#include<string.h>

#include<algorithm>

using namespace std;

int a[100005];

int main()

{

    int n,falg=0;



    scanf("%d",&n);

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

    {

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

    }

    sort(a,a+n);

    long long m,p;

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

    {

        if(a[i]==a[i+1]&&falg==0)

        {

            m=a[i];

            //printf("%d\n",a[i]*a[i+2]);

            i--;

            falg++;

        }

        else if(a[i]==a[i+1]&&falg==1)

        {

            p=a[i];

            falg=2;

            break;

        }



    }



    if(falg!=2)

        printf("0\n");

    else

        printf("%lld",m*p);

    return 0;

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

#define hi ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

#define pb push_back

#define emb emplace_back

#define mp make_pair

#define srt(a) sort(a.begin(), a.end())

#define rsort(a) sort(a.rbegin(), a.rend())

#define reverse(a) reverse(a.begin(), a.end())

#define F first

#define S second

#define pii pair<int, int>

#define vi vector<int>

#define rep(i, a, b) for (int i = (a); i < (b); i++)

#define de(x) cout << #x << " is " << x << '\n'

typedef long long ll;

using namespace std;

int main()

{

    hi;

    int n, a;

    cin >> n;

    set<int> se;

    vector<int> res;

    rep(i, 0, n)

    {

        cin >> a;

        if (se.count(a))

        {

            se.erase(a);

            res.pb(a);

        }

        else

            se.insert(a);

    }

    rsort(res);

    if (res.size() >= 2)

    {

        cout << (ll)res[0] * (ll)res[1] << '\n';

    }

    else

        cout << 0;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.356122406541812x):
#include<stdio.h>

#include<string.h>

#include<algorithm>

using namespace std;

int a[100005];

int main()

{

    int n,falg=0;



    scanf("%d",&n);

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

    {

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

    }

    sort(a,a+n);

    long long m,p;

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

    {

        if(a[i]==a[i+1]&&falg==0)

        {

            m=a[i];

            //printf("%d\n",a[i]*a[i+2]);

            i--;

            falg++;

        }

        else if(a[i]==a[i+1]&&falg==1)

        {

            p=a[i];

            falg=2;

            break;

        }



    }



    if(falg!=2)

        printf("0\n");

    else

        printf("%lld",m*p);

    return 0;

}
// Slower C++ solution:
#include <iostream>

#include<algorithm>

using namespace std ;



long long int a[100005] = {0};



int main(){

      int n;

      cin >> n;

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

        cin >> a[i];

      }

      sort(a, a + n);

      long long int x = 0, y = 0;

      for(int  i = n - 1; i >= 0; i--){

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

            if(x == 0){

                x = a[i];

            }else if(y == 0){

                y = a[i];

                break;

            }

            i--;

        }

      }

      cout << x * y << '\n';

}


// Faster C++ solution for the same problem (measured speedup: 5.231586482384997x):
#include<stdio.h>

#include<string.h>

#include<algorithm>

using namespace std;

int a[100005];

int main()

{

    int n,falg=0;



    scanf("%d",&n);

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

    {

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

    }

    sort(a,a+n);

    long long m,p;

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

    {

        if(a[i]==a[i+1]&&falg==0)

        {

            m=a[i];

            //printf("%d\n",a[i]*a[i+2]);

            i--;

            falg++;

        }

        else if(a[i]==a[i+1]&&falg==1)

        {

            p=a[i];

            falg=2;

            break;

        }



    }



    if(falg!=2)

        printf("0\n");

    else

        printf("%lld",m*p);

    return 0;

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

using namespace std;

int main(void)

{

	ios_base::sync_with_stdio(0);cin.tie(0);

	int n,t=0;

	cin>>n;

	long long int a[n+5],ans[2]={0};

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

		cin>>a[i];

	sort(a,a+n,greater<int>() );

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

	{

		if(a[i]==a[i+1])	ans[t++]=a[i],i++;

		if(t==2)	break;

	}

	cout<<ans[0]*ans[1]<<endl;

}


// Faster C++ solution for the same problem (measured speedup: 5.298940932538971x):
#include<stdio.h>

#include<string.h>

#include<algorithm>

using namespace std;

int a[100005];

int main()

{

    int n,falg=0;



    scanf("%d",&n);

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

    {

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

    }

    sort(a,a+n);

    long long m,p;

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

    {

        if(a[i]==a[i+1]&&falg==0)

        {

            m=a[i];

            //printf("%d\n",a[i]*a[i+2]);

            i--;

            falg++;

        }

        else if(a[i]==a[i+1]&&falg==1)

        {

            p=a[i];

            falg=2;

            break;

        }



    }



    if(falg!=2)

        printf("0\n");

    else

        printf("%lld",m*p);

    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <algorithm>

#include <map>

using namespace std;

typedef long long ll;

map<ll, int> mp;

int main() {

    int n;

    ll t;

    cin >> n;

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

        cin >> t;

        mp[t] ++;

    }

    ll A[mp.size()];

    int i = 0;

    for (auto it = mp.rbegin(); it != mp.rend(); ++it) {

        if ((*it).second >= 2) A[i++] = (*it).first;

        if ((*it).second >= 4) A[i++] = (*it).first;

        if (i >= 2) break;

    }



    if (i >= 2) cout << A[0] * A[1] << endl;

    else cout << "0" << endl;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.25618723647327x):
#include<stdio.h>

#include<algorithm>

using namespace std;

int a[100005];

int main()

{

    int n,flag=0;

    long long p,q;

    scanf("%d",&n);

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

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

    sort(a,a+n);

    for(int i=n-1;i>0;)

    {

        if(a[i]==a[i-1]&&flag==0)

        {

            p=a[i];

            flag=1;

            i=i-2;

        }

        else if(a[i]==a[i-1]&&flag==1)

        {

            q=a[i];

            flag=2;

            break;

        }

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

            i--;

    }

    if(flag!=2)

        printf("0\n");

    else

        printf("%lld\n",p*q);

    return 0;

}
// Slower C++ solution:
#include<iostream>

#include<algorithm>

using namespace std;

#define ll long long

int main()

{

	ll n;

	cin>>n;

	ll a[100010];

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

	{

		cin>>a[i];

	}

	sort(a,a+n);

	ll k,m;

	ll x,y;

	for(k=n-1;k>=0;k--)

	{

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

		{

			x=a[k];

			break;

		}

	}

	//cout<<k<<" ";

	for(m=k-2;m>=0;m--)

	{

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

		{

			y=a[m];

			break;

		}

	}

	if(k<0||m<0)

	{

		cout<<"0"<<endl;

	}

	else

	{

		cout<<x*y<<endl;

	}

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.341000614871021x):
#include<stdio.h>

#include<algorithm>

using namespace std;

int a[100005];

int main()

{

    int n,flag=0;

    long long p,q;

    scanf("%d",&n);

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

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

    sort(a,a+n);

    for(int i=n-1;i>0;)

    {

        if(a[i]==a[i-1]&&flag==0)

        {

            p=a[i];

            flag=1;

            i=i-2;

        }

        else if(a[i]==a[i-1]&&flag==1)

        {

            q=a[i];

            flag=2;

            break;

        }

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

            i--;

    }

    if(flag!=2)

        printf("0\n");

    else

        printf("%lld\n",p*q);

    return 0;

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

#define ll long long

using namespace std;

bool cmp(ll a, ll b)

{

    return a > b;

}

int main()

{

    int n;

    while (cin >> n)

    {

        ll b[n];

        map<int, int> a;

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

            cin >> b[i];

        sort(b, b + n, cmp);

        ll x[3];

        int cnt = 0;

        int tmp = -1;

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

        {

            a[b[i]]++;

            if (a[b[i]] == 2)

            {

                x[cnt++] = b[i];

                tmp = b[i];

            }

            else if (a[b[i]] == 4 && b[i] == tmp)



            {

                x[cnt++] = b[i];

            }

            if (cnt == 2)

                break;

        }

        if (cnt != 2)

        {

            cout << "0" << endl;

            continue;

        }

        ll ans = x[0] * x[1];

        cout << ans << endl;

    }

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.300316071834166x):
#include<stdio.h>

#include<algorithm>

using namespace std;

int a[100005];

int main()

{

    int n,flag=0;

    long long p,q;

    scanf("%d",&n);

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

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

    sort(a,a+n);

    for(int i=n-1;i>0;)

    {

        if(a[i]==a[i-1]&&flag==0)

        {

            p=a[i];

            flag=1;

            i=i-2;

        }

        else if(a[i]==a[i-1]&&flag==1)

        {

            q=a[i];

            flag=2;

            break;

        }

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

            i--;

    }

    if(flag!=2)

        printf("0\n");

    else

        printf("%lld\n",p*q);

    return 0;

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

#define hi ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

#define pb push_back

#define emb emplace_back

#define mp make_pair

#define srt(a) sort(a.begin(), a.end())

#define rsort(a) sort(a.rbegin(), a.rend())

#define reverse(a) reverse(a.begin(), a.end())

#define F first

#define S second

#define pii pair<int, int>

#define vi vector<int>

#define rep(i, a, b) for (int i = (a); i < (b); i++)

#define de(x) cout << #x << " is " << x << '\n'

typedef long long ll;

using namespace std;

int main()

{

    hi;

    int n, a;

    cin >> n;

    set<int> se;

    vector<int> res;

    rep(i, 0, n)

    {

        cin >> a;

        if (se.count(a))

        {

            se.erase(a);

            res.pb(a);

        }

        else

            se.insert(a);

    }

    rsort(res);

    if (res.size() >= 2)

    {

        cout << (ll)res[0] * (ll)res[1] << '\n';

    }

    else

        cout << 0;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.353879916336714x):
#include<stdio.h>

#include<algorithm>

using namespace std;

int a[100005];

int main()

{

    int n,flag=0;

    long long p,q;

    scanf("%d",&n);

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

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

    sort(a,a+n);

    for(int i=n-1;i>0;)

    {

        if(a[i]==a[i-1]&&flag==0)

        {

            p=a[i];

            flag=1;

            i=i-2;

        }

        else if(a[i]==a[i-1]&&flag==1)

        {

            q=a[i];

            flag=2;

            break;

        }

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

            i--;

    }

    if(flag!=2)

        printf("0\n");

    else

        printf("%lld\n",p*q);

    return 0;

}
// Slower C++ solution:
#include <iostream>

#include<algorithm>

using namespace std ;



long long int a[100005] = {0};



int main(){

      int n;

      cin >> n;

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

        cin >> a[i];

      }

      sort(a, a + n);

      long long int x = 0, y = 0;

      for(int  i = n - 1; i >= 0; i--){

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

            if(x == 0){

                x = a[i];

            }else if(y == 0){

                y = a[i];

                break;

            }

            i--;

        }

      }

      cout << x * y << '\n';

}


// Faster C++ solution for the same problem (measured speedup: 5.229396132621977x):
#include<stdio.h>

#include<algorithm>

using namespace std;

int a[100005];

int main()

{

    int n,flag=0;

    long long p,q;

    scanf("%d",&n);

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

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

    sort(a,a+n);

    for(int i=n-1;i>0;)

    {

        if(a[i]==a[i-1]&&flag==0)

        {

            p=a[i];

            flag=1;

            i=i-2;

        }

        else if(a[i]==a[i-1]&&flag==1)

        {

            q=a[i];

            flag=2;

            break;

        }

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

            i--;

    }

    if(flag!=2)

        printf("0\n");

    else

        printf("%lld\n",p*q);

    return 0;

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

using namespace std;

int main(void)

{

	ios_base::sync_with_stdio(0);cin.tie(0);

	int n,t=0;

	cin>>n;

	long long int a[n+5],ans[2]={0};

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

		cin>>a[i];

	sort(a,a+n,greater<int>() );

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

	{

		if(a[i]==a[i+1])	ans[t++]=a[i],i++;

		if(t==2)	break;

	}

	cout<<ans[0]*ans[1]<<endl;

}


// Faster C++ solution for the same problem (measured speedup: 5.296722382954649x):
#include<stdio.h>

#include<algorithm>

using namespace std;

int a[100005];

int main()

{

    int n,flag=0;

    long long p,q;

    scanf("%d",&n);

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

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

    sort(a,a+n);

    for(int i=n-1;i>0;)

    {

        if(a[i]==a[i-1]&&flag==0)

        {

            p=a[i];

            flag=1;

            i=i-2;

        }

        else if(a[i]==a[i-1]&&flag==1)

        {

            q=a[i];

            flag=2;

            break;

        }

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

            i--;

    }

    if(flag!=2)

        printf("0\n");

    else

        printf("%lld\n",p*q);

    return 0;

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

#define ll long long

#define N 100005

using namespace std;

int main()

{

	ll n;

	ll a[N];

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

	cin>>n;

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

	{

		cin>>a[i];

	}

	sort(a,a+n);

	ll x,y;

	int flag = 0; 

	ll  i ,j;

	for(i = n-1;i>=0;i--)

	{

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

		{

			i--;

			x =a[i];

			for(j=i-1;j>=0;j--)

			{

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

				{

					y = a[j];

					flag = 1;

					break;

				}

			}

			break;

		 } 

	}

	if(flag==0) cout<<"0"<<endl;

	else

	cout<<x*y<<endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.7886546445177292x):
#include<bits/stdc++.h>

using namespace std;



int main()

{

	int n;

	cin>>n;

	map<int,int> hm;

	vector<int> ans;

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

	{

		int a;

		cin>>a;

		hm[a]++;

		if(hm[a]==2)

		{

			ans.push_back(a);

			hm[a] = 0;

		}

	}

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

	if(ans.size()<2) cout<<0;

	else

		cout<<1LL*ans[ans.size()-1]*ans[ans.size()-2];

	return 0;

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

#define ll long long

#define N 100005

using namespace std;

int main()

{

	ll n;

	ll a[N];

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

	cin>>n;

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

	{

		cin>>a[i];

	}

	sort(a,a+n);

	ll x,y;

	int flag = 0; 

	ll  i ,j;

	for(i = n-1;i>=0;i--)

	{

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

		{

			i--;

			x =a[i];

			for(j=i-1;j>=0;j--)

			{

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

				{

					y = a[j];

					flag = 1;

					break;

				}

			}

			break;

		 } 

	}

	if(flag==0) cout<<"0"<<endl;

	else

	cout<<x*y<<endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.7817413237564341x):
#include <iostream>

#include <cmath>

#include <stdio.h>

#include <algorithm>

#include <string>

#include <vector>

#include <queue>

#include <deque>

#include <stack>

#include <map>

#include <set>

#include <cstring>



using namespace std;



#define f first

#define s second

#define pb push_back

#define mp make_pair

#define ll long long

#define pii pair < int, int >

#define pll pair < long long, long long>

#define ull unsigned long long

#define vi vector < int >

#define vll vector < long long >

#define sz(a) (int)a.size()

#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)

#define all(a) a.begin(), a.end()

#define sqr(x) ((x) * (x))

#define fname "searching"



const int inf = (int)1e9;

const ll INF = (ll)1e18;

const double eps = 1e-9;

const double pi = acos(-1.0);

const int mod = (int)1e9 + 7;



int n;

ll a[100100];



ll solve(){

    cin >> n;

    for(int i = 0; i < n; ++i) cin >> a[i];

    sort(a, a + n);

    

    ll x = 0, cx = 0;

    ll y = 0, cy = 0;

    ll cnt = 2;

    for(int i = n - 1; i >= 0; --i){

        if(a[i] == x) cx++;

        else if(a[i] == y) cy++;



        if(cx >= 2 * cnt) return x * x;

        if(cx >= cnt && cy >= cnt){

            return x * y;

        }

        

        if(a[i] != x && cx < cnt){

            x = a[i];

            cx = 1;

        }else if(a[i] != y && cy < cnt){

            y = a[i];

            cy = 1;

        }

    }

    return 0;

}



int main(){

    ios_base::sync_with_stdio(0);

    cin.tie(0);



    cout << solve() << "\n";

    

    return 0;

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

#define ll long long

#define N 100005

using namespace std;

int main()

{

	ll n;

	ll a[N];

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

	cin>>n;

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

	{

		cin>>a[i];

	}

	sort(a,a+n);

	ll x,y;

	int flag = 0; 

	ll  i ,j;

	for(i = n-1;i>=0;i--)

	{

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

		{

			i--;

			x =a[i];

			for(j=i-1;j>=0;j--)

			{

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

				{

					y = a[j];

					flag = 1;

					break;

				}

			}

			break;

		 } 

	}

	if(flag==0) cout<<"0"<<endl;

	else

	cout<<x*y<<endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.8313356809463617x):
#include<bits/stdc++.h>

#define LLI long long int

#define ULTRA 2134567890

#define de(x) if(x!=0 && MODE==x)

#define MODE 1

using namespace std;



int A[100007];



int main()

{

    int i,j;

    int N;



    scanf("%d", &N);

    for( i=0; i<N; i++)

    {

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

    }

    sort( A, A+N, greater<int>());



    LLI h = 0;

    LLI w = 0;

    for( i=0; i<N-1; i++)

    {

        if( A[i]==A[i+1])

        {

            if( h==0)

            {

                h = A[i];

                i++;

            }

            else if( w==0)

            {

                w = A[i];

                break;

            }

        }

    }

    printf("%lld\n", h*w);



    return 0;

}
// 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.58917796150915x):
#include<bits/stdc++.h>

#define LLI long long int

#define ULTRA 2134567890

#define de(x) if(x!=0 && MODE==x)

#define MODE 1

using namespace std;



int A[100007];



int main()

{

    int i,j;

    int N;



    scanf("%d", &N);

    for( i=0; i<N; i++)

    {

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

    }

    sort( A, A+N, greater<int>());



    LLI h = 0;

    LLI w = 0;

    for( i=0; i<N-1; i++)

    {

        if( A[i]==A[i+1])

        {

            if( h==0)

            {

                h = A[i];

                i++;

            }

            else if( w==0)

            {

                w = A[i];

                break;

            }

        }

    }

    printf("%lld\n", h*w);



    return 0;

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

#define ll long long

#define N 100005

using namespace std;

int main()

{

	ll n;

	ll a[N];

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

	cin>>n;

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

	{

		cin>>a[i];

	}

	sort(a,a+n);

	ll x,y;

	int flag = 0; 

	ll  i ,j;

	for(i = n-1;i>=0;i--)

	{

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

		{

			i--;

			x =a[i];

			for(j=i-1;j>=0;j--)

			{

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

				{

					y = a[j];

					flag = 1;

					break;

				}

			}

			break;

		 } 

	}

	if(flag==0) cout<<"0"<<endl;

	else

	cout<<x*y<<endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.767842986880238x):
/*

--------------              |   /

      |                     |  /

      |                     | /

      |             *       |/          |    |         ------            *

      |                     |           |    |        /      \

      |             |       |\          |    |       |       |\          |

   \  |             |       | \         |    |       |       | \         |

    \ |             |       |  \        |    |        \     /   \        |

     V              |       |   \        \__/|         -----     \       |

*/

#include <bits/stdc++.h>

using namespace std;



#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);

#define endl '\n'

#define mem(i,j) memset(i,j,sizeof i);

#define F first

#define S second

#define pb push_back

#define mp make_pair

#define all(a) a.begin(), a.end()

#define bit(s,i) (((s)>>(i))&1LL)

#define lowbit(x) (x&-x)

#define siz(v) (long long)v.size()

typedef long long ll;

typedef unsigned long long ull;

typedef pair<int,int> pii;

typedef pair<ll, ll> pll;

const double EPS  = 1e-8;

const int INF     = 0x3F3F3F3F;

const ll LINF     = 4611686018427387903;

const int MOD     = 1e9+7;

const int MAXN    = 2e5+9;

/*-----------------------------------------------------------------------------------------------------*/



int main() {

    EmiliaMyWife



    int n, a;

    cin >> n;

    vector<int> can;

    map<int, int> now;

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

        cin >> a;

        now[a]++;

        if(now[a]>1) {

            can.pb(a);

            now[a]=0;

        }

    }

    if(can.size()>1) {

        sort(all(can), greater<int>());

        cout << 1LL*can[0]*can[1];

    }

    else cout << 0;



	return 0;

}