fun main(args: Array<String>) {
    abc071c()
}

private data class SizeValue(val size: Int, val value: Long)

fun abc071c() {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(" ").map { it.toLong() }

    val grouped = aList.groupBy { it }.map { SizeValue(it.value.size, it.value.first()) }
        .sortedByDescending { it.value }

    var firstBar: Long? = null

    grouped.forEach {
        if (it.size >= 4) {
            return println(firstBar?.let { fb -> fb * it.value } ?: it.value * it.value)
        } else if (it.size >= 2) {
            firstBar?.let { fb -> return println(fb * it.value) }
            firstBar = it.value
        }
    }

    return println(0)
}
