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



using namespace std;



typedef long long LL;



const int MAX_N = 1e5 + 10;



int main()

{

	ios::sync_with_stdio(false);

	cin.tie(nullptr);

	

	int N, cnt[MAX_N] = {};

	LL ans = 0, A[MAX_N];

	vector<LL> vec;

	

	cin >> N;

	for (int i = 0; i < N; i++) cin >> A[i];

	

	sort(A, A + N);

	cnt[0] = 1;

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

	{

		cnt[i] = A[i] == A[i - 1] ? cnt[i - 1] + 1 : 1;

		

		if (cnt[i] == 2) vec.emplace_back(A[i]);

		else if (cnt[i] == 4) ans = max(ans, A[i] * A[i]);

	}//for i

	

	for (int i = 0; i < (int)vec.size() - 1; i++)

		ans = max(ans, vec[i] * vec[i + 1]);

		

	cout << ans << '\n';

	

	return 0;

}//main

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

#include<algorithm>

using namespace std;

int main()

{

    int N;

    while(cin>>N)

    {

        long long a[N+10];

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

        sort(a,a+N);

        long long cnt=0,n,m;

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

        {

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

            {

                cnt++,i--;

                if(cnt==1) n=a[i];

                if(cnt==2){

                    m=a[i];

                    break;

                }

            }

        }

        if(cnt==2) cout<<n*m<<endl;

        else cout<<0<<endl;

    }

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

using namespace std;



#define LL long long

#define LD long double

#define Mod 1000000007

#define L_Mod 17100000013



const double eps = 1e-9;

const int INF = 0x3f3f3f3f;

const double PI = 3.1415926535;



#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);



#define ree(a,n) memset(a,n,si 2)



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

#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))

#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

int main()

{

    LL int i,j,n,m,a[100002]= {0};

    cin>>n;

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

        cin>>a[i];

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

    LL int ma=0,num=0;

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

    {

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

        {

            if(num==0)

                ma=a[i];

            else

                ma*=a[i];

            num++;

            i++;

        }

        if(num>=2)

            break;

    }

    if(num>=2)

        cout<<ma;

    else

        cout<<0;

}


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

#include <stdio.h>

#include <string.h>

#include <algorithm>

#include <math.h>

#define ll long long

using namespace std;

int main()

{

    ll a[100005];

    ll aa,bb,book[100005];

    int flag=0,n,flge=0;

    scanf("%d",&n);

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

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

    sort(a,a+n);

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

    {

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

        {

            aa=a[i];

            n=i-2;

            flag=1;

            break;

        }

    }

    for(int i=n; i>=0&&flag; i--)

    {

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

        {

            bb=a[i];

            flge=1;

            break;

        }

    }

    if(flge==1)

    {

        printf("%lld\n",aa*bb);

    }

    else

    {

        printf("0\n");

    }

    return 0;

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



using namespace std;



typedef long long LL;



const int MAX_N = 1e5 + 10;



int main()

{

	ios::sync_with_stdio(false);

	cin.tie(nullptr);

	

	int N, cnt[MAX_N] = {};

	LL ans = 0, A[MAX_N];

	vector<LL> vec;

	

	cin >> N;

	for (int i = 0; i < N; i++) cin >> A[i];

	

	sort(A, A + N);

	cnt[0] = 1;

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

	{

		cnt[i] = A[i] == A[i - 1] ? cnt[i - 1] + 1 : 1;

		

		if (cnt[i] == 2) vec.emplace_back(A[i]);

		else if (cnt[i] == 4) ans = max(ans, A[i] * A[i]);

	}//for i

	

	for (int i = 0; i < (int)vec.size() - 1; i++)

		ans = max(ans, vec[i] * vec[i + 1]);

		

	cout << ans << '\n';

	

	return 0;

}//main

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

#include <stdio.h>

#include <string.h>

#include <algorithm>

#include <math.h>

#define ll long long

using namespace std;

int main()

{

    ll a[100005];

    ll aa,bb,book[100005];

    int flag=0,n,flge=0;

    scanf("%d",&n);

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

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

    sort(a,a+n);

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

    {

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

        {

            aa=a[i];

            n=i-2;

            flag=1;

            break;

        }

    }

    for(int i=n; i>=0&&flag; i--)

    {

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

        {

            bb=a[i];

            flge=1;

            break;

        }

    }

    if(flge==1)

    {

        printf("%lld\n",aa*bb);

    }

    else

    {

        printf("0\n");

    }

    return 0;

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

using namespace std;



#define LL long long

#define LD long double

#define Mod 1000000007

#define L_Mod 17100000013



const double eps = 1e-9;

const int INF = 0x3f3f3f3f;

const double PI = 3.1415926535;



#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);



#define ree(a,n) memset(a,n,si 2)



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

#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))

#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

int main()

{

    LL int i,j,n,m,a[100002]= {0};

    cin>>n;

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

        cin>>a[i];

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

    LL int ma=0,num=0;

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

    {

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

        {

            if(num==0)

                ma=a[i];

            else

                ma*=a[i];

            num++;

            i++;

        }

        if(num>=2)

            break;

    }

    if(num>=2)

        cout<<ma;

    else

        cout<<0;

}


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

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

#define endl '\n'

#define MAXN maxn



using namespace std;



int N;

set<int> s;

long long mx, mx2;



signed main()

{

  IO;

  cin >> N;

  for (int i = 0, t; i < N; i++) {

    cin >> t;

    if (s.find(t) != s.end()) {

      if (t > mx)

        mx2 = mx, mx = t;

      else if (t > mx2) 

        mx2 = t;

      s.erase(t);

    }

    else 

      s.insert(t);

  }

  cout << mx * mx2 << endl;

  return 0;

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



using namespace std;



typedef long long LL;



const int MAX_N = 1e5 + 10;



int main()

{

	ios::sync_with_stdio(false);

	cin.tie(nullptr);

	

	int N, cnt[MAX_N] = {};

	LL ans = 0, A[MAX_N];

	vector<LL> vec;

	

	cin >> N;

	for (int i = 0; i < N; i++) cin >> A[i];

	

	sort(A, A + N);

	cnt[0] = 1;

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

	{

		cnt[i] = A[i] == A[i - 1] ? cnt[i - 1] + 1 : 1;

		

		if (cnt[i] == 2) vec.emplace_back(A[i]);

		else if (cnt[i] == 4) ans = max(ans, A[i] * A[i]);

	}//for i

	

	for (int i = 0; i < (int)vec.size() - 1; i++)

		ans = max(ans, vec[i] * vec[i + 1]);

		

	cout << ans << '\n';

	

	return 0;

}//main

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

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

#define endl '\n'

#define MAXN maxn



using namespace std;



int N;

set<int> s;

long long mx, mx2;



signed main()

{

  IO;

  cin >> N;

  for (int i = 0, t; i < N; i++) {

    cin >> t;

    if (s.find(t) != s.end()) {

      if (t > mx)

        mx2 = mx, mx = t;

      else if (t > mx2) 

        mx2 = t;

      s.erase(t);

    }

    else 

      s.insert(t);

  }

  cout << mx * mx2 << endl;

  return 0;

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

using namespace std;



#define LL long long

#define LD long double

#define Mod 1000000007

#define L_Mod 17100000013



const double eps = 1e-9;

const int INF = 0x3f3f3f3f;

const double PI = 3.1415926535;



#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);



#define ree(a,n) memset(a,n,si 2)



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

#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))

#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

int main()

{

    LL int i,j,n,m,a[100002]= {0};

    cin>>n;

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

        cin>>a[i];

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

    LL int ma=0,num=0;

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

    {

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

        {

            if(num==0)

                ma=a[i];

            else

                ma*=a[i];

            num++;

            i++;

        }

        if(num>=2)

            break;

    }

    if(num>=2)

        cout<<ma;

    else

        cout<<0;

}


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



#include <algorithm>



using namespace std;



int main(void)



{

	long long int n,i,k,a1,a2;

	

	cin >> n;

	

	long long int input[n],big=0,secbig=0;

	

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

	{

		cin >> input[i];

	}

	

	sort(input,input+n);

	

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

	{

		if(input[i]==input[i-1]&&input[i]>=big)

		{

			

			secbig = big;

			

			big = input[i];

			

			i--;

		}

		else if(input[i]==input[i-1]&&input[i]<=big&&secbig==0)

		{

			secbig = input[i];

			

			i--;

		}

	}

	

	if(secbig==0||big==0)

	{

		cout << "0\n";

	}

	else

	{

		cout << big * secbig;

	}

	

	return 0;

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



using namespace std;



typedef long long LL;



const int MAX_N = 1e5 + 10;



int main()

{

	ios::sync_with_stdio(false);

	cin.tie(nullptr);

	

	int N, cnt[MAX_N] = {};

	LL ans = 0, A[MAX_N];

	vector<LL> vec;

	

	cin >> N;

	for (int i = 0; i < N; i++) cin >> A[i];

	

	sort(A, A + N);

	cnt[0] = 1;

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

	{

		cnt[i] = A[i] == A[i - 1] ? cnt[i - 1] + 1 : 1;

		

		if (cnt[i] == 2) vec.emplace_back(A[i]);

		else if (cnt[i] == 4) ans = max(ans, A[i] * A[i]);

	}//for i

	

	for (int i = 0; i < (int)vec.size() - 1; i++)

		ans = max(ans, vec[i] * vec[i + 1]);

		

	cout << ans << '\n';

	

	return 0;

}//main

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



#include <algorithm>



using namespace std;



int main(void)



{

	long long int n,i,k,a1,a2;

	

	cin >> n;

	

	long long int input[n],big=0,secbig=0;

	

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

	{

		cin >> input[i];

	}

	

	sort(input,input+n);

	

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

	{

		if(input[i]==input[i-1]&&input[i]>=big)

		{

			

			secbig = big;

			

			big = input[i];

			

			i--;

		}

		else if(input[i]==input[i-1]&&input[i]<=big&&secbig==0)

		{

			secbig = input[i];

			

			i--;

		}

	}

	

	if(secbig==0||big==0)

	{

		cout << "0\n";

	}

	else

	{

		cout << big * secbig;

	}

	

	return 0;

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

using namespace std;



#define LL long long

#define LD long double

#define Mod 1000000007

#define L_Mod 17100000013



const double eps = 1e-9;

const int INF = 0x3f3f3f3f;

const double PI = 3.1415926535;



#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);



#define ree(a,n) memset(a,n,si 2)



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

#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))

#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

int main()

{

    LL int i,j,n,m,a[100002]= {0};

    cin>>n;

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

        cin>>a[i];

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

    LL int ma=0,num=0;

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

    {

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

        {

            if(num==0)

                ma=a[i];

            else

                ma*=a[i];

            num++;

            i++;

        }

        if(num>=2)

            break;

    }

    if(num>=2)

        cout<<ma;

    else

        cout<<0;

}


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

using namespace std;

long long n,a,mx1=0,mx2=0;

map<long long,long long> mp;

int main(){

	scanf("%lld",&n);

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

		scanf("%lld",&a);

		if(mp[a] == 0){

			mp[a] = 1;

		}

		else{

			mp[a] = 0;

			if(a > mx1){

				mx2 = mx1;

				mx1 = a;

			}

			else if(a > mx2){

				mx2 = a;

			}

		}

	}

	printf("%lld",mx1*mx2);

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



using namespace std;



typedef long long LL;



const int MAX_N = 1e5 + 10;



int main()

{

	ios::sync_with_stdio(false);

	cin.tie(nullptr);

	

	int N, cnt[MAX_N] = {};

	LL ans = 0, A[MAX_N];

	vector<LL> vec;

	

	cin >> N;

	for (int i = 0; i < N; i++) cin >> A[i];

	

	sort(A, A + N);

	cnt[0] = 1;

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

	{

		cnt[i] = A[i] == A[i - 1] ? cnt[i - 1] + 1 : 1;

		

		if (cnt[i] == 2) vec.emplace_back(A[i]);

		else if (cnt[i] == 4) ans = max(ans, A[i] * A[i]);

	}//for i

	

	for (int i = 0; i < (int)vec.size() - 1; i++)

		ans = max(ans, vec[i] * vec[i + 1]);

		

	cout << ans << '\n';

	

	return 0;

}//main

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

using namespace std;

long long n,a,mx1=0,mx2=0;

map<long long,long long> mp;

int main(){

	scanf("%lld",&n);

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

		scanf("%lld",&a);

		if(mp[a] == 0){

			mp[a] = 1;

		}

		else{

			mp[a] = 0;

			if(a > mx1){

				mx2 = mx1;

				mx1 = a;

			}

			else if(a > mx2){

				mx2 = a;

			}

		}

	}

	printf("%lld",mx1*mx2);

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

using namespace std;



#define LL long long

#define LD long double

#define Mod 1000000007

#define L_Mod 17100000013



const double eps = 1e-9;

const int INF = 0x3f3f3f3f;

const double PI = 3.1415926535;



#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);



#define ree(a,n) memset(a,n,si 2)



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

#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))

#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

int main()

{

    LL int i,j,n,m,a[100002]= {0};

    cin>>n;

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

        cin>>a[i];

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

    LL int ma=0,num=0;

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

    {

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

        {

            if(num==0)

                ma=a[i];

            else

                ma*=a[i];

            num++;

            i++;

        }

        if(num>=2)

            break;

    }

    if(num>=2)

        cout<<ma;

    else

        cout<<0;

}


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



using namespace std;



priority_queue<long long> pq;

long long ans[100005];



int main()

{

    int n;

    scanf("%d",&n);

    int i;

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

    {

        long long t1;

        scanf("%lld",&t1);

        pq.push(t1);

    }

    long long before;

    before = 0;

    int c = 0;

    while(!pq.empty())

    {

        long long now = pq.top(); pq.pop();

        if(now == before)

        {

            before = 0;

            ans[c++] = now;

        }

        else before = now;

    }

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

    printf("%lld",ans1);

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



using namespace std;



typedef long long LL;



const int MAX_N = 1e5 + 10;



int main()

{

	ios::sync_with_stdio(false);

	cin.tie(nullptr);

	

	int N, cnt[MAX_N] = {};

	LL ans = 0, A[MAX_N];

	vector<LL> vec;

	

	cin >> N;

	for (int i = 0; i < N; i++) cin >> A[i];

	

	sort(A, A + N);

	cnt[0] = 1;

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

	{

		cnt[i] = A[i] == A[i - 1] ? cnt[i - 1] + 1 : 1;

		

		if (cnt[i] == 2) vec.emplace_back(A[i]);

		else if (cnt[i] == 4) ans = max(ans, A[i] * A[i]);

	}//for i

	

	for (int i = 0; i < (int)vec.size() - 1; i++)

		ans = max(ans, vec[i] * vec[i + 1]);

		

	cout << ans << '\n';

	

	return 0;

}//main

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



using namespace std;



priority_queue<long long> pq;

long long ans[100005];



int main()

{

    int n;

    scanf("%d",&n);

    int i;

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

    {

        long long t1;

        scanf("%lld",&t1);

        pq.push(t1);

    }

    long long before;

    before = 0;

    int c = 0;

    while(!pq.empty())

    {

        long long now = pq.top(); pq.pop();

        if(now == before)

        {

            before = 0;

            ans[c++] = now;

        }

        else before = now;

    }

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

    printf("%lld",ans1);

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

using namespace std;



#define LL long long

#define LD long double

#define Mod 1000000007

#define L_Mod 17100000013



const double eps = 1e-9;

const int INF = 0x3f3f3f3f;

const double PI = 3.1415926535;



#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);



#define ree(a,n) memset(a,n,si 2)



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

#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))

#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

int main()

{

    LL int i,j,n,m,a[100002]= {0};

    cin>>n;

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

        cin>>a[i];

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

    LL int ma=0,num=0;

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

    {

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

        {

            if(num==0)

                ma=a[i];

            else

                ma*=a[i];

            num++;

            i++;

        }

        if(num>=2)

            break;

    }

    if(num>=2)

        cout<<ma;

    else

        cout<<0;

}


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

using namespace std;

vector <long long> v;

long long a=1,b; 

int main()

{

	int n,i,j=0;

	scanf("%d",&n);

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

	{

		cin >> b;

		v.push_back(b);

	}

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

	

	for(i=0;i<v.size();i++)

	{

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

		{

			++j;

		a*=v[i];

		if(j==2) break;

		++i;

}

	}

	if(j==2) 

	cout << a;

	else

	cout << 0;

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



using namespace std;



typedef long long LL;



const int MAX_N = 1e5 + 10;



int main()

{

	ios::sync_with_stdio(false);

	cin.tie(nullptr);

	

	int N, cnt[MAX_N] = {};

	LL ans = 0, A[MAX_N];

	vector<LL> vec;

	

	cin >> N;

	for (int i = 0; i < N; i++) cin >> A[i];

	

	sort(A, A + N);

	cnt[0] = 1;

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

	{

		cnt[i] = A[i] == A[i - 1] ? cnt[i - 1] + 1 : 1;

		

		if (cnt[i] == 2) vec.emplace_back(A[i]);

		else if (cnt[i] == 4) ans = max(ans, A[i] * A[i]);

	}//for i

	

	for (int i = 0; i < (int)vec.size() - 1; i++)

		ans = max(ans, vec[i] * vec[i + 1]);

		

	cout << ans << '\n';

	

	return 0;

}//main

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

using namespace std;

vector <long long> v;

long long a=1,b; 

int main()

{

	int n,i,j=0;

	scanf("%d",&n);

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

	{

		cin >> b;

		v.push_back(b);

	}

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

	

	for(i=0;i<v.size();i++)

	{

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

		{

			++j;

		a*=v[i];

		if(j==2) break;

		++i;

}

	}

	if(j==2) 

	cout << a;

	else

	cout << 0;

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

using namespace std;



#define LL long long

#define LD long double

#define Mod 1000000007

#define L_Mod 17100000013



const double eps = 1e-9;

const int INF = 0x3f3f3f3f;

const double PI = 3.1415926535;



#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);



#define ree(a,n) memset(a,n,si 2)



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

#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))

#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

int main()

{

    LL int i,j,n,m,a[100002]= {0};

    cin>>n;

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

        cin>>a[i];

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

    LL int ma=0,num=0;

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

    {

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

        {

            if(num==0)

                ma=a[i];

            else

                ma*=a[i];

            num++;

            i++;

        }

        if(num>=2)

            break;

    }

    if(num>=2)

        cout<<ma;

    else

        cout<<0;

}


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

using namespace std;

long area=1;

vector<int> v;

bool find_a_pair(){

    int s=v.size()-1;

    while(s+1){

        if(s<=0){

            area=0;

            return 0;

        }

        if(v[s]==v[s-1]){

            area*=v[s];

            //printf("area%d---v[s]%d\n",area,v[s]);

            v.erase(v.begin()+s);

            v.erase(v.begin()+s-1);

            return 1;

        }

        s--;

    }

}

int main(){



    int n;

    scanf("%d",&n);

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

        int x;

        scanf("%d",&x);

        v.push_back(x);

    }

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

    if(find_a_pair()) find_a_pair();

    printf("%ld",area);

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



using namespace std;



typedef long long LL;



const int MAX_N = 1e5 + 10;



int main()

{

	ios::sync_with_stdio(false);

	cin.tie(nullptr);

	

	int N, cnt[MAX_N] = {};

	LL ans = 0, A[MAX_N];

	vector<LL> vec;

	

	cin >> N;

	for (int i = 0; i < N; i++) cin >> A[i];

	

	sort(A, A + N);

	cnt[0] = 1;

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

	{

		cnt[i] = A[i] == A[i - 1] ? cnt[i - 1] + 1 : 1;

		

		if (cnt[i] == 2) vec.emplace_back(A[i]);

		else if (cnt[i] == 4) ans = max(ans, A[i] * A[i]);

	}//for i

	

	for (int i = 0; i < (int)vec.size() - 1; i++)

		ans = max(ans, vec[i] * vec[i + 1]);

		

	cout << ans << '\n';

	

	return 0;

}//main

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

using namespace std;

long area=1;

vector<int> v;

bool find_a_pair(){

    int s=v.size()-1;

    while(s+1){

        if(s<=0){

            area=0;

            return 0;

        }

        if(v[s]==v[s-1]){

            area*=v[s];

            //printf("area%d---v[s]%d\n",area,v[s]);

            v.erase(v.begin()+s);

            v.erase(v.begin()+s-1);

            return 1;

        }

        s--;

    }

}

int main(){



    int n;

    scanf("%d",&n);

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

        int x;

        scanf("%d",&x);

        v.push_back(x);

    }

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

    if(find_a_pair()) find_a_pair();

    printf("%ld",area);

}