import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = (0 until n).map { sc.next().toLong() }
    answer071cAlt(n, a)
}

fun answer071cAlt(n: Int, a: List<Long>) {
    val reversedA: MutableList<Long> = a.sortedDescending() as MutableList<Long>

    val set: MutableList<Long> = mutableListOf<Long>()
    var count = 0
    var firstFlg = false
    for (index: Int in reversedA.indices) {
        if (index == 0) {
            continue
        }
        if (reversedA[index] == reversedA[index - 1] && !firstFlg) {
                count += 1
                set.add(reversedA[index])
                firstFlg = true


            if (count == 2) {
                break
            }
        }else {
            firstFlg = false
        }
    }
    if (set.isEmpty()) {
        println(0)
    } else  {
        println(set[0] * set[1])
    }
}