import scala.util.control.Breaks

object Main {
  def main(args: Array[String]): Unit = {
    val lines = io.Source.stdin.getLines().toSeq
    println(solve(lines))
  }

  def solve(lines: Seq[String]): String = {
    val n = lines.head.toInt
    val values = lines(1).split(" ").take(n).map(_.toLong)

    if (values.min == values.max) {
      values.max.toString
    } else {
      var divisersList = Vector[Vector[Long]]()
      for (i <- values.indices) {
        val d = divisors(values(i))
        divisersList = d +: divisersList
      }
      val reversed = divisersList.flatten.distinct.sorted.reverse
      var result = 0L
      val b = new Breaks
      b.breakable {
        reversed.foreach { v =>
          if (divisersList.count(_.contains(v)) >= n - 1) {
            result = v
            b.break()
          }
        }
      }
      result.toString
    }
  }

  def divisors(n: Long): Vector[Long] =
    (for (i <- 1L to n if n % i == 0) yield i).toVector
}
