from math import gcd

class SEGTree:

    def __init__(self,n):

        self.Unit=0

        i=1

        while(i<n):

            i*=2

        self.SEG=[self.Unit]*(2*i-1)

        self.d=i

    def update(self,i,x):

        i+=self.d-1

        self.SEG[i]=x

        while i>0:

            i=(i-1)//2

            self.SEG[i]=gcd(self.SEG[i*2+1],self.SEG[i*2+2])

    def find(self,a,b,k,l,r):

        if r<=a or b<=l:

            return self.Unit

        if a<=l and r<=b:

            return self.SEG[k]

        else:

            c1=self.find(a,b,2*k+1,l,(l+r)//2)

            c2=self.find(a,b,2*k+2,(l+r)//2,r)

            return gcd(c1,c2)

    def get(self,a,b):

        return self.find(a,b,0,0,self.d)



N=int(eval(input()))

SEG=SEGTree(N)

A=list(map(int,input().split()))

for i in range(N):

    SEG.update(i,A[i])

ans=1

for i in range(N):

    l,r=SEG.get(0,i),SEG.get(i+1,N)

    ans=max(ans,gcd(l,r))

print(ans)
from math import gcd

class SparseTable:

    def __init__(self,arr,N,op,e):

        self.A=arr

        self.N=N

        self.Unit=e

        self.Op=op

        self.K=N.bit_length()-1

        self.pow2=[1]

        for i in range(self.K):

            self.pow2.append(self.pow2[-1]*2)

        self.ST=[[self.Unit]*(self.K+1) for i in range(N)]

        for i in range(N):

            self.ST[i][0]=self.A[i]

        for i in reversed(list(range(N))):

            for k in range(1,self.K+1):

                if self.N<i+self.pow2[k]:

                    break

                self.ST[i][k]=self.Op(self.ST[i][k-1],self.ST[i+self.pow2[k-1]][k-1])

    def get(self,l,r):

        if l==r:

            return self.Unit

        x=r-l

        t=x.bit_length()-1

        return self.Op(self.ST[l][t],self.ST[r-self.pow2[t]][t])



N=int(eval(input()))



A=list(map(int,input().split()))

ST=SparseTable(A,N,gcd,0)

ans=1

for i in range(N):

    l,r=ST.get(0,i),ST.get(i+1,N)

    ans=max(ans,gcd(l,r))

print(ans)
from math import gcd


class SEGTree:
    def __init__(self, n):
        self.Unit = 0
        i = 1
        while i < n:
            i *= 2
        self.SEG = [self.Unit] * (2 * i - 1)
        self.d = i

    def update(self, i, x):
        i += self.d - 1
        self.SEG[i] = x
        while i > 0:
            i = (i - 1) // 2
            self.SEG[i] = gcd(self.SEG[i * 2 + 1], self.SEG[i * 2 + 2])

    def find(self, a, b, k, l, r):
        if r <= a or b <= l:
            return self.Unit
        if a <= l and r <= b:
            return self.SEG[k]
        else:
            c1 = self.find(a, b, 2 * k + 1, l, (l + r) // 2)
            c2 = self.find(a, b, 2 * k + 2, (l + r) // 2, r)
            return gcd(c1, c2)

    def get(self, a, b):
        return self.find(a, b, 0, 0, self.d)


N = int(eval(input()))
SEG = SEGTree(N)
A = list(map(int, input().split()))
for i in range(N):
    SEG.update(i, A[i])
ans = 1
for i in range(N):
    l, r = SEG.get(0, i), SEG.get(i + 1, N)
    ans = max(ans, gcd(l, r))
print(ans)

from math import gcd


class SparseTable:
    def __init__(self, arr, N, op, e):
        self.A = arr
        self.N = N
        self.Unit = e
        self.Op = op
        self.K = N.bit_length() - 1
        self.pow2 = [1]
        for i in range(self.K):
            self.pow2.append(self.pow2[-1] * 2)
        self.ST = [[self.Unit] * (self.K + 1) for i in range(N)]
        for i in range(N):
            self.ST[i][0] = self.A[i]
        for i in reversed(list(range(N))):
            for k in range(1, self.K + 1):
                if self.N < i + self.pow2[k]:
                    break
                self.ST[i][k] = self.Op(
                    self.ST[i][k - 1], self.ST[i + self.pow2[k - 1]][k - 1]
                )

    def get(self, l, r):
        if l == r:
            return self.Unit
        x = r - l
        t = x.bit_length() - 1
        return self.Op(self.ST[l][t], self.ST[r - self.pow2[t]][t])


N = int(eval(input()))
A = list(map(int, input().split()))
ST = SparseTable(A, N, gcd, 0)
ans = 1
for i in range(N):
    l, r = ST.get(0, i), ST.get(i + 1, N)
    ans = max(ans, gcd(l, r))
print(ans)

-class SEGTree: -    def __init__(self, n): -        self.Unit = 0 -        i = 1 -        while i < n: -            i *= 2 -        self.SEG = [self.Unit] * (2 * i - 1) -        self.d = i +class SparseTable: +    def __init__(self, arr, N, op, e): +        self.A = arr +        self.N = N +        self.Unit = e +        self.Op = op +        self.K = N.bit_length() - 1 +        self.pow2 = [1] +        for i in range(self.K): +            self.pow2.append(self.pow2[-1] * 2) +        self.ST = [[self.Unit] * (self.K + 1) for i in range(N)] +        for i in range(N): +            self.ST[i][0] = self.A[i] +        for i in reversed(list(range(N))): +            for k in range(1, self.K + 1): +                if self.N < i + self.pow2[k]: +                    break +                self.ST[i][k] = self.Op( +                    self.ST[i][k - 1], self.ST[i + self.pow2[k - 1]][k - 1] +                ) -    def update(self, i, x): -        i += self.d - 1 -        self.SEG[i] = x -        while i > 0: -            i = (i - 1) // 2 -            self.SEG[i] = gcd(self.SEG[i * 2 + 1], self.SEG[i * 2 + 2]) - -    def find(self, a, b, k, l, r): -        if r <= a or b <= l: +    def get(self, l, r): +        if l == r: -        if a <= l and r <= b: -            return self.SEG[k] -        else: -            c1 = self.find(a, b, 2 * k + 1, l, (l + r) // 2) -            c2 = self.find(a, b, 2 * k + 2, (l + r) // 2, r) -            return gcd(c1, c2) - -    def get(self, a, b): -        return self.find(a, b, 0, 0, self.d) +        x = r - l +        t = x.bit_length() - 1 +        return self.Op(self.ST[l][t], self.ST[r - self.pow2[t]][t]) -SEG = SEGTree(N) -for i in range(N): -    SEG.update(i, A[i]) +ST = SparseTable(A, N, gcd, 0) -    l, r = SEG.get(0, i), SEG.get(i + 1, N) +    l, r = ST.get(0, i), ST.get(i + 1, N)