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

using namespace std;



int main(){

	long long n, in;

	map<long long, long long> cnt;

	vector<long long> edge;

	cin >> n;

	

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

		cin >> in;

		cnt[in]++;

		if(cnt[in] == 2){

			edge.push_back(in);

			cnt[in] = 0;

		}

	}

	

	sort(edge.begin(), edge.end(), greater<long long>());

	

	if(edge.size() < 2) cout << "0" << endl;

	else cout << (long long)edge[0]*edge[1] << endl;

	

	return 0;

}


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

#define Y second

#define pb push_back

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

#define rep(i,a,b) for(int i=a;i<=b;i++)

#define mm(x,n) memset(x,n,sizeof(x))

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

using namespace std;

typedef long long ll;

typedef vector<int> vi;

typedef pair<int,int> pii;

//const int maxn =



int main(){

	int n;

	cin>>n;

	map<ll,int> cnt;

	rep(i,1,n){

		int tmp;

		cin >> tmp;

		cnt[tmp]++;

	}

	vector<ll> v;

	for(auto i : cnt)

		if(i.Y >= 2){

			rep(j,1,(i.Y/2))

				v.pb(i.X);

		}

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

		sort(ALL(v));

		unsigned long long ans = (v[v.size()-1]*v[v.size()-2]);

		cout<<ans;

	}

	else cout<<"0";

}


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

#include <queue>

#include <algorithm>

#include <string.h>

#include <iostream>

#define ll long long

using namespace std;

int main()

{

    int n;

    scanf("%d",&n);

    int a[100005],b[2];

    int f=0;

    b[0]=0;

    b[1]=0;

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

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

    sort(a,a+n);

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

    {

        if(f<2)

        {

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

            {

                b[f]=a[i];

                f++;

                i-=2;

            }

            else

                i--;

        }

        else

            break;

    }

    ll s;

    s=(ll)b[0]*b[1];

    printf("%lld",s);

    return 0;

}

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

#include<algorithm>

#include<iostream>

#define ll long long

using namespace std;

ll a[1000005],b[10];

int main()

{

    int n,l = 1;

    scanf("%d",&n);

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

    {

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

    }

    sort(a,a+n);

    b[0] = -1;

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

    {

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

        {

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

            i--;

        }

        if(l==3)

            break;

    }

    if(l==3)

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

    else

        printf("0\n");

    return 0;

}





/*

8

1 1 2 2 3 3 3 3

5

1 2 3 3 3

*/


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



int compare_int(const void *a, const void *b)

{

    return *(int*)a - *(int*)b;

}



int main(){

  int N;

  int A[100000] = {0};

  //int min, temp;

  long long len1 = 0;

  long long len2 = 0;



  std::cin >> N;

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

    std::cin >> A[i];



  /*

  // 昇順ソート

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

    min = i;

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

      if(A[min] > A[j]) min = j;

      temp = A[i];

      A[i] = A[min];

      A[min] = temp;

    }

  }

  */

  qsort(A, N, sizeof(int), compare_int);



  // 大きい方からペアを探す

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

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

      if(len1 == 0) len1 = A[i];

      else if(len2 == 0) len2 = A[i];

      i--;

    }

    if(len2 != 0) break;

  }



  std::cout << len1 * len2;



  return 0;

}


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

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



using namespace std;



typedef long long ll;

typedef vector<int> vi;



int main(void)

{

        int n;

        int a[100010];

        cin >> n;

        REP(i,n) cin >> a[i];



        sort(a, a+n);



        int temp = 0;

        ll longest = 0;

        ll second = 0;

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

                if(temp == a[i]){

                        if(!longest){

                                longest = a[i];

                                temp = 0;

                                continue;

                        }else if(!second){

                                second = a[i];

                                break;

                        }

                }

                temp = a[i];

        }



        cout << longest * second << 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.7695465650554338x):
#include<bits/stdc++.h>

using namespace std;



#define ll long long

#define ull long long unsigned

#define vii vector<int>

#define pii pair<int,int>

#define pll pair<long long,long long>

#define pdd pair<double,double>

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

#define ff first

#define ss second

#define pb push_back

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

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

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

#define PI 2*acos(0.0)



const int MAX=100005, MOD=1000000007;

const ll inf=1e9;



int arr[MAX];

vector<ll>v;

map<ll,int>cnt;

int main(){



    fastio;

    int n;

    cin>>n;

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

        ll val;

        cin>>val;

        if(!cnt[val]){

            v.pb(val);

        }

        cnt[val]++;

    }

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

    ll a=0,b=0;

    ll ans=0;

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

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

    }

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

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

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

    }

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

    cout<<ans<<"\n";





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

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



using namespace std;



int main(){

    long m1=0,m2=0,temp,n,i,j;

    cin>>n;

    long a[n];

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

        cin>>a[i];

        

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

    

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

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

            m1=a[i];

            break;

        }

    }

    for(j=i+2;j<n-1;j++){

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

            m2=a[j];

            break;

        }

    }

    cout<<m1*m2;

    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.7647397780874379x):
#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';

    }

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

#include<algorithm>

#include<string>

#include<cmath>

#include<set>

#include<cstdio>

#include<ctime>

#include<vector>



#define endl '\n'

#define ll long long

#define ull unsigned ll

#define x first

#define y second



using namespace std;



multiset<long long>a;



int main(){

    int n;

    cin>>n;

    int temp;

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

        cin>>temp;

        a.insert(temp);

    }

    multiset<long long>::iterator i=a.end();

    i--;

    long long q=0,w=0;

    int c;

    while(1){

        c=a.count(*i);

        if(c>=2){

            if(q==0)q=*i;

            else {

                w=*i;

                break;

            }

            c=2;

            while(c-- && i!=a.begin())i--;



        }

        if(i==a.begin())break;

        i--;

    }

    cout<<q*w<<endl;

    return 0;

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

using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

const int INF = 1e9;

const ll LINF = 1e18;



/*

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

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

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

 

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

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

 

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



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



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

*/

int main(void) {

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

    ll N; cin >> N;

    map<ll,ll> mp;

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

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

    }

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

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

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

    

    ll h = 0,w = 0;

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

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

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

            else w = ps[i].first;

            break;

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

            if(h == 0){

                h = ps[i].first;

                continue;

            }

            if(w == 0){

                w = ps[i].first;

                break;

            }

        }

    }

    cout << h * w << endl;

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.1041998247809237x):
#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.9496121625590606x):
#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 ull long long unsigned

#define vii vector<int>

#define pii pair<int,int>

#define pll pair<long long,long long>

#define pdd pair<double,double>

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

#define ff first

#define ss second

#define pb push_back

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

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

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

#define PI 2*acos(0.0)



const int MAX=100005, MOD=1000000007;

const ll inf=1e9;



int arr[MAX];

vector<ll>v;

map<ll,int>cnt;

int main(){



    fastio;

    int n;

    cin>>n;

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

        ll val;

        cin>>val;

        if(!cnt[val]){

            v.pb(val);

        }

        cnt[val]++;

    }

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

    ll a=0,b=0;

    ll ans=0;

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

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

    }

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

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

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

    }

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

    cout<<ans<<"\n";





}




















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

}