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).collect{ case (k, v) =>
    List.fill(v.length / 2)(k)
  }.flatten.toList.sorted.reverse

  if (d.length >= 2) {
    println(d.take(2).product)
  } else {
    println(0)
  }
}
