fun main(arg: Array<String>) {
    val N = nextInt()
    val A = listOfLong()
    val M = mutableMapOf<Long, Int>()
    A.sortedDescending().forEach { a ->
        M[a] = M.getOrElse(a, { 0 }) + 1
    }
    val F = M.filter { it.value >= 2 }.toList()
    val ans = when (F.size) {
        0 -> 0L
        1 -> if (F[0].second >= 4) F[0].first * F[0].first else 0L
        else -> F[0].first * F[if (F[0].second >= 4) 0 else 1].first
    }
    println(ans)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfLong() = listOfString().map { java.lang.Long.parseLong(it) }
