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

object Main extends App {
  val in = new BufferedReader(new InputStreamReader(System.in))
  val map = mutable.HashMap[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 ite = map.filter(e => e._2 > 3).keys
  val keys1 = if(ite.isEmpty) 0 else ite.max
  val keys2 = map.filter(e => e._2 > 1).keys.toVector.sorted
    .takeRight(2)
  val res1 = keys1 * keys1
  val res2 = if(keys2.size != 2) 0 else keys2.head * keys2.last

  val ans = math.max(res1,res2)
  println(ans)
}