require 'prime'

$n = gets.to_i
arr = gets[0..-2].split.map &:to_i

def share(a, b)
  b.each do |prime, count|
    if a[prime].nil?
      next
    else
      a[prime] = [a[prime], count].min
    end
  end

  (a.keys-b.keys).each do |prime|
    a.delete prime
  end
  a
end
def calc(arr)
  result = []
  $n.times do |i|
    if i == 0
      result << Prime.prime_division(arr[i]).to_h
      next
    end

    v = result[i-1].dup
    d = Prime.prime_division(arr[i]).to_h
    result << share(v,d)
  end
  result
end
larr = calc(arr)
rarr = calc(arr.reverse).reverse

def value(v)
  r = 1
  v.each do |prime, count|
    r *= prime ** count
  end
  return r
end

max = 0
$n.times do |i|
  if i == 0
    max = value rarr[1]
    next
  end

  if i == $n-1
    max = [max, value(larr[-2])].max
    next
  end

  v = value(share(larr[i-1], rarr[i+1]))
  max = [max, v].max
end
puts max
