import scala.io.StdIn

object Main extends App {

  val n = StdIn.readLine().toInt
  val a = StdIn.readLine().split(" ")
  val r = a.foldLeft(Map.empty[Int, Int]) { (acc, s) =>
    val key = s.toInt
    if (acc.contains(key)) acc.updated(key, acc(key) + 1)
    else acc + (key -> 1)
  }

  val tar = r.filter(p => 2 <= p._2)
  val keys = tar.keys.toList.sortBy(e => -1 * e)
  val ans = if (tar.isEmpty) {
    0
  }else if (tar.getOrElse(keys.head, 0) >= 4) {
    keys.head * keys.head
  }
  else if (tar.getOrElse(keys.head, 0) >= 2 &&
    tar.getOrElse(keys.tail.head, 0) >= 2) {
    keys.head * keys.tail.head
  } else {
    0
  }
  println (ans)
}
