import java.math.BigDecimal

fun main(args: Array<String>) {
    val n = readLine()!!

    println(
            readLine()!!.split(Regex("\\s+")).map { it.toInt() }
                    .groupBy { it }
                    .mapValues { it.value.size }
                    .filterValues { it >= 2 }
                    .toList().sortedByDescending { it.first }
                    .let { l ->
                        val p1 = l.getOrElse(0, { i -> 0 to 0 })
                        val p2 = l.getOrElse(1, { i -> 0 to 0 })

                        val e1 = BigDecimal(p1.first)
                        val e2 = BigDecimal(p2.first)
                        
                        e1 * (if (p1.second >= 4) e1 else e2)
                    }
    )
}
