from fractions import gcd

inpl = lambda: list(map(int,input().split()))



class SegAccumCalc:

    def __init__(self, value, N=0, calc=lambda x,y: x+y):

        M = max(len(value),N)

        N = 2**(len(bin(M))-3)

        if N < M: N *= 2

        self.N = N

        self.node = [None] * (2*N-1)

        for i, v in enumerate(value):

            self.node[i+N-1] = v

        self.calc = lambda x, y: x if y is None else y if x is None else calc(x,y)

        for i in range(N-2,-1,-1):

            left, right = self.node[2*i+1], self.node[2*i+2]

            self.node[i] = self.calc(left, right)



    def set_value(self, n, v):

        i = (self.N-1) + n

        self.node[i] = v

        while i > 0:

            i = (i-1)//2

            left, right = self.node[2*i+1], self.node[2*i+2]

            new = self.calc(left,right)

            if self.node[i] == new:

                break

            else:

                self.node[i] = new



    def get(self,

            a=0, b=-1,

            k=0, l=0, r=-1):

        if b < 0:

            b = self.N

        if r < 0:

            r = self.N

        if a <= l and r <= b:

            return self.node[k]

        elif r <= a or b <= l:

            return None

        else:

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

            right = self.get(a,b,2*k+2,(l+r)//2,r)

            return self.calc(left,right)



N = int(eval(input()))

A = inpl()

sac = SegAccumCalc(A,calc=gcd)

ans = 0

for i in range(N):

    if i == 0:

        c = sac.get(1,N)

    elif i == N-1:

        c = sac.get(0,N-1)

    else:

        c = gcd(sac.get(0,i),sac.get(i+1,N))

    if c > ans:

        ans = c

print(ans)
from fractions import gcd

inpl = lambda: list(map(int,input().split()))



class SegAccumCalc:

    def __init__(self, value, N=0, calc=lambda x,y: x+y):

        M = max(len(value),N)

        N = 2**(len(bin(M))-3)

        if N < M: N *= 2

        self.N = N

        self.node = [None] * (2*N-1)

        for i, v in enumerate(value):

            self.node[i+N-1] = v

        self.calc = lambda x, y: x if y is None else y if x is None else calc(x,y)

        for i in range(N-2,-1,-1):

            left, right = self.node[2*i+1], self.node[2*i+2]

            self.node[i] = self.calc(left, right)



    def set_input(self, n, v):

        i = (self.N-1) + n

        self.node[i] = v

        while i > 0:

            i = (i-1)//2

            left, right = self.node[2*i+1], self.node[2*i+2]

            new = self.calc(left,right)

            if self.node[i] == new:

                break

            else:

                self.node[i] = new

    

    def get_input(self, n):

        return self.node[(self.N-1)+n]



    def get_output(self,

                   a=0, b=-1,

                   k=0, l=0, r=-1):

        if b < 0:

            b = self.N

        if r < 0:

            r = self.N

        if a <= l and r <= b:

            return self.node[k]

        elif r <= a or b <= l:

            return None

        else:

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

            right = self.get_output(a,b,2*k+2,(l+r)//2,r)

            return self.calc(left,right)



N = int(eval(input()))

A = inpl()

sac = SegAccumCalc(A,calc=gcd)

ans = 0

for i in range(N):

    sac.set_input(i,0)

    g = sac.get_output()

    if g > ans:

        ans = g

    sac.set_input(i,A[i])

print(ans)
from fractions import gcd

inpl = lambda: list(map(int, input().split()))


class SegAccumCalc:
    def __init__(self, value, N=0, calc=lambda x, y: x + y):
        M = max(len(value), N)
        N = 2 ** (len(bin(M)) - 3)
        if N < M:
            N *= 2
        self.N = N
        self.node = [None] * (2 * N - 1)
        for i, v in enumerate(value):
            self.node[i + N - 1] = v
        self.calc = lambda x, y: x if y is None else y if x is None else calc(x, y)
        for i in range(N - 2, -1, -1):
            left, right = self.node[2 * i + 1], self.node[2 * i + 2]
            self.node[i] = self.calc(left, right)

    def set_value(self, n, v):
        i = (self.N - 1) + n
        self.node[i] = v
        while i > 0:
            i = (i - 1) // 2
            left, right = self.node[2 * i + 1], self.node[2 * i + 2]
            new = self.calc(left, right)
            if self.node[i] == new:
                break
            else:
                self.node[i] = new

    def get(self, a=0, b=-1, k=0, l=0, r=-1):
        if b < 0:
            b = self.N
        if r < 0:
            r = self.N
        if a <= l and r <= b:
            return self.node[k]
        elif r <= a or b <= l:
            return None
        else:
            left = self.get(a, b, 2 * k + 1, l, (l + r) // 2)
            right = self.get(a, b, 2 * k + 2, (l + r) // 2, r)
            return self.calc(left, right)


N = int(eval(input()))
A = inpl()
sac = SegAccumCalc(A, calc=gcd)
ans = 0
for i in range(N):
    if i == 0:
        c = sac.get(1, N)
    elif i == N - 1:
        c = sac.get(0, N - 1)
    else:
        c = gcd(sac.get(0, i), sac.get(i + 1, N))
    if c > ans:
        ans = c
print(ans)

from fractions import gcd

inpl = lambda: list(map(int, input().split()))


class SegAccumCalc:
    def __init__(self, value, N=0, calc=lambda x, y: x + y):
        M = max(len(value), N)
        N = 2 ** (len(bin(M)) - 3)
        if N < M:
            N *= 2
        self.N = N
        self.node = [None] * (2 * N - 1)
        for i, v in enumerate(value):
            self.node[i + N - 1] = v
        self.calc = lambda x, y: x if y is None else y if x is None else calc(x, y)
        for i in range(N - 2, -1, -1):
            left, right = self.node[2 * i + 1], self.node[2 * i + 2]
            self.node[i] = self.calc(left, right)

    def set_input(self, n, v):
        i = (self.N - 1) + n
        self.node[i] = v
        while i > 0:
            i = (i - 1) // 2
            left, right = self.node[2 * i + 1], self.node[2 * i + 2]
            new = self.calc(left, right)
            if self.node[i] == new:
                break
            else:
                self.node[i] = new

    def get_input(self, n):
        return self.node[(self.N - 1) + n]

    def get_output(self, a=0, b=-1, k=0, l=0, r=-1):
        if b < 0:
            b = self.N
        if r < 0:
            r = self.N
        if a <= l and r <= b:
            return self.node[k]
        elif r <= a or b <= l:
            return None
        else:
            left = self.get_output(a, b, 2 * k + 1, l, (l + r) // 2)
            right = self.get_output(a, b, 2 * k + 2, (l + r) // 2, r)
            return self.calc(left, right)


N = int(eval(input()))
A = inpl()
sac = SegAccumCalc(A, calc=gcd)
ans = 0
for i in range(N):
    sac.set_input(i, 0)
    g = sac.get_output()
    if g > ans:
        ans = g
    sac.set_input(i, A[i])
print(ans)

-    def set_value(self, n, v): +    def set_input(self, n, v): -    def get(self, a=0, b=-1, k=0, l=0, r=-1): +    def get_input(self, n): +        return self.node[(self.N - 1) + n] + +    def get_output(self, a=0, b=-1, k=0, l=0, r=-1): -            left = self.get(a, b, 2 * k + 1, l, (l + r) // 2) -            right = self.get(a, b, 2 * k + 2, (l + r) // 2, r) +            left = self.get_output(a, b, 2 * k + 1, l, (l + r) // 2) +            right = self.get_output(a, b, 2 * k + 2, (l + r) // 2, r) -    if i == 0: -        c = sac.get(1, N) -    elif i == N - 1: -        c = sac.get(0, N - 1) -    else: -        c = gcd(sac.get(0, i), sac.get(i + 1, N)) -    if c > ans: -        ans = c +    sac.set_input(i, 0) +    g = sac.get_output() +    if g > ans: +        ans = g +    sac.set_input(i, A[i])