stablegradients/pie-gem5-pairs huggingface dataset:
// 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.4647406010459876x):
/*

--------------              |   /

      |                     |  /

      |                     | /

      |             *       |/          |    |         ------            *

      |                     |           |    |        /      \

      |             |       |\          |    |       |       |\          |

   \  |             |       | \         |    |       |       | \         |

    \ |             |       |  \        |    |        \     /   \        |

     V              |       |   \        \__/|         -----     \       |

*/

#include <bits/stdc++.h>

using namespace std;



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

#define endl '\n'

#define mem(i,j) memset(i,j,sizeof i);

#define F first

#define S second

#define pb push_back

#define mp make_pair

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

#define bit(s,i) (((s)>>(i))&1LL)

#define lowbit(x) (x&-x)

#define siz(v) (long long)v.size()

typedef long long ll;

typedef unsigned long long ull;

typedef pair<int,int> pii;

typedef pair<ll, ll> pll;

const double EPS  = 1e-8;

const int INF     = 0x3F3F3F3F;

const ll LINF     = 4611686018427387903;

const int MOD     = 1e9+7;

const int MAXN    = 2e5+9;

/*-----------------------------------------------------------------------------------------------------*/



int main() {

    EmiliaMyWife



    int n, a;

    cin >> n;

    vector<int> can;

    map<int, int> now;

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

        cin >> a;

        now[a]++;

        if(now[a]>1) {

            can.pb(a);

            now[a]=0;

        }

    }

    if(can.size()>1) {

        sort(all(can), greater<int>());

        cout << 1LL*can[0]*can[1];

    }

    else cout << 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.7618333001481603x):
#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;

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

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

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

using namespace std;



int main(){

//	IOS;

	int n,inp;

	cin >> n;

	map<int,int> num;

	vector<int> can;

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

		cin >> inp;

		num[inp]++;

		if(num[inp]%2==0) can.push_back(inp);

	}

	sort(can.begin(),can.end(),greater<int>());

	if(can.size()<2) cout << "0\n";

	else cout << (long long int)can[0]*can[1] << '\n';

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

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

using namespace std;



int main(){

//	IOS;

	int n,inp;

	cin >> n;

	map<int,int> num;

	vector<int> can;

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

		cin >> inp;

		num[inp]++;

		if(num[inp]%2==0) can.push_back(inp);

	}

	sort(can.begin(),can.end(),greater<int>());

	if(can.size()<2) cout << "0\n";

	else cout << (long long int)can[0]*can[1] << '\n';

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

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

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

using namespace std;

int main()

{

    int n;

    scanf("%d",&n);

    long long a[n+10];

    int i,j;

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

    {

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

    }

    sort(a,a+n);

    vector<long long>rect;

    vector<long long>square;

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

    {

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

        {

            rect.push_back(a[i]);

        }

    }

    int rects=rect.size();

    for(i=2;i<rects;i++)

    {

        if(rect[i]==rect[i-1]&&rect[i]==rect[i-2])

        {

            square.push_back(rect[i]);

        }

    }

    int sq=square.size();

    long long ans1=0,ans2=0;

    if(sq>=1)

    {

        ans1=square[sq-1]*square[sq-1];

    }

    if(rects>=2)

    {

        int x=0;

        for(i=rects-2;i>=0;i--)

        {

            if(rect[i]!=rect[rects-1])

            {

                x=1;

                break;

            }

        }

        if(x==1)

        {

            ans2=rect[rects-1]*rect[i];

        }

    }

    if(ans1>ans2)

    {

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

    }

    else

    {

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

    }

    return 0;



}


// Faster C++ solution for the same problem (measured speedup: 5.184499135747743x):
//h

#include<stdio.h>

#include<algorithm>

typedef long long ll;



int n;

ll a[100005];



bool cmp(const ll &a, const ll &b)

{

	return a>b;

}



int main()

{

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

	int i;

	ll l=0ll, w=0ll;

	scanf("%d", &n);

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

	{

		scanf("%lld", a+i);

	}

	std::sort(a, a+n, cmp);

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

	{

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

		{

			l=a[i];

			break;

		}

	}

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

	{

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

		{

			w=a[i];

			break;

		}

	}

	printf("%lld\n", l*w);

	return 0;

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

using namespace std;







int main()



{

    long long int x=0,y=0,a;

    int n,i;

    scanf("%d",&n);

    long long int ara[n];

    for(i=0;i<n;i++) scanf("%lld",&ara[i]);



    sort(ara,ara+n);



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

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

            x=ara[i];

            break;

        }

    }

    i=i-2;

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

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

            y=ara[i];

            break;

        }

    }

    if(x==0||y==0){

        printf("0");

        return 0;

    }

    else{

        a=x*y;

        printf("%lld",a);

    }







}


// Faster C++ solution for the same problem (measured speedup: 5.127941543884558x):
//h

#include<stdio.h>

#include<algorithm>

typedef long long ll;



int n;

ll a[100005];



bool cmp(const ll &a, const ll &b)

{

	return a>b;

}



int main()

{

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

	int i;

	ll l=0ll, w=0ll;

	scanf("%d", &n);

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

	{

		scanf("%lld", a+i);

	}

	std::sort(a, a+n, cmp);

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

	{

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

		{

			l=a[i];

			break;

		}

	}

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

	{

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

		{

			w=a[i];

			break;

		}

	}

	printf("%lld\n", l*w);

	return 0;

}
// Slower C++ solution:


#include<bits/stdc++.h>

using namespace std;



long long ar[100060];



int main()

{



    int n,j,i,cnt=0;

    long long area=1;



    scanf("%d",&n);



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

    {

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

    }



    sort(ar,ar+n);



    j=n-1;



    while(cnt<2 && j>0)

    {

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

        {

            cnt++;

            area*=ar[j];

            j-=2;

        }



        else j--;

    }



    if(cnt<2)

    {

        printf("0");

    }



    else(printf("%lld",area));



    return 0;



}


// Faster C++ solution for the same problem (measured speedup: 5.127971247011095x):
//h

#include<stdio.h>

#include<algorithm>

typedef long long ll;



int n;

ll a[100005];



bool cmp(const ll &a, const ll &b)

{

	return a>b;

}



int main()

{

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

	int i;

	ll l=0ll, w=0ll;

	scanf("%d", &n);

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

	{

		scanf("%lld", a+i);

	}

	std::sort(a, a+n, cmp);

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

	{

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

		{

			l=a[i];

			break;

		}

	}

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

	{

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

		{

			w=a[i];

			break;

		}

	}

	printf("%lld\n", l*w);

	return 0;

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

#include<cstdio>

#include <cstring>

#include <iomanip>

#include <queue>

#include <map>



using namespace std;



map <int,int> ans;



int main(){

    priority_queue<int> res;

    int n;

    scanf("%d",&n);

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

        int k;

        scanf("%d",&k);

        ans[k]++;

        if (ans[k] == 2){

            res.push(k);

        }

        else if(ans[k] == 4){

            res.push(k);

        }

    }

    long long result = 1;

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

        if (res.empty()){

            printf("0\n");

            return 0;

        }

        else{

            result = result*res.top();

            res.pop();

        }

    }

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

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.19383971954329x):
//h

#include<stdio.h>

#include<algorithm>

typedef long long ll;



int n;

ll a[100005];



bool cmp(const ll &a, const ll &b)

{

	return a>b;

}



int main()

{

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

	int i;

	ll l=0ll, w=0ll;

	scanf("%d", &n);

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

	{

		scanf("%lld", a+i);

	}

	std::sort(a, a+n, cmp);

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

	{

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

		{

			l=a[i];

			break;

		}

	}

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

	{

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

		{

			w=a[i];

			break;

		}

	}

	printf("%lld\n", l*w);

	return 0;

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

#include <algorithm>

using namespace std;

const int maxn = 1e6+5;

long long arr[maxn];

bool com(int a,int b){

    return a>b;

}

int main(){

    int a,b,c,i,n;

    cin>>n;

    long long s;

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

        cin>>arr[i];

    }

    sort(arr,arr+n,com);

    int j=-1,k=-1;

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

        if(j!=-1&&arr[i]==arr[i+1]){

            k = i;

        }

        if(arr[i]==arr[i+1]&&k==-1){

            j = i;

            i++;

        }

        if(j!=-1&&k!=-1){

            break;

        }

    }

    if(j==-1||k==-1){

        cout<<0;

    }

    else{

        s = arr[j]*arr[k];

        cout<<s;

    }

}


// Faster C++ solution for the same problem (measured speedup: 5.197698664574914x):
//h

#include<stdio.h>

#include<algorithm>

typedef long long ll;



int n;

ll a[100005];



bool cmp(const ll &a, const ll &b)

{

	return a>b;

}



int main()

{

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

	int i;

	ll l=0ll, w=0ll;

	scanf("%d", &n);

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

	{

		scanf("%lld", a+i);

	}

	std::sort(a, a+n, cmp);

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

	{

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

		{

			l=a[i];

			break;

		}

	}

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

	{

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

		{

			w=a[i];

			break;

		}

	}

	printf("%lld\n", l*w);

	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: 9.396869574356613x):
//h

#include<stdio.h>

#include<algorithm>

typedef long long ll;



int n;

ll a[100005];



bool cmp(const ll &a, const ll &b)

{

	return a>b;

}



int main()

{

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

	int i;

	ll l=0ll, w=0ll;

	scanf("%d", &n);

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

	{

		scanf("%lld", a+i);

	}

	std::sort(a, a+n, cmp);

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

	{

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

		{

			l=a[i];

			break;

		}

	}

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

	{

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

		{

			w=a[i];

			break;

		}

	}

	printf("%lld\n", l*w);

	return 0;

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

using namespace std;



int main()

{

	int n;

	cin>>n;

	map<int,int> hm;

	vector<int> ans;

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

	{

		int a;

		cin>>a;

		hm[a]++;

		if(hm[a]==2)

		{

			ans.push_back(a);

			hm[a] = 0;

		}

	}

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

	if(ans.size()<2) cout<<0;

	else

		cout<<1LL*ans[ans.size()-1]*ans[ans.size()-2];

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.253596384946782x):
//h

#include<stdio.h>

#include<algorithm>

typedef long long ll;



int n;

ll a[100005];



bool cmp(const ll &a, const ll &b)

{

	return a>b;

}



int main()

{

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

	int i;

	ll l=0ll, w=0ll;

	scanf("%d", &n);

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

	{

		scanf("%lld", a+i);

	}

	std::sort(a, a+n, cmp);

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

	{

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

		{

			l=a[i];

			break;

		}

	}

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

	{

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

		{

			w=a[i];

			break;

		}

	}

	printf("%lld\n", l*w);

	return 0;

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

#include <cmath>

#include <stdio.h>

#include <algorithm>

#include <string>

#include <vector>

#include <queue>

#include <deque>

#include <stack>

#include <map>

#include <set>

#include <cstring>



using namespace std;



#define f first

#define s second

#define pb push_back

#define mp make_pair

#define ll long long

#define pii pair < int, int >

#define pll pair < long long, long long>

#define ull unsigned long long

#define vi vector < int >

#define vll vector < long long >

#define sz(a) (int)a.size()

#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)

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

#define sqr(x) ((x) * (x))

#define fname "searching"



const int inf = (int)1e9;

const ll INF = (ll)1e18;

const double eps = 1e-9;

const double pi = acos(-1.0);

const int mod = (int)1e9 + 7;



int n;

ll a[100100];



ll solve(){

    cin >> n;

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

    sort(a, a + n);

    

    ll x = 0, cx = 0;

    ll y = 0, cy = 0;

    ll cnt = 2;

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

        if(a[i] == x) cx++;

        else if(a[i] == y) cy++;



        if(cx >= 2 * cnt) return x * x;

        if(cx >= cnt && cy >= cnt){

            return x * y;

        }

        

        if(a[i] != x && cx < cnt){

            x = a[i];

            cx = 1;

        }else if(a[i] != y && cy < cnt){

            y = a[i];

            cy = 1;

        }

    }

    return 0;

}



int main(){

    ios_base::sync_with_stdio(0);

    cin.tie(0);



    cout << solve() << "\n";

    

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.273980823740032x):
//h

#include<stdio.h>

#include<algorithm>

typedef long long ll;



int n;

ll a[100005];



bool cmp(const ll &a, const ll &b)

{

	return a>b;

}



int main()

{

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

	int i;

	ll l=0ll, w=0ll;

	scanf("%d", &n);

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

	{

		scanf("%lld", a+i);

	}

	std::sort(a, a+n, cmp);

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

	{

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

		{

			l=a[i];

			break;

		}

	}

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

	{

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

		{

			w=a[i];

			break;

		}

	}

	printf("%lld\n", l*w);

	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: 18.416633026026023x):
//h

#include<stdio.h>

#include<algorithm>

typedef long long ll;



int n;

ll a[100005];



bool cmp(const ll &a, const ll &b)

{

	return a>b;

}



int main()

{

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

	int i;

	ll l=0ll, w=0ll;

	scanf("%d", &n);

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

	{

		scanf("%lld", a+i);

	}

	std::sort(a, a+n, cmp);

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

	{

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

		{

			l=a[i];

			break;

		}

	}

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

	{

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

		{

			w=a[i];

			break;

		}

	}

	printf("%lld\n", l*w);

	return 0;

}