stablegradients/pie-gem5-pairs huggingface dataset:
// 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.8079799036426292x):
#include <bits/stdc++.h>

using namespace std;

priority_queue <int> q;

int i,j,cnt=0;

long long p[2];

int main(){

    long long n,a,b;

    cin>>n;

    while(i!=n){

        cin>>a;

        q.push(a);

        i++;

    }

    i=0;

    cnt = 0;

    while(cnt!=2&&!q.empty()){

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

        b= q.top();

      //  printf("%lld %lld\n",a,b);

        if(a==b){

        	p[cnt]=a;

        	cnt++;

        	q.pop();

        	//printf("%lld %lld\n",p[0],p[1]);

		}

		if(q.size()==1)break;

    }

    //

    if(cnt!=2)printf("0");

    else {

        long long area;

        area = p[0]*p[1];

        printf("%lld",area);

    }

    

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

using namespace std;

priority_queue <int> q;

int i,j,cnt=0;

long long p[2];

int main(){

    long long n,a,b;

    cin>>n;

    while(i!=n){

        cin>>a;

        q.push(a);

        i++;

    }

    i=0;

    cnt = 0;

    while(cnt!=2&&!q.empty()){

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

        b= q.top();

      //  printf("%lld %lld\n",a,b);

        if(a==b){

        	p[cnt]=a;

        	cnt++;

        	q.pop();

        	//printf("%lld %lld\n",p[0],p[1]);

		}

		if(q.size()==1)break;

    }

    //

    if(cnt!=2)printf("0");

    else {

        long long area;

        area = p[0]*p[1];

        printf("%lld",area);

    }

    

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



using namespace std;



map<int,int> m;

int n;

int a, ans1, ans2, cnt;



int main() {

    scanf("%d", &n);

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

        scanf("%d", &t);

        m[t]++;

    }

    for(auto itr = m.rbegin(); itr != m.rend(); itr++) {

            int a = itr -> second;

            if(a <= 1) continue;

            if(a >= 4 && cnt == 0) {

                ans1 = itr -> first;

                ans2 = itr -> first;

                cnt += 2;

            }

            else if(a >= 2 && cnt != 2) {

                if(cnt == 1) ans2 = itr -> first;

                else if (cnt == 0) ans1 = itr -> first;

                cnt++;

            }

            if(cnt == 2) return (!printf("%lld", 1ll * ans1 * ans2));

    }

    printf("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.4438244608037314x):
#include <bits/stdc++.h>



using namespace std;



map<int,int> m;

int n;

int a, ans1, ans2, cnt;



int main() {

    scanf("%d", &n);

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

        scanf("%d", &t);

        m[t]++;

    }

    for(auto itr = m.rbegin(); itr != m.rend(); itr++) {

            int a = itr -> second;

            if(a <= 1) continue;

            if(a >= 4 && cnt == 0) {

                ans1 = itr -> first;

                ans2 = itr -> first;

                cnt += 2;

            }

            else if(a >= 2 && cnt != 2) {

                if(cnt == 1) ans2 = itr -> first;

                else if (cnt == 0) ans1 = itr -> first;

                cnt++;

            }

            if(cnt == 2) return (!printf("%lld", 1ll * ans1 * ans2));

    }

    printf("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.8085159202269123x):
#include<bits/stdc++.h>

using namespace std;

int main()

{

    long long n,i;

    cin>>n;

    long long a[n],c[3],x=0;

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

        cin>>a[i];

    sort(a,a+n);

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

    {

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

        {

            c[x]=a[i];

            --i;

            ++x;

        }

        if(x==2)

        {

            cout<<c[0]*c[1]<<endl;

            return 0;

        }

    }

      cout<<"0"<<endl;

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

using namespace std;

int main()

{

    long long n,i;

    cin>>n;

    long long a[n],c[3],x=0;

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

        cin>>a[i];

    sort(a,a+n);

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

    {

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

        {

            c[x]=a[i];

            --i;

            ++x;

        }

        if(x==2)

        {

            cout<<c[0]*c[1]<<endl;

            return 0;

        }

    }

      cout<<"0"<<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.7893035796279315x):
#include<bits/stdc++.h>

#define int long long

using namespace std;

main(){

int n;

cin>>n;

int A[n];

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

    cin>>A[i];



sort(A , A+n);

vector<int>sides;

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

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

    sides.push_back(A[i]) , i--;



}



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

    cout<<sides[0] * sides[1]<<endl;

}



else

    cout<<0<<endl;

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



using namespace std;



typedef long long LL;



const int MAX_N = 1e5 + 10;



int main()

{

	ios::sync_with_stdio(false);

	cin.tie(nullptr);

	

	int N, cnt[MAX_N] = {};

	LL ans = 0, A[MAX_N];

	vector<LL> vec;

	

	cin >> N;

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

	

	sort(A, A + N);

	cnt[0] = 1;

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

	{

		cnt[i] = A[i] == A[i - 1] ? cnt[i - 1] + 1 : 1;

		

		if (cnt[i] == 2) vec.emplace_back(A[i]);

		else if (cnt[i] == 4) ans = max(ans, A[i] * A[i]);

	}//for i

	

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

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

		

	cout << ans << '\n';

	

	return 0;

}//main

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

#define int long long

using namespace std;

main(){

int n;

cin>>n;

int A[n];

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

    cin>>A[i];



sort(A , A+n);

vector<int>sides;

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

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

    sides.push_back(A[i]) , i--;



}



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

    cout<<sides[0] * sides[1]<<endl;

}



else

    cout<<0<<endl;

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

using namespace std;



#define LL long long

#define LD long double

#define Mod 1000000007

#define L_Mod 17100000013



const double eps = 1e-9;

const int INF = 0x3f3f3f3f;

const double PI = 3.1415926535;



#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);



#define ree(a,n) memset(a,n,si 2)



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

#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))

#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

int main()

{

    LL int i,j,n,m,a[100002]= {0};

    cin>>n;

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

        cin>>a[i];

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

    LL int ma=0,num=0;

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

    {

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

        {

            if(num==0)

                ma=a[i];

            else

                ma*=a[i];

            num++;

            i++;

        }

        if(num>=2)

            break;

    }

    if(num>=2)

        cout<<ma;

    else

        cout<<0;

}


// Faster C++ solution for the same problem (measured speedup: 1.7628139125187454x):
/*بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم*/



#include<bits/stdc++.h>

using namespace std;

const  long long     mx=1e5+100;



#define      mod     1e9+7

#define      pai     acos(-1)

#define      ff      first

#define      ss      second

#define      ll      long long

#define      pb      push_back

#define      mp      make_pair

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

#define      fo      freopen("output.txt","w",stdout);

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



//typedef pair<ll,ll> pi;

//typedef map<ll,ll> mi;





int main()

{

    fast;

    ll i,j,a=-1,b=-1,c,x,y,z,n,m,t;

    cin>>n;

    set<ll>st;

    map<ll,ll>freq;

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

    {

        cin>>m;

        st.insert(m);

        freq[m]++;

    }

    ll area=0;

    vector<ll>vec;

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

    {

        if(freq[*p]>=2)

        {

            vec.pb(*p);

        }

        if(vec.size()==2)

        {

            break;

        }

    }

    if(vec.size()==1)

    {

        a=vec[0];

        x=freq[a];

        if(x>=4)

        {

            area=a*a;

        }

        else

        {

            area=0;

        }

    }

    else if(vec.size()==2)

    {

        a=vec[0];

        b=vec[1];

        x=freq[a];

        y=freq[b];



        if(x>=4)

        {

            area=max(area,(a*a));

        }

        else

        {

            if(x>=2&&y>=2)

            {

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

            }

            else

            {

                area=0;

            }

        }

    }

    else

    {

        area=0;

    }

    cout<<area<<endl;

    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.406762122215046x):
/*بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم*/



#include<bits/stdc++.h>

using namespace std;

const  long long     mx=1e5+100;



#define      mod     1e9+7

#define      pai     acos(-1)

#define      ff      first

#define      ss      second

#define      ll      long long

#define      pb      push_back

#define      mp      make_pair

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

#define      fo      freopen("output.txt","w",stdout);

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



//typedef pair<ll,ll> pi;

//typedef map<ll,ll> mi;





int main()

{

    fast;

    ll i,j,a=-1,b=-1,c,x,y,z,n,m,t;

    cin>>n;

    set<ll>st;

    map<ll,ll>freq;

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

    {

        cin>>m;

        st.insert(m);

        freq[m]++;

    }

    ll area=0;

    vector<ll>vec;

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

    {

        if(freq[*p]>=2)

        {

            vec.pb(*p);

        }

        if(vec.size()==2)

        {

            break;

        }

    }

    if(vec.size()==1)

    {

        a=vec[0];

        x=freq[a];

        if(x>=4)

        {

            area=a*a;

        }

        else

        {

            area=0;

        }

    }

    else if(vec.size()==2)

    {

        a=vec[0];

        b=vec[1];

        x=freq[a];

        y=freq[b];



        if(x>=4)

        {

            area=max(area,(a*a));

        }

        else

        {

            if(x>=2&&y>=2)

            {

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

            }

            else

            {

                area=0;

            }

        }

    }

    else

    {

        area=0;

    }

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

using namespace std;

int b[100000];

int main()

{

    int n;

    cin>>n;

    long long int a[n+5];

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

        {

            cin>>a[i];

        }

    sort(a,a+n);

    int j=0;

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

     {

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

            {

                b[j]=a[i];

                i++;

                j++;

            }

     }

    if(j>=2)

    {

    long long int x=b[j-1],y=b[j-2];

    cout<<x*y<<endl;

    }

    else

    cout<<0<<endl;

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



using namespace std;



typedef long long LL;



const int MAX_N = 1e5 + 10;



int main()

{

	ios::sync_with_stdio(false);

	cin.tie(nullptr);

	

	int N, cnt[MAX_N] = {};

	LL ans = 0, A[MAX_N];

	vector<LL> vec;

	

	cin >> N;

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

	

	sort(A, A + N);

	cnt[0] = 1;

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

	{

		cnt[i] = A[i] == A[i - 1] ? cnt[i - 1] + 1 : 1;

		

		if (cnt[i] == 2) vec.emplace_back(A[i]);

		else if (cnt[i] == 4) ans = max(ans, A[i] * A[i]);

	}//for i

	

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

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

		

	cout << ans << '\n';

	

	return 0;

}//main

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

using namespace std;

int b[100000];

int main()

{

    int n;

    cin>>n;

    long long int a[n+5];

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

        {

            cin>>a[i];

        }

    sort(a,a+n);

    int j=0;

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

     {

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

            {

                b[j]=a[i];

                i++;

                j++;

            }

     }

    if(j>=2)

    {

    long long int x=b[j-1],y=b[j-2];

    cout<<x*y<<endl;

    }

    else

    cout<<0<<endl;

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

using namespace std;



#define LL long long

#define LD long double

#define Mod 1000000007

#define L_Mod 17100000013



const double eps = 1e-9;

const int INF = 0x3f3f3f3f;

const double PI = 3.1415926535;



#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);



#define ree(a,n) memset(a,n,si 2)



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

#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))

#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

int main()

{

    LL int i,j,n,m,a[100002]= {0};

    cin>>n;

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

        cin>>a[i];

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

    LL int ma=0,num=0;

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

    {

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

        {

            if(num==0)

                ma=a[i];

            else

                ma*=a[i];

            num++;

            i++;

        }

        if(num>=2)

            break;

    }

    if(num>=2)

        cout<<ma;

    else

        cout<<0;

}


// Faster C++ solution for the same problem (measured speedup: 1.7868069521845733x):
//BISMILLAHIR RAHMANIR RAHIM

//RHYTHM_086_NS_01

//ALAN_IS_ON....



#include <bits/stdc++.h>



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

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

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

#define     pb                  push_back

#define     mp                  make_pair

#define     itr                 ::iterator

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

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

#define     thank_you           return 0

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



using namespace std;



typedef long long int ll;

typedef double db;

#define MOD 1000000007



ll bigmod(ll a,ll b){

    if(b==0){

        return 1;

    }

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

    tm=(tm*tm)%MOD;

    if(b%2==1)

        tm=(tm*a)%MOD;

    return tm;



}

void solve();





int main()

{

    boost_;

    precise_impact;

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

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

    //Here we go...

    solve();



    thank_you;

}





void solve()

{

    int n;

    cin>>n;

    int a[n];

    iter_(i,n){

        cin>>a[i];

    }

    n_sort(a);

    ll b[2];

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

    int k=0;

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

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

            if(k<2){

                b[k]=a[j];

                //b1[k]=false;

                k++;

            }

            j--;

        }

    }

    if(k!=2){

        cout<<"0"<<endl;

        //cout<<k<<endl;

    }

    else

        cout<<b[0]*b[1]<<endl;



}