fun main(args: Array<String>) {
    val n = readLine()?: return
    val aList = readLine()
        ?.split(" ")
        ?.map { it.toLong() }
        ?.groupBy { it }
        ?.mapValues { it.value.size }
        ?.filter { it.value >= 2 }
        ?.toList()
        ?.sortedByDescending { it.first }
        ?.take(2)
        ?: listOf()

    if (aList.isEmpty() || aList.map { it.second }.sum() < 4) {
        println(0)
        return
    }

    if (aList[0].second >= 4) {
        println(aList[0].first * aList[0].first)
        return
    }

    println(aList[0].first * aList[1].first)
}