object Main {
    def main(args: Array[String]) = {
        val sc = new java.util.Scanner(System.in)
        val n  = sc.nextInt
        val ls = List.fill(n)(sc.nextInt).sorted.reverse
        println(calc(ls))
    }
    def calc(ls: List[Int]) : Int = {
        val tmplist = ls.filter(x => ls.count(_ == x) > 1).sorted.reverse.distinct
        if (tmplist.length > 1) tmplist(0) * tmplist(1) else 0
    }
}