import copy

class SegmentTree:

    def __init__(self, N, func, I):

        self.sz = N

        self.func = func

        self.I = copy.deepcopy(I)

        self.seg = [copy.deepcopy(I) for i in range(self.sz * 2)]

 

    def assign(self, k, x):

        self.seg[k + self.sz] = copy.deepcopy(x)

 

    def build(self):

        for i in range(self.sz - 1, 0, -1):

            self.seg[i] = self.func(self.seg[2 * i], self.seg[2 * i + 1])

 

    def update(self, k, x):

        k += self.sz

        self.seg[k] = copy.deepcopy(x)

        while k > 1:

            k //= 2

            self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1])

 

    def query(self, a, b):

        L = copy.deepcopy(self.I)

        R = copy.deepcopy(self.I)

        a += self.sz

        b += self.sz

        while a < b:

            if a % 2 == 1:

                L = self.func(L, self.seg[a])

                a += 1

            if b % 2 == 1:

                b -= 1

                R = self.func(self.seg[b], R)

            a //= 2

            b //= 2

        return self.func(L, R)



import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

from fractions import gcd

N = int(readline())

m = list(map(int,read().split()))

seg = SegmentTree(N , gcd , 0)

for i in range(N):

    seg.assign(i , next(m))

seg.build()

ans = 1

for i in range(N):

    ans = max(ans,gcd(seg.query(0,i) , seg.query(i+1,N)))

print(ans)
import copy

class SegmentTree:

    def __init__(self, N, func, I):

        self.sz = N

        self.func = func

        self.I = copy.deepcopy(I)

        self.seg = [copy.deepcopy(I) for i in range(self.sz * 2)]

 

    def assign(self, k, x):

        self.seg[k + self.sz] = copy.deepcopy(x)

 

    def build(self):

        for i in range(self.sz - 1, 0, -1):

            self.seg[i] = self.func(self.seg[2 * i], self.seg[2 * i + 1])

 

    def update(self, k, x):

        k += self.sz

        self.seg[k] = copy.deepcopy(x)

        while k > 1:

            k //= 2

            self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1])

 

    def query(self, a, b):

        L = copy.deepcopy(self.I)

        R = copy.deepcopy(self.I)

        a += self.sz

        b += self.sz

        while a < b:

            if a % 2 == 1:

                L = self.func(L, self.seg[a])

                a += 1

            if b % 2 == 1:

                b -= 1

                R = self.func(self.seg[b], R)

            a //= 2

            b //= 2

        return self.func(L, R)



def main():

    import sys

    read = sys.stdin.buffer.read

    readline = sys.stdin.buffer.readline

    from fractions import gcd

    N = int(readline())

    m = list(map(int,read().split()))

    seg = SegmentTree(N , gcd , 0)

    for i in range(N):

        seg.assign(i , next(m))

    seg.build()

    ans = 1

    for i in range(N):

        ans = max(ans,gcd(seg.query(0,i) , seg.query(i+1,N)))

    print(ans)



main()
import copy


class SegmentTree:
    def __init__(self, N, func, I):
        self.sz = N
        self.func = func
        self.I = copy.deepcopy(I)
        self.seg = [copy.deepcopy(I) for i in range(self.sz * 2)]

    def assign(self, k, x):
        self.seg[k + self.sz] = copy.deepcopy(x)

    def build(self):
        for i in range(self.sz - 1, 0, -1):
            self.seg[i] = self.func(self.seg[2 * i], self.seg[2 * i + 1])

    def update(self, k, x):
        k += self.sz
        self.seg[k] = copy.deepcopy(x)
        while k > 1:
            k //= 2
            self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1])

    def query(self, a, b):
        L = copy.deepcopy(self.I)
        R = copy.deepcopy(self.I)
        a += self.sz
        b += self.sz
        while a < b:
            if a % 2 == 1:
                L = self.func(L, self.seg[a])
                a += 1
            if b % 2 == 1:
                b -= 1
                R = self.func(self.seg[b], R)
            a //= 2
            b //= 2
        return self.func(L, R)


import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
from fractions import gcd

N = int(readline())
m = list(map(int, read().split()))
seg = SegmentTree(N, gcd, 0)
for i in range(N):
    seg.assign(i, next(m))
seg.build()
ans = 1
for i in range(N):
    ans = max(ans, gcd(seg.query(0, i), seg.query(i + 1, N)))
print(ans)

import copy


class SegmentTree:
    def __init__(self, N, func, I):
        self.sz = N
        self.func = func
        self.I = copy.deepcopy(I)
        self.seg = [copy.deepcopy(I) for i in range(self.sz * 2)]

    def assign(self, k, x):
        self.seg[k + self.sz] = copy.deepcopy(x)

    def build(self):
        for i in range(self.sz - 1, 0, -1):
            self.seg[i] = self.func(self.seg[2 * i], self.seg[2 * i + 1])

    def update(self, k, x):
        k += self.sz
        self.seg[k] = copy.deepcopy(x)
        while k > 1:
            k //= 2
            self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1])

    def query(self, a, b):
        L = copy.deepcopy(self.I)
        R = copy.deepcopy(self.I)
        a += self.sz
        b += self.sz
        while a < b:
            if a % 2 == 1:
                L = self.func(L, self.seg[a])
                a += 1
            if b % 2 == 1:
                b -= 1
                R = self.func(self.seg[b], R)
            a //= 2
            b //= 2
        return self.func(L, R)


def main():
    import sys

    read = sys.stdin.buffer.read
    readline = sys.stdin.buffer.readline
    from fractions import gcd

    N = int(readline())
    m = list(map(int, read().split()))
    seg = SegmentTree(N, gcd, 0)
    for i in range(N):
        seg.assign(i, next(m))
    seg.build()
    ans = 1
    for i in range(N):
        ans = max(ans, gcd(seg.query(0, i), seg.query(i + 1, N)))
    print(ans)


main()

-import sys +def main(): +    import sys -read = sys.stdin.buffer.read -readline = sys.stdin.buffer.readline -from fractions import gcd +    read = sys.stdin.buffer.read +    readline = sys.stdin.buffer.readline +    from fractions import gcd -N = int(readline()) -m = list(map(int, read().split())) -seg = SegmentTree(N, gcd, 0) -for i in range(N): -    seg.assign(i, next(m)) -seg.build() -ans = 1 -for i in range(N): -    ans = max(ans, gcd(seg.query(0, i), seg.query(i + 1, N))) -print(ans) +    N = int(readline()) +    m = list(map(int, read().split())) +    seg = SegmentTree(N, gcd, 0) +    for i in range(N): +        seg.assign(i, next(m)) +    seg.build() +    ans = 1 +    for i in range(N): +        ans = max(ans, gcd(seg.query(0, i), seg.query(i + 1, N))) +    print(ans) + + +main()