
import java.util.Scanner

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

  val n = sc.nextInt()

  val seq = Range(0, n).map(_ => sc.nextInt())
    .groupBy(i => i)
    .toStream
    .sortWith((t1, t2) => t1._1 > t2._1)
    .filter(t => t._2.size > 1)
    .toSeq

  if (seq.size == 1) {
    println(if (seq(0)._2.size > 3) seq(0)._1 * seq(0)._1 else 0)
  }else if (seq.size > 1) {
    println(if (seq(0)._2.size > 3) seq(0)._1 * seq(0)._1 else seq(0)._1 * seq(1)._1)
  } else {
    println(0)
  }
}
