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 (GCC 5.4.1) (judge verdict: Runtime Error)



#pragma warning(disable:4996)
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX_STRING 2200000 
#define MAXCARDS 100000

double alCards[MAXCARDS];
char sInput[MAX_STRING];

int main() {

	char* psInput;
	long long l=0;
	long long lTemp2=0;
/*	double  lLoopEnd=0.0;
	double  lTemp=0.0;
	double  lAllSum=0.0;
	double  lLeftSum=0.0;
	double  lRightSum=0.0;
	double  lTempMin=0.0;
	double  lMin=0.0; */
	long long  lCardsNumber =0;
	long long  lMax = 0;
	long long  lTop = 0;
	long long  lSecond = 0;
	long long  lTarget=0;
	long long  lFound=0;

	// read line 1
	gets(sInput);
	lCardsNumber = atol(sInput);
	//format
	for (l=0;l<lCardsNumber;l++){
		 alCards[l]=0.0;
	}
	// read line 2
	gets(sInput);
	psInput = strtok(sInput," ");
	for (l=0;l<lCardsNumber;l++){
		lTemp2=atol(psInput);
		alCards[lTemp2]=alCards[lTemp2]+1;
		if (lMax<lTemp2){
			lMax=lTemp2;
		}
		psInput = strtok(NULL," ");
	}

	for (lTarget=lMax;lTarget>0;lTarget--){
		if(alCards[lTarget]>=2){
			if(lTop==0){
				lTop=lTarget;
			} else {
				lSecond=lTarget;
				lTarget=0;
				break;
			}
		}
	}

	printf("%ld\n",lTop*lSecond);

    return 0;
}