import scala.collection.mutable
import java.io.{BufferedReader, InputStreamReader}

object Main extends App {
  val in = new BufferedReader(new InputStreamReader(System.in))
  val map = mutable.TreeMap[Int,Int]()

  val n = in.readLine.toInt
  in.readLine.split(" ").map(_.toInt)
    .foreach(e => {
      if(!map.contains(e)) map += e -> 1
      else map(e) +=1
    })

  val a = map.filter(e => e._2 > 1)
    .takeRight(2)
  // println(a)
  val ans = if(a.size != 2) 0 else a.head._1 * a.last._1
  println(ans)
}