fun main(args: Array<String>) {
    val n= readLine()!!.toInt()
    val a= readLine()!!.split(" ").map{it.toLong()}
            .groupBy { it }.mapValues { it.value.size }
            .filterValues { it>=2 }
            .toList().sortedByDescending { it.first }

    val h=a.getOrElse(0){0L to 0}
    val w= if(h.second>=4) h
    else a.getOrElse(1){0L to 0}
            
    println(h.first * w.first)
}