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 Fortran (GNU Fortran 9.2.1) (judge verdict: Accepted)

program rec
	implicit none
    integer :: n, i,j,c1,c2
    integer(8),allocatable :: a(:)
    integer(8) :: l1, l2, s1, s2
    logical :: status
    read(*,*) n
    allocate(a(n))
    read(*,*) a
    call heapsort(a)
	
    s1 = 0
    s2 = 0
    c1 = n
    do i = n - 1, 1, -1
    	l1 = a(i)
        l2 = a(i+1)
    	if(l1 == l2) then
        	s1 = l1
        	c1 = i
        	exit
        else
        	l1 = a(i)
            l2 = a(i-1)
        end if
    end do
    do i = c1 - 2, 1, -1
    	l1 = a(i)
        l2 = a(i+1)
    	if(l1 == l2) then
        	s2 = l1
        	c1 = i
        	exit
        else
        	l1 = a(i)
            l2 = a(i-1)
        end if
    end do
    	
    write(*,*) s1*s2

	stop
contains
	subroutine heapsort(array)
    implicit none
    integer(8):: array(:)
    integer ::i,k,j,l
    integer(8) :: t

    n=size(array)

    if (n==1) then
       return
    end if
    
    l=n/2+1
    k=n
    do while(k.ne.1)
       if(l.gt.1)then
          l=l-1
          t=array(L)
       else
          t=array(k)
          array(k)=array(1)
          k=k-1
          if(k == 1) then
             array(1)=t
             exit
          endif
       endif
       i=l
       j=l+l
       do while(j.le.k)
          if(j.lt.k)then
             if(array(j).lt.array(j+1))j=j+1
          endif
          if (t.lt.array(j))then
             array(i)=array(j)
             i=j
             j=j+j
          else
             j=k+1
          endif
       end do
       array(i)=t
    end do
    return
  end subroutine heapsort

end program rec