import scala.io.StdIn

object Main extends App {

  val n = StdIn.readLine().toInt
  val a = StdIn.readLine().split(" ")
  val singles = scala.collection.mutable.Set.empty[String]
  val r = a.foldLeft(Set.empty[String]) { (acc, s) =>
    if (singles.contains(s)) {
      acc + s
    } else {
      singles += s
      acc
    }
  }

  val l = r.toList.distinct.map(_.toInt).sortBy(e => -1 * e)
  val s = l match {
    case h :: w :: _ => h * w
    case hw :: Nil => hw * hw
    case _ => 0
  }
  println(s)
}