import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val a = (1..n).map { sc.nextLong() }


  val map = mutableMapOf<Long, Int>()
  for (ai in a) {
    val tmp = map.getOrElse(ai) { 0 }
    map.put(ai, tmp+1)
  }

  val mm = map.filter { it.value >= 2 }.keys.sorted().reversed()
  if (mm.size == 0) {
    println(0)
    return
  }

  val mk = mm[0]
  val mv = map.getOrElse(mk) { 0 }
  if (mv >= 4) {
    println(mk * mk)
    return
  }

  if (mm.size == 1) {
    println(0)
    return
  }

  val mkk = mm[1]
  println(mk * mkk)

}