require 'prime'

class Array
  def to_hash
    result_map = Hash.new
    each do |e|
      result_map[e[0]] = e[1]
    end
    result_map
  end
end

class Hash
  def max_divisor(ary_hash)
    result = Hash.new
    each_pair do |k, v|
      result[k] = [v, ary_hash[k]].min unless ary_hash[k].nil?
    end
    result
  end

  def get_max_divisor
    result = 1
    each_pair do |k,v|
      result *= (k**v)
    end
    result
  end
end

def max(ary)
  hash_ary = ary.map{|i| Prime.prime_division(i).to_hash}

  left_hash_ary = []
  hash_ary.each do |h|
    left_hash_ary << (left_hash_ary.empty? ? h : left_hash_ary.last.max_divisor(h))
  end
  right_hash_ary = []
  hash_ary.reverse_each do |h|
    right_hash_ary << (right_hash_ary.empty? ? h : right_hash_ary.last.max_divisor(h))
  end
  right_hash_ary.reverse!

  result = 1
  (0..ary.size - 1).each do |idx|
    result_tmp = case idx
                 when 0 then right_hash_ary[idx + 1]
                 when (ary.size - 1) then left_hash_ary[idx - 1]
                 else left_hash_ary[idx - 1].max_divisor(right_hash_ary[idx + 1])
                 end.get_max_divisor
    result = result_tmp if result_tmp > result
  end

  result
end

gets
ary = gets.split.map(&:to_i)
puts max(ary)
