import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val N = sc.nextInt
  val A = (0 until N).map(_ => sc.nextInt)
  val dup = A.groupBy(identity).toSeq.filter(_._2.size >= 2).map(_._1).sorted(Ordering[Int].reverse)
  println((dup ++ Seq(0, 0)).take(2).reduce(_ * _))
}