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.4259090662906482x):
//BISMILLAHIR RAHMANIR RAHIM

//RHYTHM_086_NS_01

//ALAN_IS_ON....



#include <bits/stdc++.h>



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

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

#define     for_n(i, n)         for (int i = 1; i <= int(n); i++)

#define     pb                  push_back

#define     mp                  make_pair

#define     itr                 ::iterator

#define     s_sort(s)           sort(s.begin(),s.end())

#define     n_sort(a)           sort(a,a+n)

#define     thank_you           return 0

#define     precise_impact      cout<<setprecision(10)<<fixed;



using namespace std;



typedef long long int ll;

typedef double db;

#define MOD 1000000007



ll bigmod(ll a,ll b){

    if(b==0){

        return 1;

    }

    ll tm=bigmod(a,b/2);

    tm=(tm*tm)%MOD;

    if(b%2==1)

        tm=(tm*a)%MOD;

    return tm;



}

void solve();





int main()

{

    boost_;

    precise_impact;

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

    //freopen("out.txt","w",stdout);

    //Here we go...

    solve();



    thank_you;

}





void solve()

{

    int n;

    cin>>n;

    int a[n];

    iter_(i,n){

        cin>>a[i];

    }

    n_sort(a);

    ll b[2];

    bool b1[2]={true,true};

    int k=0;

    for(int j=n-1;j>=1;j--){

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

            if(k<2){

                b[k]=a[j];

                //b1[k]=false;

                k++;

            }

            j--;

        }

    }

    if(k!=2){

        cout<<"0"<<endl;

        //cout<<k<<endl;

    }

    else

        cout<<b[0]*b[1]<<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.759362845871325x):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;



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

#define PI  acos(-1.0)

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

#define pb push_back

int main()

{

     optimize

     int n;

     cin>>n;

     ll a[n+2];

     set<ll>st;

     map<ll,ll>Map;

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

        cin>>a[i];

        Map[a[i]]++;

        st.insert(a[i]);

     }

     ll x=0,y=0;

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

          if(Map[*it]>=2){

            x=*it;

            break;

          }

     }

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

        if(*it!=x && Map[*it]>=2){

            y=*it;

            break;

        }

     }

     if(Map[x]>=4) cout<<x*x<<endl;

     else cout<<x*y<<endl;

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

using namespace std;

typedef long long ll;



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

#define PI  acos(-1.0)

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

#define pb push_back

int main()

{

     optimize

     int n;

     cin>>n;

     ll a[n+2];

     set<ll>st;

     map<ll,ll>Map;

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

        cin>>a[i];

        Map[a[i]]++;

        st.insert(a[i]);

     }

     ll x=0,y=0;

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

          if(Map[*it]>=2){

            x=*it;

            break;

          }

     }

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

        if(*it!=x && Map[*it]>=2){

            y=*it;

            break;

        }

     }

     if(Map[x]>=4) cout<<x*x<<endl;

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

using namespace std;



int main()

{

    long int n;

    cin >> n;



    long long int input;

    vector<long long int>vec;



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

        cin >> input;

        vec.push_back(input);

    }

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

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



    long long int a = 0, b = 0, c = 0, area_1 = 0, area_2 = 0;

    int cnt = 0;



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

        if((vec[i] == vec[i+3] || vec[i] == vec[i+1]) && vec[i] > a){

            a = vec[i];

        }

        if(vec[i] == vec[i+3] && vec[i] > c){

            c = vec[i];

        }

        if((vec[i] == vec[i+3] || vec[i] == vec[i+1]) && vec[i] < a && vec[i] > b)

            b = vec[i];

    }



    area_1 = a*b;

    area_2 = c*c;



    if(area_1>area_2)

        cout << area_1;

    else

        cout << area_2;

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

using namespace std;



int main()

{

    long int n;

    cin >> n;



    long long int input;

    vector<long long int>vec;



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

        cin >> input;

        vec.push_back(input);

    }

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

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



    long long int a = 0, b = 0, c = 0, area_1 = 0, area_2 = 0;

    int cnt = 0;



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

        if((vec[i] == vec[i+3] || vec[i] == vec[i+1]) && vec[i] > a){

            a = vec[i];

        }

        if(vec[i] == vec[i+3] && vec[i] > c){

            c = vec[i];

        }

        if((vec[i] == vec[i+3] || vec[i] == vec[i+1]) && vec[i] < a && vec[i] > b)

            b = vec[i];

    }



    area_1 = a*b;

    area_2 = c*c;



    if(area_1>area_2)

        cout << area_1;

    else

        cout << area_2;

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

using namespace std;



int main() {

	map<long long, int> mp;

	int n;

	cin >> n;

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

		long long x;

		cin >> x;

		mp[x]++;

	}

	long long a = 0, b = 0;

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

		if (it->second > 1) {

			if (a == 0) {

				a = it->first;

				it->second -= 2;

			}

			if (b == 0 && it->second > 1) {

				b = it->first;

				break;

			}

		}

	}

	cout << a * b;

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

using namespace std;



int main() {

	map<long long, int> mp;

	int n;

	cin >> n;

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

		long long x;

		cin >> x;

		mp[x]++;

	}

	long long a = 0, b = 0;

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

		if (it->second > 1) {

			if (a == 0) {

				a = it->first;

				it->second -= 2;

			}

			if (b == 0 && it->second > 1) {

				b = it->first;

				break;

			}

		}

	}

	cout << a * b;

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

using namespace std;



int N,length[100001];

long long ans1,ans2;



int main(){

	ios_base::sync_with_stdio(false);

	cin.tie(NULL);

	cout.tie(NULL);

    cin>>N;

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

        cin>>length[i];

    }

    sort(length + 1,length + N + 1);

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

        if(length[i] == length[i - 1] && ans1 == 0) {

            ans1 = length[i];

            i--;

        }

        else if(length[i] == length[i - 1] && ans2 == 0) {

            ans2 = length[i];

            break;

        }

    }

    cout<<ans1 * ans2<<endl;

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

using namespace std;



int N,length[100001];

long long ans1,ans2;



int main(){

	ios_base::sync_with_stdio(false);

	cin.tie(NULL);

	cout.tie(NULL);

    cin>>N;

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

        cin>>length[i];

    }

    sort(length + 1,length + N + 1);

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

        if(length[i] == length[i - 1] && ans1 == 0) {

            ans1 = length[i];

            i--;

        }

        else if(length[i] == length[i - 1] && ans2 == 0) {

            ans2 = length[i];

            break;

        }

    }

    cout<<ans1 * ans2<<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.807723944570741x):
#include <iostream>

#include <algorithm>

using namespace std;



long long N, A[100100], idx, idx2;



int main() {

	// baca arraynya

    cin >> N;

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

        cin >> A[i];

    }

    

    // urutkan array naik A[1]..A[N]

    sort(A+1, A+N+1);



    for (int i=N; i>=2; i--){

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

            idx=i;

            break;

        }

    }

    

    for (int i=idx-2; i>=2; i--){

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

            idx2=i;

            break;

        }

    }

    cout << A[idx]*A[idx2] << endl;



    

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

#include <algorithm>

using namespace std;



long long N, A[100100], idx, idx2;



int main() {

	// baca arraynya

    cin >> N;

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

        cin >> A[i];

    }

    

    // urutkan array naik A[1]..A[N]

    sort(A+1, A+N+1);



    for (int i=N; i>=2; i--){

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

            idx=i;

            break;

        }

    }

    

    for (int i=idx-2; i>=2; i--){

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

            idx2=i;

            break;

        }

    }

    cout << A[idx]*A[idx2] << 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.8076316101157228x):
#include <bits/stdc++.h>

using namespace std;

long long a[100010],n,sisi1,sisi2;

int main() {

cin>>n;

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

	cin>>a[i];

}

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

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

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

		sisi1=i;

		break;

	}

}

for(int i=sisi1-2;i>=2;i--) {

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

		sisi2=i;

		break;

	}

}

cout<<a[sisi1]*a[sisi2]<<endl;

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

using namespace std;

long long a[100010],n,sisi1,sisi2;

int main() {

cin>>n;

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

	cin>>a[i];

}

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

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

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

		sisi1=i;

		break;

	}

}

for(int i=sisi1-2;i>=2;i--) {

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

		sisi2=i;

		break;

	}

}

cout<<a[sisi1]*a[sisi2]<<endl;

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

#include <algorithm>

#include <map>

using namespace std;

typedef long long ll;

map<ll, int> mp;

int main() {

    int n;

    ll t;

    cin >> n;

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

        cin >> t;

        mp[t] ++;

    }

    ll A[mp.size()];

    int i = 0;

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

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

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

        if (i >= 2) break;

    }



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

    else cout << "0" << endl;

    return 0;

}

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

#include<string.h>

#include<algorithm>

using namespace std;

int a[100005];

int main()

{

    int n,falg=0;



    scanf("%d",&n);

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

    {

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

    }

    sort(a,a+n);

    long long m,p;

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

    {

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

        {

            m=a[i];

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

            i--;

            falg++;

        }

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

        {

            p=a[i];

            falg=2;

            break;

        }



    }



    if(falg!=2)

        printf("0\n");

    else

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

    return 0;

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

#include<algorithm>

using namespace std;

#define ll long long

int main()

{

	ll n;

	cin>>n;

	ll a[100010];

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

	{

		cin>>a[i];

	}

	sort(a,a+n);

	ll k,m;

	ll x,y;

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

	{

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

		{

			x=a[k];

			break;

		}

	}

	//cout<<k<<" ";

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

	{

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

		{

			y=a[m];

			break;

		}

	}

	if(k<0||m<0)

	{

		cout<<"0"<<endl;

	}

	else

	{

		cout<<x*y<<endl;

	}

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.343237710538356x):
#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;

}