stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 5.131156276876931x):
//h

#include<stdio.h>

#include<algorithm>

typedef long long ll;



int n;

ll a[100005];



bool cmp(const ll &a, const ll &b)

{

	return a>b;

}



int main()

{

	//freopen("in.txt", "r", stdin);

	int i;

	ll l=0ll, w=0ll;

	scanf("%d", &n);

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

	{

		scanf("%lld", a+i);

	}

	std::sort(a, a+n, cmp);

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

	{

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

		{

			l=a[i];

			break;

		}

	}

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

	{

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

		{

			w=a[i];

			break;

		}

	}

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

	return 0;

}
// Slower C++ solution:
/*

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

      |                     |  /

      |                     | /

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

      |                     |           |    |        /      \

      |             |       |\          |    |       |       |\          |

   \  |             |       | \         |    |       |       | \         |

    \ |             |       |  \        |    |        \     /   \        |

     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;

}


// Faster C++ solution for the same problem (measured speedup: 5.315443534348902x):
//h

#include<stdio.h>

#include<algorithm>

typedef long long ll;



int n;

ll a[100005];



bool cmp(const ll &a, const ll &b)

{

	return a>b;

}



int main()

{

	//freopen("in.txt", "r", stdin);

	int i;

	ll l=0ll, w=0ll;

	scanf("%d", &n);

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

	{

		scanf("%lld", a+i);

	}

	std::sort(a, a+n, cmp);

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

	{

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

		{

			l=a[i];

			break;

		}

	}

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

	{

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

		{

			w=a[i];

			break;

		}

	}

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

	return 0;

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

#define int long long



using namespace std;



signed main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(0);



    int n, arr[100000];

    cin >> n;

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

        cin >> arr[i];

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



    int s = -1;

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

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

            if (s == -1)

                s = arr[i], i++;

            else

                return cout << s * arr[i] << '\n', 0;

    cout << "0\n";



    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.33357473352694x):
//h

#include<stdio.h>

#include<algorithm>

typedef long long ll;



int n;

ll a[100005];



bool cmp(const ll &a, const ll &b)

{

	return a>b;

}



int main()

{

	//freopen("in.txt", "r", stdin);

	int i;

	ll l=0ll, w=0ll;

	scanf("%d", &n);

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

	{

		scanf("%lld", a+i);

	}

	std::sort(a, a+n, cmp);

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

	{

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

		{

			l=a[i];

			break;

		}

	}

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

	{

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

		{

			w=a[i];

			break;

		}

	}

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

	return 0;

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

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

using namespace std;



int main(){

//	IOS;

	int n,inp;

	cin >> n;

	map<int,int> num;

	vector<int> can;

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

		cin >> inp;

		num[inp]++;

		if(num[inp]%2==0) can.push_back(inp);

	}

	sort(can.begin(),can.end(),greater<int>());

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

	else cout << (long long int)can[0]*can[1] << '\n';

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.252849956098417x):
//h

#include<stdio.h>

#include<algorithm>

typedef long long ll;



int n;

ll a[100005];



bool cmp(const ll &a, const ll &b)

{

	return a>b;

}



int main()

{

	//freopen("in.txt", "r", stdin);

	int i;

	ll l=0ll, w=0ll;

	scanf("%d", &n);

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

	{

		scanf("%lld", a+i);

	}

	std::sort(a, a+n, cmp);

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

	{

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

		{

			l=a[i];

			break;

		}

	}

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

	{

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

		{

			w=a[i];

			break;

		}

	}

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

	return 0;

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

#include<vector>

#include<map>

#include<algorithm>

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

#define allr(x) x.rbegin(),x.rend()

#define pb push_back

#define mp make_pair

#define F first

#define S second

#define eb emplace_back

#define int long long

#define MOD 1000000007

#define PI 2*acos(0)

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

using namespace std;

int32_t main() {

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

	int n, a; cin >> n;

	map<int, int> c;

	vector<int> v;

	forn(i, n) {

		cin >> a;

		c[a]++;

		if (c[a] == 2)v.pb(a);

	}

	sort(allr(v));

	if (v.size() && c[v[0]] >= 4)

		cout << v[0] * v[0] << '\n';

	else if (v.size() > 1)

		cout << v[0] * v[1] << '\n';

	else

		cout << "0\n";	

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.320307930968847x):
//h

#include<stdio.h>

#include<algorithm>

typedef long long ll;



int n;

ll a[100005];



bool cmp(const ll &a, const ll &b)

{

	return a>b;

}



int main()

{

	//freopen("in.txt", "r", stdin);

	int i;

	ll l=0ll, w=0ll;

	scanf("%d", &n);

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

	{

		scanf("%lld", a+i);

	}

	std::sort(a, a+n, cmp);

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

	{

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

		{

			l=a[i];

			break;

		}

	}

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

	{

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

		{

			w=a[i];

			break;

		}

	}

	printf("%lld\n", l*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.7859110483015395x):
#include<iostream>

#include<map>

#include<algorithm>

using namespace std;

int main(){

    long long a,s,t,z=0;

    cin>>a;

    long long k[a]={0};

    map<long long,long long>g;

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

        cin>>s;

        if(g.find(s)==g.end()){

            k[z]=s;

            z+=1;

            g[s]=1;

        }

        else g[s]+=1;

    }

    sort(k,k+z);

    t=0;

    s=0;

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

        if(g[k[i]]/4>=1){

            t=k[i];

            s=k[i];

        }

        else if(g[k[i]]/2>=1){

            s=t;

            t=k[i];

        }

    }

    if(s==0){

        cout<<"0"<<endl;

    }

    else cout<<t*s<<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.500151633843108x):
#include<iostream>

#include<map>

#include<algorithm>

using namespace std;

int main(){

    long long a,s,t,z=0;

    cin>>a;

    long long k[a]={0};

    map<long long,long long>g;

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

        cin>>s;

        if(g.find(s)==g.end()){

            k[z]=s;

            z+=1;

            g[s]=1;

        }

        else g[s]+=1;

    }

    sort(k,k+z);

    t=0;

    s=0;

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

        if(g[k[i]]/4>=1){

            t=k[i];

            s=k[i];

        }

        else if(g[k[i]]/2>=1){

            s=t;

            t=k[i];

        }

    }

    if(s==0){

        cout<<"0"<<endl;

    }

    else cout<<t*s<<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.7928564094289696x):
#include <bits/stdc++.h>

using namespace std;

int main()

{

    int n;

    cin>>n;

    set<int>S;

    vector<int>B;

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

    {

        int x;

        cin>>x;

        if(S.count(x)){

        S.erase(x);

        B.push_back(x);}

        else

        S.insert(x);

    }

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

    if((int)B.size()<2){

        printf("0\n");

    }

    else

    {

        int x=(int)B.size();

        printf("%lld",1LL*B[x-1]*B[x-2]);

    }

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

using namespace std;

int main()

{

    int n;

    cin>>n;

    set<int>S;

    vector<int>B;

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

    {

        int x;

        cin>>x;

        if(S.count(x)){

        S.erase(x);

        B.push_back(x);}

        else

        S.insert(x);

    }

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

    if((int)B.size()<2){

        printf("0\n");

    }

    else

    {

        int x=(int)B.size();

        printf("%lld",1LL*B[x-1]*B[x-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.7625639160215882x):
#include <iostream>

#include <set>

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

using namespace std;



int main()

{

    BurstStream

    int n;

    while (cin >> n)

    {

        long long mxside[] = {0, 0};

        set<long long> s;



        while (n--)

        {

            long long temp;

            cin >> temp;



            if (s.find(temp) == s.end()) s.insert(temp);

            else

            {

                s.erase(temp);

                if (temp > mxside[0])

                {

                    mxside[1] = mxside[0];

                    mxside[0] = temp;

                }

                else if (temp > mxside[1]) mxside[1] = temp;

            }

        }

        cout << mxside[0] * mxside[1] << '\n';

    }

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

#include <set>

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

using namespace std;



int main()

{

    BurstStream

    int n;

    while (cin >> n)

    {

        long long mxside[] = {0, 0};

        set<long long> s;



        while (n--)

        {

            long long temp;

            cin >> temp;



            if (s.find(temp) == s.end()) s.insert(temp);

            else

            {

                s.erase(temp);

                if (temp > mxside[0])

                {

                    mxside[1] = mxside[0];

                    mxside[0] = temp;

                }

                else if (temp > mxside[1]) mxside[1] = temp;

            }

        }

        cout << mxside[0] * mxside[1] << '\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.8024169692757133x):
#include<iostream>

#include<queue>

using namespace std;

int n,c=0;

long long a,b,ans[2];

priority_queue<long long> pq;

int main()

{

	cin>>n;

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

	{

		cin>>a;

		pq.push(a);

	}

	

	while(!pq.empty())

	{

		a=pq.top(); 

		  pq.pop();

		b=pq.top();

		

		if(a==b)

		{

			ans[c]=a;

			c++;

			pq.pop();

		}

		

		if(pq.size()==1||c==2)

		break;

	}

	

	if(c==2)

	{

		long long area=ans[0]*ans[1];

	

		cout<<area;

	}

	else

	{

		cout<<"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.532501076062408x):
#include<iostream>

#include<queue>

using namespace std;

int n,c=0;

long long a,b,ans[2];

priority_queue<long long> pq;

int main()

{

	cin>>n;

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

	{

		cin>>a;

		pq.push(a);

	}

	

	while(!pq.empty())

	{

		a=pq.top(); 

		  pq.pop();

		b=pq.top();

		

		if(a==b)

		{

			ans[c]=a;

			c++;

			pq.pop();

		}

		

		if(pq.size()==1||c==2)

		break;

	}

	

	if(c==2)

	{

		long long area=ans[0]*ans[1];

	

		cout<<area;

	}

	else

	{

		cout<<"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.948136390601187x):
#include<stdio.h>

#include<vector>

#include<set>

#include<algorithm>

using namespace std;

set<long long>k;

vector<long long>t;

int main()

{

    long long a,h,siz,p,q;

    scanf("%lld",&a);

    for(long long i=0;i<a;i++)

    {

        siz=k.size();

        scanf("%lld",&h);

        k.insert(h);

        if(k.size()==siz)

        {

            t.push_back(h);

        }

    }

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

    p=count(t.begin(),t.end(),t[t.size()-1]);

    if(p>=3)

    {

    printf("%lld",t[t.size()-1]*t[t.size()-1]);

    }

    else if(t.size()>=2)

    {

    printf("%lld",t[t.size()-1]*(t[t.size()-p-1]));

    }

    else printf("0");

    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.8180920471917337x):
#include<stdio.h>

#include<vector>

#include<set>

#include<algorithm>

using namespace std;

set<long long>k;

vector<long long>t;

int main()

{

    long long a,h,siz,p,q;

    scanf("%lld",&a);

    for(long long i=0;i<a;i++)

    {

        siz=k.size();

        scanf("%lld",&h);

        k.insert(h);

        if(k.size()==siz)

        {

            t.push_back(h);

        }

    }

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

    p=count(t.begin(),t.end(),t[t.size()-1]);

    if(p>=3)

    {

    printf("%lld",t[t.size()-1]*t[t.size()-1]);

    }

    else if(t.size()>=2)

    {

    printf("%lld",t[t.size()-1]*(t[t.size()-p-1]));

    }

    else printf("0");

    return 0;

}
// Slower C++ solution:
/*

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

      |                     |  /

      |                     | /

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

      |                     |           |    |        /      \

      |             |       |\          |    |       |       |\          |

   \  |             |       | \         |    |       |       | \         |

    \ |             |       |  \        |    |        \     /   \        |

     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;

}


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

#include<vector>

#include<set>

#include<algorithm>

using namespace std;

set<long long>k;

vector<long long>t;

int main()

{

    long long a,h,siz,p,q;

    scanf("%lld",&a);

    for(long long i=0;i<a;i++)

    {

        siz=k.size();

        scanf("%lld",&h);

        k.insert(h);

        if(k.size()==siz)

        {

            t.push_back(h);

        }

    }

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

    p=count(t.begin(),t.end(),t[t.size()-1]);

    if(p>=3)

    {

    printf("%lld",t[t.size()-1]*t[t.size()-1]);

    }

    else if(t.size()>=2)

    {

    printf("%lld",t[t.size()-1]*(t[t.size()-p-1]));

    }

    else printf("0");

    return 0;

}