stablegradients/pie-gem5-pairs huggingface dataset:
// 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.4897439379853594x):
#include<bits/stdc++.h>

#define ll long long

#define inf 999999999999

#define F first

#define S second

#define read(x)  freopen("input.txt","r",stdin);

#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

#define pi 2*acos(0.0)

#define ee exp(1)

#define mx 200009

using namespace std;

priority_queue<ll>p,q;

map<ll,ll>m;

int main(){//read(x);

fast;

ll a,b,c,d,e,f,g,h,i,j,k,l=0,n,t;

cin>>n;

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

    cin>>a;

    m[a]++;

}

for(auto i:m){

    a=i.F;b=i.S;

    if(b>=4)p.push(a);

    if(b>=2)q.push(a);

}

if(p.size()>=1){

    a=p.top();

    l=max(l,a*a);

}

if(q.size()>=2){

    a=q.top();q.pop();

    b=q.top();q.pop();

    l=max(l,a*b);

}



 cout<<l<<endl;



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

#define ll long long

#define ull unsigned long long

#define pii pair<int,int>

#define piii pair<int,pii>

#define pll pair<ll,ll>

#define plii pair<ll,pii>

#define vi vector<int>

#define ff first

#define ss second

#define mp make_pair

#define pb push_back

#define SORT(x) sort(x.begin(), x.end())

#define GSORT(x) sort(x.begin(), x.end(), greater<int>())

#define mx 100001

#define eps 0.00000000001

#define mod 1000000007

#define pi acos(-1)

#define inf 100000000

#define loop(i,b,n) for(int i=b;i<n;++i)

#define rev_loop(i,b,n) for(int i=b;i>=n;--i)

#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;

int main()

{

    fio;

    ll N;

    cin >> N;



    vector<ll> A(N);



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

        cin >> A.at(i);



    ll k1=0,k2=0;



    SORT(A);



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

        if(A.at(i) == A.at(i+1)){

            if(k1 <= k2)

                k1 = A.at(i);

            else

            {

                k2 = A.at(i);

            }

            i++;

        }

    }





    cout << k1 * k2 << endl;

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

#define ll long long

#define ull unsigned long long

#define pii pair<int,int>

#define piii pair<int,pii>

#define pll pair<ll,ll>

#define plii pair<ll,pii>

#define vi vector<int>

#define ff first

#define ss second

#define mp make_pair

#define pb push_back

#define SORT(x) sort(x.begin(), x.end())

#define GSORT(x) sort(x.begin(), x.end(), greater<int>())

#define mx 100001

#define eps 0.00000000001

#define mod 1000000007

#define pi acos(-1)

#define inf 100000000

#define loop(i,b,n) for(int i=b;i<n;++i)

#define rev_loop(i,b,n) for(int i=b;i>=n;--i)

#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;

int main()

{

    fio;

    ll N;

    cin >> N;



    vector<ll> A(N);



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

        cin >> A.at(i);



    ll k1=0,k2=0;



    SORT(A);



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

        if(A.at(i) == A.at(i+1)){

            if(k1 <= k2)

                k1 = A.at(i);

            else

            {

                k2 = A.at(i);

            }

            i++;

        }

    }





    cout << k1 * k2 << endl;

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

using namespace std;

#define ll long long

int main()

{

    int t=1;

    while(t--)

    {

        ll n;

        cin>>n;

        ll a[n+5];

        map<ll,ll>cnt;

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

        {

            cin>>a[i];

            cnt[a[i]]++;

        }



        ll ans=0;

        vector<ll>v;

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



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

        {





            if(cnt[a[i]]>=4)

            {

                ans=max(ans,(a[i]*a[i]));



            }

            if(v.size()>=2) {

                ans=max(ans,v[0]*v[1]);

            }

            if(cnt[a[i]]>=2&&v.size()<2) v.push_back(a[i]);

            cnt[a[i]]=0;

        }

        cout<<ans<<endl;

        v.clear();

        cnt.clear();

    }

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

using namespace std;

#define ll long long

int main()

{

    int t=1;

    while(t--)

    {

        ll n;

        cin>>n;

        ll a[n+5];

        map<ll,ll>cnt;

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

        {

            cin>>a[i];

            cnt[a[i]]++;

        }



        ll ans=0;

        vector<ll>v;

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



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

        {





            if(cnt[a[i]]>=4)

            {

                ans=max(ans,(a[i]*a[i]));



            }

            if(v.size()>=2) {

                ans=max(ans,v[0]*v[1]);

            }

            if(cnt[a[i]]>=2&&v.size()<2) v.push_back(a[i]);

            cnt[a[i]]=0;

        }

        cout<<ans<<endl;

        v.clear();

        cnt.clear();

    }

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

using namespace std;

int main()

{

    int t,k;

    cin >> t;

    k=t;

    vector <long long> side;

    long long n;

    while(k--)

    {

        cin >> n;

        side.push_back(n);

    }

    sort(side.begin(),side.end(),greater<long long >());

    long long a=0,b=0,i,f=0;

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

    {

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

        {

            if(f==0){

                a=side[i];

                f++;

            }

            else if(f==1){

                b=side[i];

                f++;

            }

            i++;

        }

       // if(a>0 && b>0) break;

    }

    cout << a*b*1LL << endl;

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

using namespace std;

int main()

{

    int t,k;

    cin >> t;

    k=t;

    vector <long long> side;

    long long n;

    while(k--)

    {

        cin >> n;

        side.push_back(n);

    }

    sort(side.begin(),side.end(),greater<long long >());

    long long a=0,b=0,i,f=0;

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

    {

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

        {

            if(f==0){

                a=side[i];

                f++;

            }

            else if(f==1){

                b=side[i];

                f++;

            }

            i++;

        }

       // if(a>0 && b>0) break;

    }

    cout << a*b*1LL << endl;

}
// 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.765462045397876x):
/***



    Muhammad Imdad-Ul-Haque Rakib(Attari)

    CSE'19

    Chittagong,Bangladesh



***/





#include<bits/stdc++.h>





/**Definitions**/





#define   ld             long double

#define   ll             long long

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

#define   pb             push_back

#define   ppb            pop_back

#define   ull            unsigned long long

#define   over           return 0

#define   scan(i,n,a)    for(i=0;i<n;i++) cin>>a[i]

#define   MP             make_pair

#define   spc            " "



using namespace std;





/** Predefined Functions **/





int gcd(int x,int y){

    if(x==0) return y;

    else return gcd(y%x,x);

}

bool sortbysec(const pair<int,int>&a, const pair<int,int>&b){ return (a.second<b.second); }

bool sortbysecinrev(const pair<int,int>&a, const pair<int,int>&b){ return (a.second>b.second); }

bool sortbysize(string &s1,string &s2){ return s1.size() < s2.size(); }

bool sortinrev(const pair<int,int> &a, const pair<int,int> &b){ return (a.first > b.first); }





/** Main Function **/





int main(){



    boost_;

    ll n;

    cin>>n;

    ll a[n],i,a1=0,a2=0,a3=0;

    vector<ll>v,q;

    map<ll,ll>mp;

    scan(i,n,a);



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



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

        mp[a[i]]++;

        if(mp[a[i]]==1) q.pb(a[i]);

    }



    for(i=0;i<q.size();++i){

        if(mp[q[i]]>=2) v.pb(q[i]);

        if(v.size()==2) break;

    }

    if(v.size()==0) cout<<0<<endl;

    else{



       if(v.size()==1){if(mp[v[0]]>=4) cout<<v[0]*v[0]<<endl; else cout<<0<<endl;}

       else{

           if(mp[v[0]]>=4) cout<<v[0]*v[0]<<endl;

           else cout<<v[0]*v[1]<<endl;

       }

    }





    over;

}
// 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.4600742677325225x):
/***



    Muhammad Imdad-Ul-Haque Rakib(Attari)

    CSE'19

    Chittagong,Bangladesh



***/





#include<bits/stdc++.h>





/**Definitions**/





#define   ld             long double

#define   ll             long long

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

#define   pb             push_back

#define   ppb            pop_back

#define   ull            unsigned long long

#define   over           return 0

#define   scan(i,n,a)    for(i=0;i<n;i++) cin>>a[i]

#define   MP             make_pair

#define   spc            " "



using namespace std;





/** Predefined Functions **/





int gcd(int x,int y){

    if(x==0) return y;

    else return gcd(y%x,x);

}

bool sortbysec(const pair<int,int>&a, const pair<int,int>&b){ return (a.second<b.second); }

bool sortbysecinrev(const pair<int,int>&a, const pair<int,int>&b){ return (a.second>b.second); }

bool sortbysize(string &s1,string &s2){ return s1.size() < s2.size(); }

bool sortinrev(const pair<int,int> &a, const pair<int,int> &b){ return (a.first > b.first); }





/** Main Function **/





int main(){



    boost_;

    ll n;

    cin>>n;

    ll a[n],i,a1=0,a2=0,a3=0;

    vector<ll>v,q;

    map<ll,ll>mp;

    scan(i,n,a);



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



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

        mp[a[i]]++;

        if(mp[a[i]]==1) q.pb(a[i]);

    }



    for(i=0;i<q.size();++i){

        if(mp[q[i]]>=2) v.pb(q[i]);

        if(v.size()==2) break;

    }

    if(v.size()==0) cout<<0<<endl;

    else{



       if(v.size()==1){if(mp[v[0]]>=4) cout<<v[0]*v[0]<<endl; else cout<<0<<endl;}

       else{

           if(mp[v[0]]>=4) cout<<v[0]*v[0]<<endl;

           else cout<<v[0]*v[1]<<endl;

       }

    }





    over;

}
// 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.743320026268051x):
#include<iostream>

#include<bits/stdc++.h>

using namespace std;

int main()

{

    long long n,a[200000],i,j,b[3]={0},k=0;

    cin>>n;

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

    {

        cin>>a[i];

    }

    sort(a,a+n);

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

    {       

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

        {

            b[k]=a[j--];

            k++;

            if(k==2)

            {

                break;

            }

        }         

    }

    cout<<(b[0]*b[1])<<endl;

    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.416678811666809x):
#include<iostream>

#include<bits/stdc++.h>

using namespace std;

int main()

{

    long long n,a[200000],i,j,b[3]={0},k=0;

    cin>>n;

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

    {

        cin>>a[i];

    }

    sort(a,a+n);

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

    {       

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

        {

            b[k]=a[j--];

            k++;

            if(k==2)

            {

                break;

            }

        }         

    }

    cout<<(b[0]*b[1])<<endl;

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

using namespace std;

typedef long long ll;

int main()

{

    ll n;

    cin>>n;

    ll arr[n];

    map<ll,ll, greater<ll>>mp;

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

    {

        cin>>arr[i];

        mp[arr[i]]++;

    }

    ll c=0;

    ll ar=1;

    ll f=0;

    for(auto it=mp.begin(); it!=mp.end(); ++it)

    {

        ll s=it->second;

        if(c==0)

        {

            if(s>=4)

            {

                cout<<it->first*it->first<<endl;

                f=1;

                break;

            }

        }

        if(s>=2)

        {

            ar=ar*it->first;

            c++;

            if(c==2)

            {

                break;

            }

        }

    }

    if(c!=2&&f==0)

    {

        cout<<0<<endl;

    }

    else if(c==2&&f==0)

    {

        cout<<ar<<endl;

    }



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

using namespace std;

typedef long long ll;

int main()

{

    ll n;

    cin>>n;

    ll arr[n];

    map<ll,ll, greater<ll>>mp;

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

    {

        cin>>arr[i];

        mp[arr[i]]++;

    }

    ll c=0;

    ll ar=1;

    ll f=0;

    for(auto it=mp.begin(); it!=mp.end(); ++it)

    {

        ll s=it->second;

        if(c==0)

        {

            if(s>=4)

            {

                cout<<it->first*it->first<<endl;

                f=1;

                break;

            }

        }

        if(s>=2)

        {

            ar=ar*it->first;

            c++;

            if(c==2)

            {

                break;

            }

        }

    }

    if(c!=2&&f==0)

    {

        cout<<0<<endl;

    }

    else if(c==2&&f==0)

    {

        cout<<ar<<endl;

    }



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

using namespace std;

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

#define ll long long

#define vi vector<int>

#define pii pair<int,int>

#define F first

#define S second

#define pb push_back

#define forn(b) for(int i = 0; i < b; i++)

#define rforn(b) for(int i = b - 1 ;i >= 0; i--)

#define It(m) for(auto it = m.begin(); it != m.end(); it++)

#define N 500500

#define PI 3.14159265358979323846264338327950L

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

	

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

	

int main(){

	speed;

	int n; cin >> n;

	vector<ll> v(n);

	forn(n) {

		cin >> v[i];

	}

	sort(all(v));

	vector<ll> w {0, 0};

	int k = 0;

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

		if(v[i] == v[i + 1]) {

			w[k] = v[i];

			i--;

			k++;

			if(k == 2) break;

		}

	}

	ll res = w[0] * w[1];

	cout << res;

	return 0;

}