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

#define int long long



using namespace std;



signed main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(0);



    int n, arr[100000];

    cin >> n;

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

        cin >> arr[i];

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



    int s = -1;

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

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

            if (s == -1)

                s = arr[i], i++;

            else

                return cout << s * arr[i] << '\n', 0;

    cout << "0\n";



    return 0;

}


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

#include<vector>

#include<set>

#include<algorithm>

using namespace std;

set<long long>k;

vector<long long>t;

int main()

{

    long long a,h,siz,p,q;

    scanf("%lld",&a);

    for(long long i=0;i<a;i++)

    {

        siz=k.size();

        scanf("%lld",&h);

        k.insert(h);

        if(k.size()==siz)

        {

            t.push_back(h);

        }

    }

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

    p=count(t.begin(),t.end(),t[t.size()-1]);

    if(p>=3)

    {

    printf("%lld",t[t.size()-1]*t[t.size()-1]);

    }

    else if(t.size()>=2)

    {

    printf("%lld",t[t.size()-1]*(t[t.size()-p-1]));

    }

    else printf("0");

    return 0;

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

#include<vector>

#include<map>

#include<algorithm>

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

#define allr(x) x.rbegin(),x.rend()

#define pb push_back

#define mp make_pair

#define F first

#define S second

#define eb emplace_back

#define int long long

#define MOD 1000000007

#define PI 2*acos(0)

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

using namespace std;

int32_t main() {

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

	int n, a; cin >> n;

	map<int, int> c;

	vector<int> v;

	forn(i, n) {

		cin >> a;

		c[a]++;

		if (c[a] == 2)v.pb(a);

	}

	sort(allr(v));

	if (v.size() && c[v[0]] >= 4)

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

	else if (v.size() > 1)

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

	else

		cout << "0\n";	

	return 0;

}


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

#include<vector>

#include<set>

#include<algorithm>

using namespace std;

set<long long>k;

vector<long long>t;

int main()

{

    long long a,h,siz,p,q;

    scanf("%lld",&a);

    for(long long i=0;i<a;i++)

    {

        siz=k.size();

        scanf("%lld",&h);

        k.insert(h);

        if(k.size()==siz)

        {

            t.push_back(h);

        }

    }

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

    p=count(t.begin(),t.end(),t[t.size()-1]);

    if(p>=3)

    {

    printf("%lld",t[t.size()-1]*t[t.size()-1]);

    }

    else if(t.size()>=2)

    {

    printf("%lld",t[t.size()-1]*(t[t.size()-p-1]));

    }

    else printf("0");

    return 0;

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

#include <set>

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

using namespace std;



int main()

{

    BurstStream

    int n;

    while (cin >> n)

    {

        long long mxside[] = {0, 0};

        set<long long> s;



        while (n--)

        {

            long long temp;

            cin >> temp;



            if (s.find(temp) == s.end()) s.insert(temp);

            else

            {

                s.erase(temp);

                if (temp > mxside[0])

                {

                    mxside[1] = mxside[0];

                    mxside[0] = temp;

                }

                else if (temp > mxside[1]) mxside[1] = temp;

            }

        }

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

    }

    return 0;

}


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

#include<vector>

#include<set>

#include<algorithm>

using namespace std;

set<long long>k;

vector<long long>t;

int main()

{

    long long a,h,siz,p,q;

    scanf("%lld",&a);

    for(long long i=0;i<a;i++)

    {

        siz=k.size();

        scanf("%lld",&h);

        k.insert(h);

        if(k.size()==siz)

        {

            t.push_back(h);

        }

    }

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

    p=count(t.begin(),t.end(),t[t.size()-1]);

    if(p>=3)

    {

    printf("%lld",t[t.size()-1]*t[t.size()-1]);

    }

    else if(t.size()>=2)

    {

    printf("%lld",t[t.size()-1]*(t[t.size()-p-1]));

    }

    else printf("0");

    return 0;

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

}

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

using namespace std;

int main()

{

    long long int n,i,sum = -100,m;

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



    vector<long long int>v;

    cin>>n;

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

    {

        cin>>m;

      if(mp[m]==0)

        v.push_back(m);



        mp[m]++;





    }

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

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

    {



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

        {

            for(int j = v.size()-1; j > i; j--)

            {

                if(mp[v[j]]>=2)

                {



                    if(v[i]*v[j]>sum)

                        sum = v[i]*v[j];

                    break;

                }



            }

        }



    }

    for(i = v.size()-1; i >= 0; i--)

    {



        if(mp[v[i]]>=4 && v[i]*v[i]>sum)

        {

            sum = v[i]*v[i];

            break;

        }



    }



    if(sum<0)

        sum = 0;

    cout<<sum<<endl;

    return 0;

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

}




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

using namespace std;

int main()

{

    long long int n,i,sum = -100,m;

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



    vector<long long int>v;

    cin>>n;

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

    {

        cin>>m;

      if(mp[m]==0)

        v.push_back(m);



        mp[m]++;





    }

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

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

    {



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

        {

            for(int j = v.size()-1; j > i; j--)

            {

                if(mp[v[j]]>=2)

                {



                    if(v[i]*v[j]>sum)

                        sum = v[i]*v[j];

                    break;

                }



            }

        }



    }

    for(i = v.size()-1; i >= 0; i--)

    {



        if(mp[v[i]]>=4 && v[i]*v[i]>sum)

        {

            sum = v[i]*v[i];

            break;

        }



    }



    if(sum<0)

        sum = 0;

    cout<<sum<<endl;

    return 0;

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

}

// Faster C++ solution for the same problem (measured speedup: 1.76676949134924x):
///Bismillahir Rahmanir Rahim

#include "bits/stdc++.h"



#define                           ll                          long long

#define                           int                         ll

#define                           fi                          first

#define                           si                          second

#define                           mp                          make_pair

#define                           pb                          push_back

#define                           pi                          pair<ll,ll>

#define                           clr(x)                      memset(x,0,sizeof(x));

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

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

#define                           done(i)                     cout<<"done = "<<i<<endl;

#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;

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



using namespace std;



const ll inf=1e18;

const int mod=1e9+7;

const int M=100005;

vector<int>vec;

map<int,int>cnt;

int ses=0;

 main()



{

    fast

    int n;

    cin>>n;

    f(i,1,n)

    {

        int x;

        cin>>x;

        cnt[x]++;

    }

    for(auto x:cnt)

    {

        if(x.si>=2)vec.pb(x.fi);

        if(x.si>=4)ses=max(ses,(x.fi*x.fi));

    }

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

    if(vec.size()<2)

    {

        cout<<ses<<endl;

        return 0;

    }

    int a=vec.back();

    vec.pop_back();

    int b=vec.back();

    ses=max(ses,a*b);

    cout<<ses<<endl;

    return 0;



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

}




// Faster C++ solution for the same problem (measured speedup: 3.4626366904731065x):
///Bismillahir Rahmanir Rahim

#include "bits/stdc++.h"



#define                           ll                          long long

#define                           int                         ll

#define                           fi                          first

#define                           si                          second

#define                           mp                          make_pair

#define                           pb                          push_back

#define                           pi                          pair<ll,ll>

#define                           clr(x)                      memset(x,0,sizeof(x));

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

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

#define                           done(i)                     cout<<"done = "<<i<<endl;

#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;

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



using namespace std;



const ll inf=1e18;

const int mod=1e9+7;

const int M=100005;

vector<int>vec;

map<int,int>cnt;

int ses=0;

 main()



{

    fast

    int n;

    cin>>n;

    f(i,1,n)

    {

        int x;

        cin>>x;

        cnt[x]++;

    }

    for(auto x:cnt)

    {

        if(x.si>=2)vec.pb(x.fi);

        if(x.si>=4)ses=max(ses,(x.fi*x.fi));

    }

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

    if(vec.size()<2)

    {

        cout<<ses<<endl;

        return 0;

    }

    int a=vec.back();

    vec.pop_back();

    int b=vec.back();

    ses=max(ses,a*b);

    cout<<ses<<endl;

    return 0;



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

}

// Faster C++ solution for the same problem (measured speedup: 1.7860581205865098x):
//Bismillahir Rahmanir Rahim

//In the name of Allah the Most Merciful

//Astagfirullahil laji Rabbi Minkulli Jamio

#include<bits/stdc++.h>

using namespace std;

#define int long long int

#define double long double

int i,j,k;

main()

{



 int n;cin>>n;

 int a[n]={0};

 int b[n]={0};int j=0;

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

    cin>>a[i];

    int c[n]={0};k=0;

    map<int,int> m;

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

    {

        m[a[i]]++;

        if(m[a[i]]==2)

        {

            b[j++]=a[i];

        }

        if(m[a[i]]==4)

        {

            c[k++]=a[i];

        }

    }

//for(i=0;i<j;i++) cout<<b[i]<<' ';

//for(i=0;i<k;i++) cout<<c[i]<<' ';

   sort(b,b+j);

   sort(c,c+k);

   if(k==0&&j==0) cout<<0<<endl;

   else

   if(k==0) cout<<b[j-1]*b[j-2]<<endl;

   else if(j<=1) cout<<c[k-1]*c[k-1]<<endl;

   else cout<<max(c[k-1]*c[k-1],b[j-1]*b[j-2]);

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

}




// Faster C++ solution for the same problem (measured speedup: 3.5004398762497058x):
//Bismillahir Rahmanir Rahim

//In the name of Allah the Most Merciful

//Astagfirullahil laji Rabbi Minkulli Jamio

#include<bits/stdc++.h>

using namespace std;

#define int long long int

#define double long double

int i,j,k;

main()

{



 int n;cin>>n;

 int a[n]={0};

 int b[n]={0};int j=0;

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

    cin>>a[i];

    int c[n]={0};k=0;

    map<int,int> m;

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

    {

        m[a[i]]++;

        if(m[a[i]]==2)

        {

            b[j++]=a[i];

        }

        if(m[a[i]]==4)

        {

            c[k++]=a[i];

        }

    }

//for(i=0;i<j;i++) cout<<b[i]<<' ';

//for(i=0;i<k;i++) cout<<c[i]<<' ';

   sort(b,b+j);

   sort(c,c+k);

   if(k==0&&j==0) cout<<0<<endl;

   else

   if(k==0) cout<<b[j-1]*b[j-2]<<endl;

   else if(j<=1) cout<<c[k-1]*c[k-1]<<endl;

   else cout<<max(c[k-1]*c[k-1],b[j-1]*b[j-2]);

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

}

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

#define cy cout << "YES" << endl;

#define cn cout << "NO" << endl;

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

using namespace std;

int main()

{



    long long a,b,c,d,e;

    cin >> a;

     map<long long,long long>mp;

    vector<long long>vec;

    while(a--)

    {

        cin >> b;

        mp[b]++;

    }



    for(auto it=mp.begin();it!=mp.end();it++){

        if(it->second>=4)

        {

            vec.push_back(it->first);

            vec.push_back(it->first);

        }

        if(it->second>=2)



        {

            vec.push_back(it->first);

        }



    }

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

    if(vec.size()>1)

    {

        long long x=vec[vec.size()-1]*vec[vec.size()-2];

        cout << x << endl;



    }

    else{

        cout << 0 << endl;

    }





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

}




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

#define cy cout << "YES" << endl;

#define cn cout << "NO" << endl;

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

using namespace std;

int main()

{



    long long a,b,c,d,e;

    cin >> a;

     map<long long,long long>mp;

    vector<long long>vec;

    while(a--)

    {

        cin >> b;

        mp[b]++;

    }



    for(auto it=mp.begin();it!=mp.end();it++){

        if(it->second>=4)

        {

            vec.push_back(it->first);

            vec.push_back(it->first);

        }

        if(it->second>=2)



        {

            vec.push_back(it->first);

        }



    }

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

    if(vec.size()>1)

    {

        long long x=vec[vec.size()-1]*vec[vec.size()-2];

        cout << x << endl;



    }

    else{

        cout << 0 << endl;

    }





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

}

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

using namespace std;

int main()

{

    long long n;

    cin>>n;

    vector<long long >v;

    vector<long long >t;

    vector<long long >f;

    set<long long>s;

    set<long long>::iterator it;

    map<long long,long long>m;

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

    {

        long long x;

        cin>>x;

        m[x]+=1;

       s.insert(x);

    }

    long long mx=0;

    for(it=s.begin();it!=s.end();it++)

    {

        if(m[*it]>=2)

        {

            t.push_back(*it);

        }

        if(m[*it]>=4)

        {

            f.push_back(*it);

        }

    }

    if(f.size()!=0)

    {

       mx=max(mx,f[f.size()-1]*f[f.size()-1]);

    }

     if(t.size()>=2)

    {

         mx=max(mx,t[t.size()-1]*t[t.size()-2]);

    }





cout<<mx<<endl;



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

}




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

using namespace std;

int main()

{

    long long n;

    cin>>n;

    vector<long long >v;

    vector<long long >t;

    vector<long long >f;

    set<long long>s;

    set<long long>::iterator it;

    map<long long,long long>m;

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

    {

        long long x;

        cin>>x;

        m[x]+=1;

       s.insert(x);

    }

    long long mx=0;

    for(it=s.begin();it!=s.end();it++)

    {

        if(m[*it]>=2)

        {

            t.push_back(*it);

        }

        if(m[*it]>=4)

        {

            f.push_back(*it);

        }

    }

    if(f.size()!=0)

    {

       mx=max(mx,f[f.size()-1]*f[f.size()-1]);

    }

     if(t.size()>=2)

    {

         mx=max(mx,t[t.size()-1]*t[t.size()-2]);

    }





cout<<mx<<endl;



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

}

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

#define ll long long

#define inf 999999999999

#define F first

#define S second

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

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

#define pi 2*acos(0.0)

#define ee exp(1)

#define mx 200009

using namespace std;

priority_queue<ll>p,q;

map<ll,ll>m;

int main(){//read(x);

fast;

ll a,b,c,d,e,f,g,h,i,j,k,l=0,n,t;

cin>>n;

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

    cin>>a;

    m[a]++;

}

for(auto i:m){

    a=i.F;b=i.S;

    if(b>=4)p.push(a);

    if(b>=2)q.push(a);

}

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

    a=p.top();

    l=max(l,a*a);

}

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

    a=q.top();q.pop();

    b=q.top();q.pop();

    l=max(l,a*b);

}



 cout<<l<<endl;



}