stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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]);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
    #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;

    }

// Optimized solution to the same problem (faster):
#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]);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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]);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

    

}


// Optimized solution to the same problem (faster):
#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]);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

    }

}


// Optimized solution to the same problem (faster):
#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]);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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]);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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]);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
/*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;

}

// Optimized solution to the same problem (faster):
#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]);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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]);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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]);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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]);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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";

}


// Optimized solution to the same problem (faster):
#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]);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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]);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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

*/


// Optimized solution to the same problem (faster):
#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]);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem: