stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#include <algorithm>

#include <stdio.h>

#include <vector>

using namespace std;

#define PB push_back



constexpr int kN = int(1E5 + 10);



long long int a[kN];



int main() {

	int n;

	vector<long long int> v;

	long long int ans = 0;

	scanf("%d", &n);

	for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);

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

	for (int i = 2; i <= n; i++) if (a[i] == a[i - 1]) {

		v.PB(a[i]);

		i++;

	}

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

	if (v.size() >= 2) printf("%lld\n", v[0] * v[1]);

	else printf("0\n");

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

const int INF = 1e9;

const ll LINF = 1e18;



/*

<url:https://arc081.contest.atcoder.jp/tasks/arc081_a>

問題文============================================================

 太さが無視できる棒が N 本あります． i 番目の棒の長さは Ai です．

 

 すぬけ君は，これらの棒から 4 本の異なる棒を選び，それらの棒を辺として長方形（正方形を含む）を作りたいです．

 作ることができる最大の長方形の面積を求めてください．

 

=================================================================



解説=============================================================



================================================================

*/

int main(void) {

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

    ll N; cin >> N;

    map<ll,ll> mp;

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

        ll A; cin >> A; mp[A]++;

    }

    vector<pll> ps(mp.begin(),mp.end());

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

    reverse(ps.begin(),ps.end());

    

    ll h = 0,w = 0;

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

        if(ps[i].second >= 4){

            if(h == 0) h = w = ps[i].first;

            else w = ps[i].first;

            break;

        }else if(ps[i].second >= 2){

            if(h == 0){

                h = ps[i].first;

                continue;

            }

            if(w == 0){

                w = ps[i].first;

                break;

            }

        }

    }

    cout << h * w << endl;

	return 0;

}


// Optimized solution to the same problem (faster):
#include <algorithm>

#include <stdio.h>

#include <vector>

using namespace std;

#define PB push_back



constexpr int kN = int(1E5 + 10);



long long int a[kN];



int main() {

	int n;

	vector<long long int> v;

	long long int ans = 0;

	scanf("%d", &n);

	for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);

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

	for (int i = 2; i <= n; i++) if (a[i] == a[i - 1]) {

		v.PB(a[i]);

		i++;

	}

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

	if (v.size() >= 2) printf("%lld\n", v[0] * v[1]);

	else printf("0\n");

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;



#define ll long long

#define ull long long unsigned

#define vii vector<int>

#define pii pair<int,int>

#define pll pair<long long,long long>

#define pdd pair<double,double>

#define pldld pair<long long double, long long double>

#define ff first

#define ss second

#define pb push_back

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

#define write freopen("vorta.txt","w",stdout);

#define fastio ios::sync_with_stdio(false); cin.tie(NULL);

#define PI 2*acos(0.0)



const int MAX=100005, MOD=1000000007;

const ll inf=1e9;



int arr[MAX];

vector<ll>v;

map<ll,int>cnt;

int main(){



    fastio;

    int n;

    cin>>n;

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

        ll val;

        cin>>val;

        if(!cnt[val]){

            v.pb(val);

        }

        cnt[val]++;

    }

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

    ll a=0,b=0;

    ll ans=0;

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

        if(cnt[v[i]]>=4) ans=max(ans,(v[i]*v[i]));

    }

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

        if(!a && cnt[v[i]]>=2) a=v[i];

        else if(!b && cnt[v[i]]>=2) b=v[i];

    }

    ans=max(ans,(a*b));

    cout<<ans<<"\n";





}




















// Optimized solution to the same problem (faster):
#include <algorithm>

#include <stdio.h>

#include <vector>

using namespace std;

#define PB push_back



constexpr int kN = int(1E5 + 10);



long long int a[kN];



int main() {

	int n;

	vector<long long int> v;

	long long int ans = 0;

	scanf("%d", &n);

	for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);

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

	for (int i = 2; i <= n; i++) if (a[i] == a[i - 1]) {

		v.PB(a[i]);

		i++;

	}

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

	if (v.size() >= 2) printf("%lld\n", v[0] * v[1]);

	else printf("0\n");

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
//    https://youtu.be/N3oCS85HvpY



#include<bits/stdc++.h>

using namespace std;



typedef long long ll;

typedef long double ld;

typedef long long unsigned llu;

typedef pair<long long, long long> pll;

const long long inf = 2000000000000000000LL;	// 2e18

#define pi                  acos(-1.0)

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

#define shesh               "\n"

#define ff                  first

#define ss                  second

#define pb                  push_back

#define bp                  pop_back

#define pf                  push_front

#define fp                  pop_front

#define ub                  upper_bound

#define lb                  lower_bound

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

#define debug(x)            cout<<"debug "<<x<<"\n"

#define mest(a,b)           memset(a,b,sizeof(a))



int main(){

    fast;

    ll t,n,m,i,j,k,temp,flag,ans=0;

    cin>>n;

    map<ll,ll>mp;

    vector<ll>v;

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

        cin>>temp;

        mp[temp]++;

        if(mp[temp]==2){

            v.pb(temp);

        }else if(mp[temp]==4){

            ans=max(ans,temp*temp);

        }

    }

    sort(all(v));

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

        ans=max(ans,v[v.size()-1]*v[v.size()-2]);

    }

    cout<<ans;

    return 0;

}


// Optimized solution to the same problem (faster):
#include <algorithm>

#include <stdio.h>

#include <vector>

using namespace std;

#define PB push_back



constexpr int kN = int(1E5 + 10);



long long int a[kN];



int main() {

	int n;

	vector<long long int> v;

	long long int ans = 0;

	scanf("%d", &n);

	for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);

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

	for (int i = 2; i <= n; i++) if (a[i] == a[i - 1]) {

		v.PB(a[i]);

		i++;

	}

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

	if (v.size() >= 2) printf("%lld\n", v[0] * v[1]);

	else printf("0\n");

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

 

#define pb push_back

#define ll long long

#define maxn 500005

#define fr(i,j,k) for(int i=j;i<k;i++)

#define f(n) fr(i,0,n)

#define f1(n) fr(i,1,n+1)

#define ms(i) memset(i,0,sizeof(i));

#define ms1(i) memset(i,-1,sizeof(i));

#define F first

#define S second

int main(){

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    map<ll,int>mp;

    int n;

    cin >> n;

    f(n){

        int add;

        cin >> add;

        mp[-add]++;

    }

    vector<ll>v;

    for(auto i:mp){

        if(i.S<2)continue;

        while(i.S >= 2){

            v.pb(i.F);

            i.S -= 2;

        }

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

    }

    if(v.size() < 2){

        cout << 0 << endl;

    }

    else{

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

    }

}

// Optimized solution to the same problem (faster):
#include <algorithm>

#include <stdio.h>

#include <vector>

using namespace std;

#define PB push_back



constexpr int kN = int(1E5 + 10);



long long int a[kN];



int main() {

	int n;

	vector<long long int> v;

	long long int ans = 0;

	scanf("%d", &n);

	for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);

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

	for (int i = 2; i <= n; i++) if (a[i] == a[i - 1]) {

		v.PB(a[i]);

		i++;

	}

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

	if (v.size() >= 2) printf("%lld\n", v[0] * v[1]);

	else printf("0\n");

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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

// Optimized solution to the same problem (faster):
#include<iostream>

#include<algorithm>

using namespace std;

int main()

{

    int N;

    while(~scanf("%d",&N))

    {

        long long a[N+10];

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

		scanf("%lld",&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) 

		printf("%lld\n",n*m);

        else 

        printf("0\n");

    }

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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';

}


// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
//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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}




// Optimized solution to the same problem (faster):
//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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int main()

{

    int n;

    scanf("%d",&n);

    long long a[n+10];

    int i,j;

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

    {

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

    }

    sort(a,a+n);

    vector<long long>rect;

    vector<long long>square;

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

    {

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

        {

            rect.push_back(a[i]);

        }

    }

    int rects=rect.size();

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

    {

        if(rect[i]==rect[i-1]&&rect[i]==rect[i-2])

        {

            square.push_back(rect[i]);

        }

    }

    int sq=square.size();

    long long ans1=0,ans2=0;

    if(sq>=1)

    {

        ans1=square[sq-1]*square[sq-1];

    }

    if(rects>=2)

    {

        int x=0;

        for(i=rects-2;i>=0;i--)

        {

            if(rect[i]!=rect[rects-1])

            {

                x=1;

                break;

            }

        }

        if(x==1)

        {

            ans2=rect[rects-1]*rect[i];

        }

    }

    if(ans1>ans2)

    {

        printf("%lld\n",ans1);

    }

    else

    {

        printf("%lld\n",ans2);

    }

    return 0;



}


// Optimized solution to the same problem (faster):
//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;

}

// Fastest known solution for this problem: