import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter

fun solve() {
    val n = inf.readLine()!!.toInt()
    val a = inf.readLine()!!.split(' ').map(String::toLong)
            .groupBy { it }.map { it.key to it.value.size }.filter { it.second > 1 }.sortedBy { -it.first }
    println(if (a.isNotEmpty() && a[0].second >= 4) a[0].first * a[0].first else if (a.size > 1) a[0].first * a[1].first else 0L)
}

fun main(args: Array<String>) {
    solve()
    ouf.close()
}

val inf = BufferedReader(InputStreamReader(System.`in`))
val ouf = PrintWriter(System.out)