object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val a = List.fill(n)(sc.nextLong())
  val d = a.groupBy(identity).filter(_._2.length >= 2).keys.toList.sorted.reverse
  if (d.length >= 2) {
    println(d.take(2).product)
  } else {
    println(0)
  }
}
