import java.util.*
object MainKt {
  @JvmStatic fun main(args:Array<String>) {
    val N=readLine()!!.toInt()
    val A=readLine()!!.split(" ").map(String::toLong)
    assert(A.size==N)
    var dictionary:HashMap<Long,Int> =HashMap()
    A.distinct().forEach {dictionary.put(it,0)}
    var candicate:MutableList<Long> = mutableListOf()
    for(a in A) {
      dictionary.put(a,dictionary.get(a)!! + 1)
      if (dictionary.get(a)!! %2==0) {
        candicate.add(a)
      }
    }
    // println(A.filter{a-> A.indexOfFirst {v->v==a}!=A.indexOfLast{v->v==a}}.distinct().sortedDescending().let{ if(it.size<2) {0} else {it[0]*it[1]} })
      println(candicate.sortedDescending().let{ when(it.size) {
        0 -> 0
        1 -> it[0]*it[0]
        else -> it[0]*it[1]
      } })
  }
}
