import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val n  = sc.nextInt
  val al = Vector.fill(n)(sc.nextInt)

  val cnt   = al.zipWithIndex.groupBy(_._1)
  

  val cnt2  = cnt.filter(_._2.size >= 2)
  val cnt4  = cnt2.filter(_._2.size >= 4)
  val over2 = cnt2.keySet.toVector
  val over4 = cnt4.keySet.toVector

  val bl = (over2 ++ over4).sortWith(_ > _)

  val res =
    if(bl.length <= 1) 0L
    else bl.head.toLong * bl.tail.head.toLong

  println(res)
}