Problem:
Score : 300 points

Problem Statement

We have N sticks with negligible thickness.
The length of the i-th stick is A_i.

Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides.
Find the maximum possible area of the rectangle.

Constraints

4 \leq N \leq 10^5

1 \leq A_i \leq 10^9

A_i is an integer.

Input

Input is given from Standard Input in the following format:

N
A_1 A_2 ... A_N

Output

Print the maximum possible area of the rectangle.
If no rectangle can be formed, print 0.

Sample Input 1

6
3 1 2 4 2 1

Sample Output 1

2

1 \times 2 rectangle can be formed.

Sample Input 2

4
1 2 3 4

Sample Output 2

0

No rectangle can be formed.

Sample Input 3

10
3 3 3 3 4 4 4 5 5 5

Sample Output 3

20

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstdlib>
using namespace std;
int main(){
	long int n,a[100000],some[100000],count=0,t,ans=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		some[i]=0;
	}
	sort(a,a+n);
	for(int i=n-1;0<=i;i--){
		if(a[i]*a[i-2]==a[i-1]*a[i-3] && a[i]==a[i-1] && a[i-2]==a[i-3]){
			ans=a[i-1]*a[i-2];
			count++;
			break;
		}
		else if(a[i]*a[i-3]==a[i-1]*a[i-4] && a[i]==a[i-1] && a[i-3]==a[i-4]){
			ans=a[i-1]*a[i-3];
			count++;
			break;
		}
		else if(a[i]*a[i-4]==a[i-1]*a[i-5] && a[i]==a[i-1] && a[i-4]==a[i-5]){
			ans=a[i-1]*a[i-4];
			count++;
			break;
		}
		else if(a[i]*a[i-5]==a[i-1]*a[i-6] && a[i]==a[i-1] && a[i-5]==a[i-6]){
			ans=a[i-1]*a[i-5];
			count++;
			break;
		}
		else if(a[i]*a[i-6]==a[i-1]*a[i-7] && a[i]==a[i-1] && a[i-6]==a[i-7]){
			ans=a[i-1]*a[i-6];
			count++;
			break;
		}
		else if(a[i]*a[i-7]==a[i-1]*a[i-8] && a[i]==a[i-1] && a[i-7]==a[i-8]){
			ans=a[i-1]*a[i-7];
			count++;
			break;
		}
		else if(a[i]*a[i-8]==a[i-1]*a[i-9] && a[i]==a[i-1] && a[i-8]==a[i-9]){
			ans=a[i-1]*a[i-8];
			count++;
			break;
		}
		else if(a[i]*a[i-9]==a[i-1]*a[i-10] && a[i]==a[i-1] && a[i-9]==a[i-10]){
			ans=a[i-1]*a[i-9];
			count++;
			break;
		}
		else if(a[i]*a[i-10]==a[i-1]*a[i-11] && a[i]==a[i-1] && a[i-10]==a[i-11]){
			ans=a[i-1]*a[i-10];
			count++;
			break;
		}
		else if(a[i]*a[i-11]==a[i-1]*a[i-12] && a[i]==a[i-1] && a[i-11]==a[i-12]){
			ans=a[i-1]*a[i-11];
			count++;
			break;
		}
		else if(a[i]*a[i-12]==a[i-1]*a[i-13] && a[i]==a[i-1] && a[i-12]==a[i-13]){
			ans=a[i-1]*a[i-12];
			count++;
			break;
		}
		else if(a[i]*a[i-13]==a[i-1]*a[i-14] && a[i]==a[i-1] && a[i-13]==a[i-14]){
			ans=a[i-1]*a[i-13];
			count++;
			break;
		}
		else if(a[i]*a[i-14]==a[i-1]*a[i-15] && a[i]==a[i-1] && a[i-14]==a[i-15]){
			ans=a[i-1]*a[i-14];
			count++;
			break;
		}
		else if(a[i]*a[i-15]==a[i-1]*a[i-16] && a[i]==a[i-1] && a[i-15]==a[i-16]){
			ans=a[i-1]*a[i-15];
			count++;
			break;
		}
		else if(a[i]*a[i-16]==a[i-1]*a[i-17] && a[i]==a[i-1] && a[i-16]==a[i-17]){
			ans=a[i-1]*a[i-16];
			count++;
			break;
		}
		else if(a[i]*a[i-17]==a[i-1]*a[i-18] && a[i]==a[i-1] && a[i-17]==a[i-18]){
			ans=a[i-1]*a[i-17];
			count++;
			break;
		}
		else if(a[i]*a[i-18]==a[i-1]*a[i-19] && a[i]==a[i-1] && a[i-18]==a[i-19]){
			ans=a[i-1]*a[i-18];
			count++;
			break;
		}
		else if(a[i]*a[i-19]==a[i-1]*a[i-20] && a[i]==a[i-1] && a[i-19]==a[i-20]){
			ans=a[i-1]*a[i-19];
			count++;
			break;
		}
		else if(a[i]*a[i-20]==a[i-1]*a[i-21] && a[i]==a[i-1] && a[i-20]==a[i-21]){
			ans=a[i-1]*a[i-20];
			count++;
			break;
		}
		else if(a[i]*a[i-21]==a[i-1]*a[i-22] && a[i]==a[i-1] && a[i-21]==a[i-22]){
			ans=a[i-1]*a[i-21];
			count++;
			break;
		}
	}
	cout<<ans<<endl;
	return 0;
}