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

using namespace std;



typedef long long ll;

const ll INF = 1e18;

const int BIG = 1e9 + 555;



int n;

map<ll, ll> mp;



int main(){

	ios::sync_with_stdio(false);

	cin.tie(0);

	cout.tie(0);



	cin >> n;



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

		ll x;	cin >> x;

		mp[x]++;

	}



	vector<ll> vv;

	

	ll fRes = 0;

	for(map<ll, ll>::iterator it = mp.begin(); it != mp.end(); it++){

		if(it->second < 2){

			continue;

		}

		vv.push_back(it->first);

		if(it->second >= 4){

			fRes = max(fRes, (it->first) * (it->first));

		}

	}

	

	if((int)vv.size() > 1){

		int L = (int)vv.size();

		fRes = max(fRes, vv[L - 2] * vv[L - 1]);

	}



	cout << fRes << '\n';



	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.1043791810995125x):
#pragma warning( disable : 4996 )

/*

#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")

#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#pragma comment(linker, "/stack:200000000")

#pragma GCC optimize("O3")

*/

//#include <bits/stdc++.h>

#include <cstdio>

#include <cstring>

#include <cstdint>

#include <cmath>

#include <algorithm>

#include <tuple>

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

#define FOR(i, l, r) for (int i = (l); i < (r); ++i)

#define FORR(i, r, l) for (int i =(r); i >= (l); --i)

#define P(STR) puts(#STR)



using namespace std;



constexpr int Dir4[4][2] = { {0, 1}, {1, 0}, {0, -1}, {-1, 0} };

constexpr int Dir8[8][2] = { {-1, -1}, {-1, 1}, {0, -1}, {0, 1}, {1, -1}, {1, 1} };

constexpr double EPS = 1e-8;

const double PI = acos(-1);



using int16 = short;

using uint16 = unsigned short;

using uint = unsigned int;

using int64 = long long;

using uint64 = unsigned long long;

using pii = pair<int, int>;



auto Equal = [](double a, double b) { return fabs(a - b) < EPS; };



/* mods */



/* main code */

#include <set>

#include <map>



int n, x;

map<int, int> cnt;

multiset<int> Set;



int main()

{

	scanf("%d", &n);



	while (n--)

	{

		scanf("%d", &x);



		++cnt[x];

		if (cnt[x] == 2)

		{

			cnt[x] = 0;

			Set.insert(x);

		}

	}



	if (Set.size() < 2)

	{

		P(0);

		return 0;

	}



	auto a = Set.rbegin(), b = Set.rbegin();

	++b;



	printf("%lld", (int64)(*a) * (*b));



	return 0;

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

using namespace std;



int main()

{

    int n,i;

    cin>>n;

    long long l[n];

    for(i=0;i<n;i++) cin>>l[i];

    sort(l,l+n);

    long long ans=0,x=0,y=0;

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

    {

        if(x!=0 && y!=0) break;

        else if(x==0 && l[i]==l[i-1]) {

                x=l[i];

                i=i-2;

        }

        else if(x!=0 && l[i]==l[i-1]) {

                y=l[i];

                i=i-2;

        }

        else i--;

    }

    ans=x*y;

    cout<<ans<<"\n";

    return 0;

}


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

#include<string.h>

#include<algorithm>

#include<map>

 #define ll long long

  ll a[100005],b[100005];

using namespace std;

int main()

{

    int n;

    int flag=0;

    scanf("%d",&n);

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

    {

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

    }

    sort(a,a+n);

    int t=0;

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

    {

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

        {

            b[t]=a[j];

            a[j]=a[j-1]=0;

            t++;

            if(t==2)

            {

                flag=1;

                break;

            }

        }

    }

    if(flag==0)

        printf("0\n");

    else

    printf("%lld\n",b[0]*b[1]);

}
// Slower C++ solution:


#include <bits/stdc++.h>

using namespace std;



#define LL long long



LL ara[100000+10];

//vector<LL>v;

LL v[100000+10];



LL abso(LL x)

{

	if(x<0)

		return -1*x;



	else

		return x;

}



int main() {



    LL n,cnt=0,ans=-1,k=1;

    scanf("%lld",&n);



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

    {

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

    }



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



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

    {

        if(ara[i]!=ara[i+1])

            cnt=0;



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

        {

            cnt++;



            if(cnt+1==2)

            {

                v[k]=ara[i];

                k++;



            }



            if(cnt+1==4)

            {

                if(ara[i]*ara[i]>ans)

                {

                    ans=ara[i]*ara[i];

                    //cout<<"#*"<<ans<<endl;



                }



            }



        }

    }



    /*for(int i=1;i<=k;i++)

        cout<<v[i]<<" ";

*/

    //vector<LL>::iterator it = v.end();

    LL w = v[k-1];

    LL r = v[k-2];



    //cout<<"*"<<w<<" "<<r<<endl;



    LL ansi=w*r;



    if(ansi>ans)

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



    else if(ansi<=ans)

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



    else

        printf("0\n");





	return 0;

}


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

#include<string.h>

#include<algorithm>

#include<map>

 #define ll long long

  ll a[100005],b[100005];

using namespace std;

int main()

{

    int n;

    int flag=0;

    scanf("%d",&n);

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

    {

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

    }

    sort(a,a+n);

    int t=0;

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

    {

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

        {

            b[t]=a[j];

            a[j]=a[j-1]=0;

            t++;

            if(t==2)

            {

                flag=1;

                break;

            }

        }

    }

    if(flag==0)

        printf("0\n");

    else

    printf("%lld\n",b[0]*b[1]);

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

using namespace std;

#define ll long long int

int main(){

	ll i,j,k,l,n;

	cin>>n;

	ll ar[n+1]; map<ll,ll> mp;

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

		cin>>ar[i];

		mp[ar[i]]++;

	}

	

	ll mx=-1; set<ll> st;

	for(auto it:mp){

		if(it.second>=4){

			mx=max(mx,it.first);

		}

		else if(it.second>=2){

			st.insert(it.first);

		}

	}



	

	ll mx2=-1,mx3=-1;

	if(st.size()>=1){

		mx3=max(mx3,mx*(*(--st.end())));

	}

		if(mx!=-1) mx=mx*mx;

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

		ll a,b;

		a=*(--st.end());

		st.erase(*(--st.end()));

		b=*(--st.end());

		mx2=max(mx2,a*b);

	}

	if(mx==-1&&mx2==-1){

		cout<<"0";

	}

	else{

		cout<<max(mx,max(mx2,mx3));

	}

	return 0;

}

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

#include<string.h>

#include<algorithm>

#include<map>

 #define ll long long

  ll a[100005],b[100005];

using namespace std;

int main()

{

    int n;

    int flag=0;

    scanf("%d",&n);

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

    {

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

    }

    sort(a,a+n);

    int t=0;

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

    {

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

        {

            b[t]=a[j];

            a[j]=a[j-1]=0;

            t++;

            if(t==2)

            {

                flag=1;

                break;

            }

        }

    }

    if(flag==0)

        printf("0\n");

    else

    printf("%lld\n",b[0]*b[1]);

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

#include<stdio.h>

#include<cstring>

#include<cmath>

#include<algorithm>

#include<map>

#define ll long long

using namespace std;

int main(){

	int n;

	cin>>n;

	ll a[n];

	int j=0;

	map<ll,ll> m;

	ll num;

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

		cin>>num;

		m[num]++;

	}

	ll flag=0;

    for(map<ll,ll>::reverse_iterator rit=m.rbegin();rit!=m.rend();rit++){

        if(rit->second>=2){

        	a[j++]=rit->first;

        	if(j>=2){

                break;

        	}

		}

        if((*rit).second>=4){

            flag=(*rit).first;

        }

        //cout<<(*rit).first<<","<<(*rit).second<<endl;

    }

	/*map<ll, ll>::iterator  iter;

	for(iter = m.end(); iter != m.begin(); iter--){



		cout<<iter->first<<" "<<iter->second<<endl;

    }

    for(iter = m.begin(); iter != m.end(); iter++){

        if(iter->second>=2){

        	a[j++]=iter->first;

		}

		cout<<iter->first<<" "<<iter->second<<endl;

    }

*/

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

    	cout<<a[i]<<" ";

	}*/



	if(flag){

        cout<<flag*flag<<endl;

    }else{

        if(j<2){

            if(flag){

                cout<<flag*flag<<endl;

            }else{

                cout<<0<<endl;

            }



        }else{

            cout<<a[j-1]*a[j-2]<<endl;

        }

    }

	return 0;

}


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

#include<string.h>

#include<algorithm>

#include<map>

 #define ll long long

  ll a[100005],b[100005];

using namespace std;

int main()

{

    int n;

    int flag=0;

    scanf("%d",&n);

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

    {

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

    }

    sort(a,a+n);

    int t=0;

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

    {

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

        {

            b[t]=a[j];

            a[j]=a[j-1]=0;

            t++;

            if(t==2)

            {

                flag=1;

                break;

            }

        }

    }

    if(flag==0)

        printf("0\n");

    else

    printf("%lld\n",b[0]*b[1]);

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

using namespace std;



typedef long long ll;

const ll INF = 1e18;

const int BIG = 1e9 + 555;



int n;

map<ll, ll> mp;



int main(){

	ios::sync_with_stdio(false);

	cin.tie(0);

	cout.tie(0);



	cin >> n;



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

		ll x;	cin >> x;

		mp[x]++;

	}



	vector<ll> vv;

	

	ll fRes = 0;

	for(map<ll, ll>::iterator it = mp.begin(); it != mp.end(); it++){

		if(it->second < 2){

			continue;

		}

		vv.push_back(it->first);

		if(it->second >= 4){

			fRes = max(fRes, (it->first) * (it->first));

		}

	}

	

	if((int)vv.size() > 1){

		int L = (int)vv.size();

		fRes = max(fRes, vv[L - 2] * vv[L - 1]);

	}



	cout << fRes << '\n';



	return 0;

}

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

#include<string.h>

#include<algorithm>

#include<map>

 #define ll long long

  ll a[100005],b[100005];

using namespace std;

int main()

{

    int n;

    int flag=0;

    scanf("%d",&n);

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

    {

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

    }

    sort(a,a+n);

    int t=0;

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

    {

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

        {

            b[t]=a[j];

            a[j]=a[j-1]=0;

            t++;

            if(t==2)

            {

                flag=1;

                break;

            }

        }

    }

    if(flag==0)

        printf("0\n");

    else

    printf("%lld\n",b[0]*b[1]);

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

    #include <vector>

    #include <algorithm>

     

    using namespace std;

     

    void solve() {

        int n;

        cin >> n;

     

        vector<int64_t> a(n);

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

            cin >> a[i];

        }

     

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

     

        vector<int64_t> b;

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

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

                b.push_back(a[i]);

                i++;

            }

        }

     

        int64_t result = 0;

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

            for(int j = i+1; j < b.size(); j++){

                result = max(result, b[i]*b[j]);

            }

        }

     

        cout << result << endl;

    }

     

    int main() {

        solve();

        return 0;

    }

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

#include<string.h>

#include<algorithm>

#include<map>

 #define ll long long

  ll a[100005],b[100005];

using namespace std;

int main()

{

    int n;

    int flag=0;

    scanf("%d",&n);

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

    {

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

    }

    sort(a,a+n);

    int t=0;

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

    {

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

        {

            b[t]=a[j];

            a[j]=a[j-1]=0;

            t++;

            if(t==2)

            {

                flag=1;

                break;

            }

        }

    }

    if(flag==0)

        printf("0\n");

    else

    printf("%lld\n",b[0]*b[1]);

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



using namespace std;



#define ll long long int



int main()

{

    ll n,i,x;

    cin>>n;

    set<ll>S;

    vector<ll>B;

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

    {

        cin>>x;

        if(S.count(x))

		{

        S.erase(x);

        B.push_back(x);

		}

        else

        S.insert(x);

    }

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

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

        printf("0\n");

    }

    else

    {

       	x=(ll)B.size();

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

    }

    return 0;

}

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

#include<string.h>

#include<algorithm>

#include<map>

 #define ll long long

  ll a[100005],b[100005];

using namespace std;

int main()

{

    int n;

    int flag=0;

    scanf("%d",&n);

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

    {

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

    }

    sort(a,a+n);

    int t=0;

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

    {

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

        {

            b[t]=a[j];

            a[j]=a[j-1]=0;

            t++;

            if(t==2)

            {

                flag=1;

                break;

            }

        }

    }

    if(flag==0)

        printf("0\n");

    else

    printf("%lld\n",b[0]*b[1]);

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

using namespace std;

int main()

{

    unsigned int n,i,j;

    long long int lar=0,seclar=0;

    cin>>n;

    long long int a[n];

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

    {

        cin>>a[i];

    }

    sort(a,a+n,greater<long long int>());

    



    int count=0;

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

    {

        

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

        {

            lar=a[i];

            

            break;

        }

        

        

    }

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

    {if(a[i]==lar)

    {

        count++;

    }}

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

    {

        if(a[i]==a[i+1] && a[i]!=lar && a[i+1]!=lar)

        {

            seclar=a[i];

            break;

        }

        

    }

    if(count<4)

    cout<<lar*seclar;

    else

    cout<<lar*lar;

    return 0;

    

}


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

#include<string.h>

#include<algorithm>

#include<map>

 #define ll long long

  ll a[100005],b[100005];

using namespace std;

int main()

{

    int n;

    int flag=0;

    scanf("%d",&n);

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

    {

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

    }

    sort(a,a+n);

    int t=0;

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

    {

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

        {

            b[t]=a[j];

            a[j]=a[j-1]=0;

            t++;

            if(t==2)

            {

                flag=1;

                break;

            }

        }

    }

    if(flag==0)

        printf("0\n");

    else

    printf("%lld\n",b[0]*b[1]);

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

using namespace std;

typedef pair<int,int> pii;

#define F first

#define S second

#define ALL(a) begin(a), end(a)

int main()

{

    int n;

    priority_queue<int, vector<int>, greater<int>> pq;

    map<int,int> mp;

    cin >> n;

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

        int a;

        cin >> a;

        if (++mp[a] == 2) {

            mp[a] = 0;

            pq.push(a);

            if (pq.size() > 2)

                pq.pop();

        }

    }

    if (pq.size() != 2) {

        cout << 0 << endl;

    } else {

        int x = pq.top();

        pq.pop();

        cout << x * 1ll * pq.top() << endl;

    }

}


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

#include<string.h>

#include<algorithm>

#include<map>

 #define ll long long

  ll a[100005],b[100005];

using namespace std;

int main()

{

    int n;

    int flag=0;

    scanf("%d",&n);

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

    {

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

    }

    sort(a,a+n);

    int t=0;

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

    {

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

        {

            b[t]=a[j];

            a[j]=a[j-1]=0;

            t++;

            if(t==2)

            {

                flag=1;

                break;

            }

        }

    }

    if(flag==0)

        printf("0\n");

    else

    printf("%lld\n",b[0]*b[1]);

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

#define N 100100

using namespace std;

int a[N];

int main(){

	int n;

	scanf("%d",&n);

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

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

	int x=0,y=0;

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

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

			if(!x) x=a[i];

			else if(!y) y=a[i];

			i++;

		}

	}

	printf("%lld\n",1LL*x*y);

	return 0;

}

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

#include<string.h>

#include<algorithm>

#include<map>

 #define ll long long

  ll a[100005],b[100005];

using namespace std;

int main()

{

    int n;

    int flag=0;

    scanf("%d",&n);

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

    {

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

    }

    sort(a,a+n);

    int t=0;

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

    {

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

        {

            b[t]=a[j];

            a[j]=a[j-1]=0;

            t++;

            if(t==2)

            {

                flag=1;

                break;

            }

        }

    }

    if(flag==0)

        printf("0\n");

    else

    printf("%lld\n",b[0]*b[1]);

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

#include<map>

using namespace std;



int main(){

	long long int n,ans=0,ouo=0,tmp;

	long long int quq=0,ququq=0;

	long long int ouq=0; 

	long long int ans2,ans4;

	map <long long int,long long int> mp;

	cin>>n;

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

		cin>>ouo;

		mp[ouo]++;

		if(mp[ouo]==2) {

			if(ouo>quq) quq=ouo;

			if(quq>ququq){

				tmp = quq;

				quq = ququq;

				ququq = tmp;

			}

		}

		if(mp[ouo]==4){

			if(ouo>ouq){

				ouq = ouo;

			}

		}

	}

	ans2 = quq * ququq;

	ans4 = ouq * ouq;

	if(ans2>=ans4) ans = ans2;

	else ans = ans4;

	cout<<ans<<endl;

}


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

#include<string.h>

#include<algorithm>

#include<map>

 #define ll long long

  ll a[100005],b[100005];

using namespace std;

int main()

{

    int n;

    int flag=0;

    scanf("%d",&n);

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

    {

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

    }

    sort(a,a+n);

    int t=0;

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

    {

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

        {

            b[t]=a[j];

            a[j]=a[j-1]=0;

            t++;

            if(t==2)

            {

                flag=1;

                break;

            }

        }

    }

    if(flag==0)

        printf("0\n");

    else

    printf("%lld\n",b[0]*b[1]);

}
// Slower C++ solution:
/*input

10

3 3 3 3 4 4 4 5 5 5

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long lol;

#define MAX 100010



int n;

multiset<int> s;

lol a[MAX], ans;



void init() {

	ans = 0;

	s.clear();

	memset(a, 0, sizeof(a));

}



int main() {

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



	cin >> n;

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

		cin >> a[i];

		s.insert(a[i]);

	}

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



	lol big = -1;

	for (int i = n; i >= 1; i--) if (s.count(a[i]) >= 2) {

		if (s.count(a[i]) >= 4) {

			ans = max(a[i] * a[i], a[i] * big);

			break;

		}

		if (big != -1 && big != a[i]) {

			ans = max(ans, a[i] * big);

			break;

		}

		else

			big = a[i];

	}

	cout << ans << '\n';

	return 0;

}

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

#include<string.h>

#include<algorithm>

#include<map>

 #define ll long long

  ll a[100005],b[100005];

using namespace std;

int main()

{

    int n;

    int flag=0;

    scanf("%d",&n);

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

    {

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

    }

    sort(a,a+n);

    int t=0;

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

    {

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

        {

            b[t]=a[j];

            a[j]=a[j-1]=0;

            t++;

            if(t==2)

            {

                flag=1;

                break;

            }

        }

    }

    if(flag==0)

        printf("0\n");

    else

    printf("%lld\n",b[0]*b[1]);

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

using namespace std;

using ll = long long;



int main(){

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

	vector<ll> v;

	ll n;

	cin >> n;

	v.resize(n);

	for(auto& i:v)

		cin >> i;

	map<ll, ll, greater<ll>> cnt;

	for(const auto& i:v){

		if(cnt.find(i)==cnt.end())

			cnt[i]=0;

		cnt[i]++;

	}

	ll a, b;

	a=b=0;

	for(auto& i:cnt){

		if(i.second>=2){

			i.second-=2;

			a=i.first;

			break;

		}

	}

	for(auto& i:cnt){

		if(i.second>=2){

			b = i.first;

			break;

		}

	}

	cout << a*b << "\n";

	return 0;

}


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

#include<string.h>

#include<algorithm>

#include<map>

 #define ll long long

  ll a[100005],b[100005];

using namespace std;

int main()

{

    int n;

    int flag=0;

    scanf("%d",&n);

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

    {

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

    }

    sort(a,a+n);

    int t=0;

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

    {

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

        {

            b[t]=a[j];

            a[j]=a[j-1]=0;

            t++;

            if(t==2)

            {

                flag=1;

                break;

            }

        }

    }

    if(flag==0)

        printf("0\n");

    else

    printf("%lld\n",b[0]*b[1]);

}
// Slower C++ solution:
#pragma warning( disable : 4996 )

/*

#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")

#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#pragma comment(linker, "/stack:200000000")

#pragma GCC optimize("O3")

*/

//#include <bits/stdc++.h>

#include <cstdio>

#include <cstring>

#include <cstdint>

#include <cmath>

#include <algorithm>

#include <tuple>

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

#define FOR(i, l, r) for (int i = (l); i < (r); ++i)

#define FORR(i, r, l) for (int i =(r); i >= (l); --i)

#define P(STR) puts(#STR)



using namespace std;



constexpr int Dir4[4][2] = { {0, 1}, {1, 0}, {0, -1}, {-1, 0} };

constexpr int Dir8[8][2] = { {-1, -1}, {-1, 1}, {0, -1}, {0, 1}, {1, -1}, {1, 1} };

constexpr double EPS = 1e-8;

const double PI = acos(-1);



using int16 = short;

using uint16 = unsigned short;

using uint = unsigned int;

using int64 = long long;

using uint64 = unsigned long long;

using pii = pair<int, int>;



auto Equal = [](double a, double b) { return fabs(a - b) < EPS; };



/* mods */



/* main code */

#include <set>

#include <map>



int n, x;

map<int, int> cnt;

multiset<int> Set;



int main()

{

	scanf("%d", &n);



	while (n--)

	{

		scanf("%d", &x);



		++cnt[x];

		if (cnt[x] == 2)

		{

			cnt[x] = 0;

			Set.insert(x);

		}

	}



	if (Set.size() < 2)

	{

		P(0);

		return 0;

	}



	auto a = Set.rbegin(), b = Set.rbegin();

	++b;



	printf("%lld", (int64)(*a) * (*b));



	return 0;

}


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

#include<string.h>

#include<algorithm>

#include<map>

 #define ll long long

  ll a[100005],b[100005];

using namespace std;

int main()

{

    int n;

    int flag=0;

    scanf("%d",&n);

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

    {

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

    }

    sort(a,a+n);

    int t=0;

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

    {

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

        {

            b[t]=a[j];

            a[j]=a[j-1]=0;

            t++;

            if(t==2)

            {

                flag=1;

                break;

            }

        }

    }

    if(flag==0)

        printf("0\n");

    else

    printf("%lld\n",b[0]*b[1]);

}