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: Wrong Answer)

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

int alNumber[MAXCARDS];
int alTimes[MAXCARDS];
char sInput[MAX_STRING];

int main() {

	char* psInput;
	long long l=0;
	int i=0;
	int j=0;
	int lTemp2=0;
	int lKinds=0;
	int  lCardsNumber =0;
	int  lMax = 0;
	int  lTop = 0;
	int  lSecond = 0;
	int  lSquare = 0;
	int  lTarget=0;
	int  lFound=0;
	int  lAnswer=0;
	int  lTimes=0;
	int  lNumber=0;

	// read line 1
	gets(sInput);
	lCardsNumber = atol(sInput);
	//format
	for (i=0;i<lCardsNumber;i++){
//		alNumber[i]=0;
		alTimes[i]=0;
	}
	// read line 2
	gets(sInput);
	psInput = strtok(sInput," ");
	for (i=0;i<lCardsNumber;i++){
		lTemp2=atol(psInput);
		lFound=0;
		for (j=0;j<lKinds;j++){
			if(alNumber[j]==lTemp2){
				alTimes[j]=alTimes[j]+1;
				lFound=1;
			}
		}
		if (lFound==0){
			alNumber[lKinds]=lTemp2;
			alTimes[lKinds]=alTimes[lKinds]+1;
			lKinds++;
		}
/*		if (lMax<lTemp2){
			lMax=lTemp2;
		}*/
		if (i<lCardsNumber){
			psInput = strtok(NULL," ");
		}
	}

	for (i=0;i<lKinds;i++){
		lTimes=alTimes[i];
		lNumber=alNumber[i];
		if(lTimes>=4){
			if(lNumber>lSquare){
				lSquare = lNumber;
			}
		}
		if(lTimes>=2){
			if(lNumber>lTop){
				lSecond = lTop;
				lTop = lNumber;
			} else if (lNumber>lSecond){
				lSecond = lNumber;
			}
		}
	}
	/*
	for (lTarget=lMax;lTarget>0;lTarget--){
		lTimes=0;
		for(j=0;j<lKinds;j++){
			if(alNumber[j]==lTarget){
				lTimes=alTimes[j];
			}
		}

		if(lTimes>=4&&lSquare==0){
			lSquare=lTarget;
		} 
		if(lTimes>=2){
			if(lTop==0){
				lTop=lTarget;
			} else if (lSecond==0) {
				lSecond=lTarget;
			}
		}
		if(lTarget+10<lSecond||lTarget+10<lSquare){
			break;
		}
	}*/
	lAnswer=lTop*lSecond;
	if (lAnswer<lSquare*lSquare){
			lAnswer=lSquare*lSquare;
	}
	printf("%ld\n",lAnswer);

    return 0;
}