require 'prime'
N = gets.to_i
a_list = gets.split.map(&:to_i)

forward_gcd_list = []
prev_gcd = nil
a_list.each do |a|
  gcd = if prev_gcd == nil
    a
  else
    prev_gcd.gcd(a)
  end
  forward_gcd_list.push(gcd)
  prev_gcd = gcd
end
backward_gcd_list = []
prev_gcd = nil
a_list.reverse.each do |a|
  gcd = if prev_gcd == nil
    a
  else
    prev_gcd.gcd(a)
  end
  backward_gcd_list.unshift(gcd)
  prev_gcd = gcd
end

ans = -1
(0...N).each do |i|
  front_gcd = i >= 1 ? forward_gcd_list[i - 1] : nil
  back_gcd = i < N - 1 ? backward_gcd_list[i + 1] : nil
  if front_gcd == nil
    ans = back_gcd if back_gcd > ans
  elsif back_gcd == nil
    ans = front_gcd if front_gcd > ans
  else
    gcd = front_gcd.gcd(back_gcd)
    ans = gcd if gcd > ans
  end
end
puts ans
