#!/usr/bin/env python3

import sys

from fractions import gcd

input = sys.stdin.readline





class RgcdQ:

    def __init__(self, a):

        self.n = len(a)

        self.size = 2**(self.n - 1).bit_length()

        self.data = [0] * (2*self.size-1)

        self.initialize(a)



    # Initialize data

    def initialize(self, a):

        for i in range(self.n):

            self.data[self.size + i - 1] = a[i]

        for i in range(self.size-2, -1, -1):

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



    # Update ak as x

    def update(self, k, x):

        k += self.size - 1

        self.data[k] = x

        while k > 0:

            k = (k - 1) // 2

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



    # gcd value in [l, r)

    def query(self, l, r):

        L = l + self.size; R = r + self.size

        s = 0

        while L < R:

            if R & 1:

                R -= 1

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

            if L & 1:

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

                L += 1

            L >>= 1; R >>= 1

        return s

 

if __name__ == "__main__":

    n = int(eval(input()))

    a = [int(item) for item in input().split()]

    ST = RgcdQ(a)

    ans = 0

    for i in range(0, n):

        ans = max(ans, gcd(ST.query(0, i), ST.query(i+1, n)))

    print(ans)
#!/usr/bin/env python3

import sys

from fractions import gcd

input = sys.stdin.readline



class DisjointSparseTable:

    def __init__(self, a):

        # Identity element

        self.e = 0

        self.level = (len(a) - 1).bit_length()

        self.size = 2**self.level

        self.table = [[self.e] * self.size for _ in range(self.level)]

        # Set bottom first

        for i, item in enumerate(a):

            self.table[-1][i] = item

        self.build()



    def build(self):

        for i in range(1, self.level):

            step = 2**i

            lv = self.level - 1 - i

            for mid in range(step, self.size, step*2):

                # Forward

                val = self.e 

                for j in range(step):

                    val = gcd(self.table[-1][mid + j], val)

                    self.table[lv][mid + j] = val

                # Backward

                val = self.e

                for j in range(step):

                    val = gcd(self.table[-1][mid - 1 - j], val)

                    self.table[lv][mid - 1 - j] = val



    # Returns f[l:r)

    def query(self, l, r):

        if l == r:

            return self.e

        elif l == r - 1:

            return self.table[-1][l]

        lv = self.level - (l ^ r-1).bit_length()

        return gcd(self.table[lv][l], self.table[lv][r-1])



 

if __name__ == "__main__":

    n = int(eval(input()))

    a = [int(item) for item in input().split()]

    DST = DisjointSparseTable(a)

    ans = 0

    for i in range(0, n):

        ans = max(ans, gcd(DST.query(0, i), DST.query(i+1, n)))

    print(ans)
#!/usr/bin/env python3
import sys
from fractions import gcd

input = sys.stdin.readline


class RgcdQ:
    def __init__(self, a):
        self.n = len(a)
        self.size = 2 ** (self.n - 1).bit_length()
        self.data = [0] * (2 * self.size - 1)
        self.initialize(a)

    # Initialize data
    def initialize(self, a):
        for i in range(self.n):
            self.data[self.size + i - 1] = a[i]
        for i in range(self.size - 2, -1, -1):
            self.data[i] = gcd(self.data[i * 2 + 1], self.data[i * 2 + 2])

    # Update ak as x
    def update(self, k, x):
        k += self.size - 1
        self.data[k] = x
        while k > 0:
            k = (k - 1) // 2
            self.data[k] = gcd(self.data[2 * k + 1], self.data[2 * k + 2])

    # gcd value in [l, r)
    def query(self, l, r):
        L = l + self.size
        R = r + self.size
        s = 0
        while L < R:
            if R & 1:
                R -= 1
                s = gcd(s, self.data[R - 1])
            if L & 1:
                s = gcd(s, self.data[L - 1])
                L += 1
            L >>= 1
            R >>= 1
        return s


if __name__ == "__main__":
    n = int(eval(input()))
    a = [int(item) for item in input().split()]
    ST = RgcdQ(a)
    ans = 0
    for i in range(0, n):
        ans = max(ans, gcd(ST.query(0, i), ST.query(i + 1, n)))
    print(ans)

#!/usr/bin/env python3
import sys
from fractions import gcd

input = sys.stdin.readline


class DisjointSparseTable:
    def __init__(self, a):
        # Identity element
        self.e = 0
        self.level = (len(a) - 1).bit_length()
        self.size = 2**self.level
        self.table = [[self.e] * self.size for _ in range(self.level)]
        # Set bottom first
        for i, item in enumerate(a):
            self.table[-1][i] = item
        self.build()

    def build(self):
        for i in range(1, self.level):
            step = 2**i
            lv = self.level - 1 - i
            for mid in range(step, self.size, step * 2):
                # Forward
                val = self.e
                for j in range(step):
                    val = gcd(self.table[-1][mid + j], val)
                    self.table[lv][mid + j] = val
                # Backward
                val = self.e
                for j in range(step):
                    val = gcd(self.table[-1][mid - 1 - j], val)
                    self.table[lv][mid - 1 - j] = val

    # Returns f[l:r)
    def query(self, l, r):
        if l == r:
            return self.e
        elif l == r - 1:
            return self.table[-1][l]
        lv = self.level - (l ^ r - 1).bit_length()
        return gcd(self.table[lv][l], self.table[lv][r - 1])


if __name__ == "__main__":
    n = int(eval(input()))
    a = [int(item) for item in input().split()]
    DST = DisjointSparseTable(a)
    ans = 0
    for i in range(0, n):
        ans = max(ans, gcd(DST.query(0, i), DST.query(i + 1, n)))
    print(ans)

-class RgcdQ: +class DisjointSparseTable: -        self.n = len(a) -        self.size = 2 ** (self.n - 1).bit_length() -        self.data = [0] * (2 * self.size - 1) -        self.initialize(a) +        # Identity element +        self.e = 0 +        self.level = (len(a) - 1).bit_length() +        self.size = 2**self.level +        self.table = [[self.e] * self.size for _ in range(self.level)] +        # Set bottom first +        for i, item in enumerate(a): +            self.table[-1][i] = item +        self.build() -    # Initialize data -    def initialize(self, a): -        for i in range(self.n): -            self.data[self.size + i - 1] = a[i] -        for i in range(self.size - 2, -1, -1): -            self.data[i] = gcd(self.data[i * 2 + 1], self.data[i * 2 + 2]) +    def build(self): +        for i in range(1, self.level): +            step = 2**i +            lv = self.level - 1 - i +            for mid in range(step, self.size, step * 2): +                # Forward +                val = self.e +                for j in range(step): +                    val = gcd(self.table[-1][mid + j], val) +                    self.table[lv][mid + j] = val +                # Backward +                val = self.e +                for j in range(step): +                    val = gcd(self.table[-1][mid - 1 - j], val) +                    self.table[lv][mid - 1 - j] = val -    # Update ak as x -    def update(self, k, x): -        k += self.size - 1 -        self.data[k] = x -        while k > 0: -            k = (k - 1) // 2 -            self.data[k] = gcd(self.data[2 * k + 1], self.data[2 * k + 2]) - -    # gcd value in [l, r) +    # Returns f[l:r) -        L = l + self.size -        R = r + self.size -        s = 0 -        while L < R: -            if R & 1: -                R -= 1 -                s = gcd(s, self.data[R - 1]) -            if L & 1: -                s = gcd(s, self.data[L - 1]) -                L += 1 -            L >>= 1 -            R >>= 1 -        return s +        if l == r: +            return self.e +        elif l == r - 1: +            return self.table[-1][l] +        lv = self.level - (l ^ r - 1).bit_length() +        return gcd(self.table[lv][l], self.table[lv][r - 1]) -    ST = RgcdQ(a) +    DST = DisjointSparseTable(a) -        ans = max(ans, gcd(ST.query(0, i), ST.query(i + 1, n))) +        ans = max(ans, gcd(DST.query(0, i), DST.query(i + 1, n)))