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

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

    val grouped = aList.groupBy { it }.values.sortedByDescending { it.first() }

    val bars = mutableListOf<Long>()

    grouped.forEach {
        if (it.size >= 4) {
            return println(if (bars.isEmpty()) it.first() * it.first() else bars.first() * it.first())
        } else if (it.size >= 2) {
            bars.addAll(it.take(2))
            if (bars.size >= 4) {
                return println(bars.first() * bars.last())
            }
        }
    }

    return println(0)
}
