# Original solution
#!/usr/bin/python3
# -*- coding: utf-8 -*-
def euclid(a, b):
    if b == 0:
        return a
    else:
        return euclid(b, a % b)

def list_euclid(int_list):
    ans = int_list[0]
    if len(int_list) == 1:
        return ans
    for i in range(1,len(int_list)):
        ans = euclid(ans, int_list[i])
        if ans == 1:
            return ans
    return ans

n = int(eval(input()))
a = list(map(int, input().split()))
max_gcd = 0
b_int = {}
min = min(a)
if n == 2:
    max_gcd = max(a)
elif n < 5:
    for i in range(0, n):
        if a[0] in b_int:
            p = a.pop(0)
            # a.append(p)
        else:
            p = a.pop(0)
            b_int[p] = p
            x = list_euclid(a)
            if max_gcd < x:
                max_gcd = x
            a.append(p)
else:
    for i in range(0, n):
        if a[0] in b_int:
            p = a.pop(0)
            # a.append(p)
        else:
            if max_gcd == 0:
                p = a.pop(0)
                b_int[p] = p
                k = len(a) // 2
                x = 0
                y = list_euclid(a[0:k])
                if y == 1:
                    x = 1
                else:
                    z = list_euclid(a[k:len(a)])
                    x = euclid(y, z)
                if max_gcd < x:
                    max_gcd = x
                a.append(p)
            elif min <= max_gcd:
                break
            else:
                p = a.pop(0)
                b_int[p] = p
                k = len(a) // 2
                x = 0
                if k < 1:
                    x = list_euclid(a)
                else:
                    y = list_euclid(a[0:k])
                    if y == 1:
                        x = 1
                    else:
                        z = list_euclid(a[k:len(a)])
                        x = euclid(y, z)
                if max_gcd < x:
                    max_gcd = x
                a.append(p)
print(max_gcd)


# Optimized solution
#!/usr/bin/python3
# -*- coding: utf-8 -*-
def euclid(a, b):
    if b == 0:
        return a
    else:
        return euclid(b, a % b)

def list_euclid(int_list):
    ans = int_list[0]
    if len(int_list) == 1:
        return ans
    kako_hash = {}
    kako_hash[ans] = ans
    for i in range(1,len(int_list)):
        if int_list[i] in kako_hash:
            continue
        else:
            kako_hash[int_list[i]] = int_list[i]
            ans = euclid(ans, int_list[i])
        if ans == 1:
            return ans
    return ans

n = int(eval(input()))
a = list(map(int, input().split()))
max_gcd = 0
b_int = {}
min = min(a)
if n == 2:
    max_gcd = max(a)
elif n < 5:
    for i in range(0, n):
        if a[0] in b_int:
            p = a.pop(0)
            # a.append(p)
        else:
            p = a.pop(0)
            b_int[p] = p
            x = list_euclid(a)
            if max_gcd < x:
                max_gcd = x
            a.append(p)
else:
    for i in range(0, n):
        if a[0] in b_int:
            p = a.pop(0)
            # a.append(p)
        else:
            if max_gcd == 0:
                p = a.pop(0)
                b_int[p] = p
                k = len(a) // 2
                x = 0
                y = list_euclid(a[0:k])
                if y == 1:
                    x = 1
                else:
                    z = list_euclid(a[k:len(a)])
                    x = euclid(y, z)
                if max_gcd < x:
                    max_gcd = x
                a.append(p)
            elif min <= max_gcd:
                break
            else:
                p = a.pop(0)
                b_int[p] = p
                k = len(a) // 2
                x = 0
                if k < 1:
                    x = list_euclid(a)
                else:
                    y = list_euclid(a[0:k])
                    if y == 1:
                        x = 1
                    else:
                        z = list_euclid(a[k:len(a)])
                        x = euclid(y, z)
                if max_gcd < x:
                    max_gcd = x
                a.append(p)
print(max_gcd)