program main
  implicit none

  integer :: n, i, cnt
  integer(16) :: ans
  integer(16), allocatable :: a(:)

  read(*,*) n
  allocate(a(n))
  
  ans = 0
  cnt = 0
  read(*,*) a
  call quicksort(a, 1, n)
  do i = n, 2, -1
     if(a(i) == a(i-1)) then
        ans = a(i)
        cnt = i
        exit
     end if
  end do

  do i = cnt-2, 2, -1
     if(a(i) == a(i-1)) then
        ans = ans * a(i)
        exit
     end if
     if(i == 2) then
        ans = 0
     end if
     
  end do

  write(*,*) ans

  stop
  
contains
  recursive subroutine quicksort(a, first, last)
    implicit none
    integer(16) ::  a(*)
    integer :: first, last
    integer :: i, j
    integer ::  x, t
    
    x = a( (first+last) / 2 )
    i = first
    j = last
    do
       do while (a(i) < x)
          i=i+1
       end do
       do while (x < a(j))
          j=j-1
       end do
       if (i >= j) exit
       t = a(i);  a(i) = a(j);  a(j) = t
       i=i+1
       j=j-1
    end do
    if (first < i - 1) call quicksort(a, first, i - 1)
    if (j + 1 < last)  call quicksort(a, j + 1, last)
  end subroutine quicksort

end program main

  
