object Main extends App {
	import scala.io.StdIn._
	import scala.math._

	def sort(x: List[Long]): List[Long] = {
		x match {
			case Nil => List[Long]()
			case r::Nil => List(r)
			case r::rest =>{
				val temp = rest.toArray
				var right = List(r)
				var left = List[Long]()

				for(i<-0 until rest.size){
					if(temp(i) > r) right = temp(i)::right
					else left = temp(i)::left
				}

				sort(left):::sort(right)
			}
		}
	}
	
	val N = readInt
	val A = readLine.split(" ").map(_.toLong).toList

	val AA = sort(A).reverse

	println(AA.mkString(" "))

	var result = new Array[Long](5)
	var j = 0

	for(i <- AA){
		result(j) = i
		j match {
			case 0 => j = j + 1
			case 1 if(result(0) != result(1)) => result(0) = i
			case 1 if(result(0) == result(1)) => j = j + 1
			case 2 => j = j + 1
			case 3 if(result(0) != result(1)) => result(2) = i
			case 3 if(result(0) == result(1)) => j = j + 1
			case _ => 
		}
	}

	println(result.mkString(" "))
	println(min(result(0),result(1)) * min(result(2),result(3)))
}
