n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)

def gcd(lhs, rhs)
  l = [lhs, rhs].max
  s = [lhs, rhs].min
  r = l % s
  return s if r.zero?
  gcd(s, r)
end

def mgcd(ary)
  v = ary.first
  1.upto(ary.length - 1) do |i|
    v = gcd(v, ary[i])
  end
  v
end

def solve(ary)
  result = []
  v = ary.first
  1.upto(ary.length - 1) do |i|
    ks = gcd(v, ary[i])
    result << { idx: i, ks: ks }
    v = ks
  end
  result.sort_by! { |r| [r[:ks], r[:idx]] }
  i = result.first[:idx]
  a1 = ary.dup
  a1[i - 1] = a1[i]
  a2 = ary.dup
  a2[i] = a2[i - 1]
  [mgcd(a1), mgcd(a2)].max
end

puts solve(a.sort.reverse)
