fun main(args: Array<String>) {
    val N = readInputLine().toInt()
    val As = readInputLine().split(" ").map { it.toLong() }.toLongArray()
    
    As.sortDescending()
    
    var longer = 0L
    var shorter = 0L
    
    var now = As[0]
    var index = 1
    
    while (index < N) {
        if (As[index] == now) {
            if (longer == 0L) {
                longer = now
                index++
            } else {
                shorter = now
                break
            }
        }
        if (index < N) {
            now = As[index]
            index++
        }
    }

    println(longer * shorter)
}

fun readInputLine(): String {
    return readLine()!!
}

