from fractions import*

def update(k,x):

    k+=N0-1

    data[k]=x

    while k+1:

        k=~-k//2

        data[k]=gcd(data[2*k+1],data[2*k+2])

def query(l,r):

    L,R=l+N0,r+N0

    s=0

    while L<R:

        if R&1:

            R-=1

            s=gcd(s,data[R-1])

        if L&1:

            s=gcd(s,data[L-1])

            L+=1

        L>>=1

        R>>=1

    return s

n,*a=list(map(int,open(0).read().split()))

N0=2**(n-1).bit_length()

data=[0]*2*N0

for i in range(n):

    update(i,a[i])

print((max(gcd(query(0,i),query(i+1,n))for i in range(n))))
from fractions import*

n,*a=list(map(int,open(0).read().split()))

b=a[:]

for i in range(1,n):

    a[i]=gcd(a[i],a[i-1])

    b[n-i-1]=gcd(b[n-i-1],b[n-i])

a=[0]+a

b+=0,

print((max(gcd(a[i],b[i+1])for i in range(n))))
from fractions import *


def update(k, x):
    k += N0 - 1
    data[k] = x
    while k + 1:
        k = ~-k // 2
        data[k] = gcd(data[2 * k + 1], data[2 * k + 2])


def query(l, r):
    L, R = l + N0, r + N0
    s = 0
    while L < R:
        if R & 1:
            R -= 1
            s = gcd(s, data[R - 1])
        if L & 1:
            s = gcd(s, data[L - 1])
            L += 1
        L >>= 1
        R >>= 1
    return s


n, *a = list(map(int, open(0).read().split()))
N0 = 2 ** (n - 1).bit_length()
data = [0] * 2 * N0
for i in range(n):
    update(i, a[i])
print((max(gcd(query(0, i), query(i + 1, n)) for i in range(n))))

from fractions import *

n, *a = list(map(int, open(0).read().split()))
b = a[:]
for i in range(1, n):
    a[i] = gcd(a[i], a[i - 1])
    b[n - i - 1] = gcd(b[n - i - 1], b[n - i])
a = [0] + a
b += (0,)
print((max(gcd(a[i], b[i + 1]) for i in range(n))))

- -def update(k, x): -    k += N0 - 1 -    data[k] = x -    while k + 1: -        k = ~-k // 2 -        data[k] = gcd(data[2 * k + 1], data[2 * k + 2]) - - -def query(l, r): -    L, R = l + N0, r + N0 -    s = 0 -    while L < R: -        if R & 1: -            R -= 1 -            s = gcd(s, data[R - 1]) -        if L & 1: -            s = gcd(s, data[L - 1]) -            L += 1 -        L >>= 1 -        R >>= 1 -    return s - - -N0 = 2 ** (n - 1).bit_length() -data = [0] * 2 * N0 -for i in range(n): -    update(i, a[i]) -print((max(gcd(query(0, i), query(i + 1, n)) for i in range(n)))) +b = a[:] +for i in range(1, n): +    a[i] = gcd(a[i], a[i - 1]) +    b[n - i - 1] = gcd(b[n - i - 1], b[n - i]) +a = [0] + a +b += (0,) +print((max(gcd(a[i], b[i + 1]) for i in range(n))))