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

}


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

}
// Slower C++ solution:
#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';

    }

}

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

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

#include <algorithm>

using namespace std;



int a[100005];

int ans[100005];



bool cmp(int a, int b) {

    return a > b;

}



int main() {

    int n;

    cin >> n;

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

        cin >> a[i];

    }

    sort(a, a+n, cmp);

    int tmp=a[0], cnt=1, j=0;

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

        if(a[i] == tmp) {

            cnt ++;

        }

        else {

            if(cnt >= 4) {

                ans[j] = tmp;

                j++;

                ans[j] = tmp;

                j++;

            }

            else if(cnt >= 2) {

                ans[j] = tmp;

                j++;

            }

            tmp = a[i];

            cnt = 1;

        }

    }

    if(cnt >= 2) {

        ans[j] = tmp;

        j++;

    }

    /*for(int i=0; i<j; i++) {

        cout << ans[i] << " \n"[i == j-1];

    }*/

    cout << (long long int)ans[0] * ans[1] << 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.764630218216921x):
#include<bits/stdc++.h>



using namespace std;



int main(){

	ios::sync_with_stdio(false);

	cin.tie(0);

	

	int n,inp;

	cin >> n;

	map<int,int> m;

	priority_queue<int> pq;

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

		cin >> inp;

		m[inp]++;

		if(m[inp]==2){

			pq.emplace(inp);

			m[inp]=0;

		}

	}

	long long w,l;

	if(pq.size()){

		w=pq.top();

		pq.pop();

	}

	else{

		cout << "0\n";

		return 0;

	}

	if(pq.size()){

		l=pq.top();

		cout << w*l << '\n';

	}

	else cout << "0\n";

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

#define MAX_N 100000 + 5

using namespace std;



bool cmp(long long &a, long long &b){

	return a > b;

}



int main(){

	int N;

	long long n[MAX_N];

	cin >> N;

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

		cin >> n[i];

	sort(n, n + N, cmp);

	

	long long ans = 0, res = 0;

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

		if(n[i] != res){

			int cnt = 1;

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

				if(n[i] == n[j]) cnt++;

				else break;

			}

			

			if(cnt >= 2){

				if(cnt >= 4)

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

				ans = max(ans, res * n[i]);

				

				res = n[i];

			}

		}

	}

	

	cout << ans << 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.7203205740944345x):
#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;

	LL ans = 0, A[MAX_N];

	map<int, int> mp;

	

	cin >> N;

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

	

	vector<LL> vec;

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

	{

		if (mp[A[i]] >= 2)

		{

			if (mp[A[i]] >= 4) ans = max(ans, A[i] * A[i]);

			

			vec.emplace_back(A[i]);

		}//if

	}//for i

	

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

	vec.resize(unique(vec.begin(), vec.end()) - vec.begin());

	

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

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

		

	cout << ans << '\n';

	

	return 0;

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

using namespace std;



int main()

{

	int n;

	cin>>n;

	int64_t a[n]={};

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

		cin>>a[i];

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

	int64_t x = 0 , y = 0;

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

	{



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

		{

			if( x == 0)

				x = a[i];

			else if ( y == 0)

				y = a[i];

			i+=1;

		}

		if( x && y)

			break;

	}

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

using namespace std;



int main()

{

	int n;

	cin>>n;

	int64_t a[n]={};

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

		cin>>a[i];

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

	int64_t x = 0 , y = 0;

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

	{



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

		{

			if( x == 0)

				x = a[i];

			else if ( y == 0)

				y = a[i];

			i+=1;

		}

		if( x && y)

			break;

	}

	cout<< x * y <<"\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.7602102445665155x):
#include <iostream>

#include <set>

using namespace std;

int main()

{

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

    int n;

    while (cin >> n)

    {

        set<int> se;

        long long x, f = 0, s = 0;

        while (n--)

        {

            cin >> x;

            if (se.find(x) == se.end())

                se.insert(x);

            else

            {

                se.erase(x);

                if (x > f)

                {

                    s = f;

                    f = x;

                }

                else if (x > s)

                    s = x;

            }

        }

        cout << f * s << '\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.4046843411015597x):
#include <iostream>

#include <set>

using namespace std;

int main()

{

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

    int n;

    while (cin >> n)

    {

        set<int> se;

        long long x, f = 0, s = 0;

        while (n--)

        {

            cin >> x;

            if (se.find(x) == se.end())

                se.insert(x);

            else

            {

                se.erase(x);

                if (x > f)

                {

                    s = f;

                    f = x;

                }

                else if (x > s)

                    s = x;

            }

        }

        cout << f * s << '\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.8287228616216993x):
#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;

}
// 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.4593588327666194x):
#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;

}
// 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.8015574700074861x):
#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;

    }

}