class SegmentTree

  @@inf = 2**31-1
  
  # O(n)
  def initialize(size_or_ary=[], form: :min)
    
    @identity_element =  @@inf
    @identity_element = -@@inf if form == :max
    @identity_element = 0 if form == :gcd
    # p "form!!!!!!!" if form == :gcd
    
    case size_or_ary
    when Integer
      n = size_or_ary
      @origial_size = size_or_ary
      @n = 1
      @n *= 2 while @n < n
      # @n: leaf node size(2^k)
      # @n*2-1: tree node size
      # p ["n", @n]
      @nodes = Array.new(@n*2-1, @identity_element)
    # when Array
      # ary = size_or_ary
      # n = ary.size
      # @n = ary.size
      # @n *= 2 while @n < n
      # @nodes = ary.concat( [@identity_element] * (@n - ary.size))
    else
      raise
    end
  end

  def update(i, val)
    
    return update_gcd(i, val) if @form == :gcd
    
    # @n-1: inner node size
    i += @n - 1
    @nodes[i] = val
    while i > 0
      i = ( i - 1 ) / 2
      @nodes[i] = [@nodes[2*i+1], @nodes[2*i+2]].min
    end
  end
  
  def update_min(i, val)
    # @n-1: inner node size
    i += @n - 1
    @nodes[i] = val
    while i > 0
      i = ( i - 1 ) / 2
      @nodes[i] = [@nodes[2*i+1], @nodes[2*i+2]].min
    end
  end
  
  def update_gcd(i, val)
    # @n-1: inner node size
    i += @n - 1
    @nodes[i] = val
    while i > 0
      i = ( i - 1 ) / 2
      @nodes[i] = @nodes[2*i+1].gcd @nodes[2*i+2]
    end
  end

  def get_min(a, b, k=0, l=0, r=-1)

    r = @n if r < 0
    return @identity_element if (r <= a || b <= l)
    return @nodes[k] if (a <= l && r <= b)

    vl = get_min(a, b, k*2+1, l, (l+r)/2)
    vr = get_min(a, b, k*2+2, (l+r)/2,r)
    return vl <= vr ? vl : vr
  end
  
  # def get_gcd(a, b, k=0, l=0, r=-1)
    # r = @n if r < 0
    # return @identity_element if (r <= a || b <= l)
    # # p [@nodes[k]] if (a <= l && r <= b)
    # return @nodes[k] if (a <= l && r <= b)
    # # p [a, b, k, l, r]

    # vl = get_gcd(a, b, k*2+1, l, (l+r)/2)
    # vr = get_gcd(a, b, k*2+2, (l+r)/2,r)
    # # p [vl, vr]
    # return vl.gcd vr
  # end
  
  def get_gcd(l, r) 
    # p @n
    l += @n - 1
    r += @n - 1
    # p [l, r, @identity_element]
    lres, rres = @identity_element, @identity_element
    # p ["aaa", lres]
    while l < r
      if l[0] == 0
        lres = lres.gcd @nodes[l]
        l += 1
      end
      if r[0] == 0
        r -= 1
        # p ["r", r]
        rres = (@nodes[r]).gcd rres
      end
      l /= 2
      r /= 2
    end
    return lres.gcd(rres)
  end

  def inf=(x)
    @@inf = x
  end

  def inf()
    @@inf
  end

  def inspect

    t = 0
    res = "SegmentTree\n  "
    @nodes.each_with_index do |e,i|

      res << e.to_s << " "
      if t == i && i < @n-1
        res << "\n  "
        t = t * 2 + 2
      end
    end
    res
  end
end

class Array
  def to_st( form = :min )
    st = SegmentTree.new(size, form: form)
    each_with_index{ |t, i| st.update_gcd(i, t) }
    st
  end
end

# p 5.integer?
# p [4, 4, 3].concat( [0] * 5 )

n = gets.to_s.to_i
a = gets.to_s.split.map{|t| t.to_i }

st = a.to_st(:gcd)
# p st
# p st.get_gcd(1, n-1)
# p st.get_gcd(2, 3)
# p st.get_gcd(0, 2)
# p st.get_gcd(0, n-2)
# p "bfetrha"
# p n
# p st.get_gcd(1, n)
# p "fgshf"
# p st.get_gcd(0, n-1)
ans = [st.get_gcd(1, n), st.get_gcd(0, n-1)].max
# p ans
# p "aaaaa"
1.upto(n-2) do |i|
  # p "aaaaa"
  v = st.get_gcd(0, i).gcd st.get_gcd(i+1, n) 
  ans = v if ans < v
end

puts ans

Measured memory_bytes: 10652