import fractions

N = int(eval(input()))

A = [int(i) for i in input().split()]





def segfunc(x, y):

    return fractions.gcd(x, y)





def init(init_val):

    # set_val

    for i in range(N):

        seg[i+num-1] = init_val[i]

    # built

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

        seg[i] = segfunc(seg[2*i+1], seg[2*i+2])





def update(k, x):

    k += num-1

    seg[k] = x

    while k:

        k = (k-1)//2

        seg[k] = segfunc(seg[k*2+1], seg[k*2+2])





def query(p, q):

    if q <= p:

        return ide_ele

    p += num-1

    q += num-2

    res = ide_ele

    while q-p > 1:

        if p & 1 == 0:

            res = segfunc(res, seg[p])

        if q & 1 == 1:

            res = segfunc(res, seg[q])

            q -= 1

        p = p//2

        q = (q-1)//2

    if p == q:

        res = segfunc(res, seg[p])

    else:

        res = segfunc(segfunc(res, seg[p]), seg[q])

    return res





#####単位元######

ide_ele = 0



# num:n以上の最小の2のべき乗

num = 2**(N-1).bit_length()

seg = [ide_ele]*2*num



# 'init(a)': 配列aで初期化。O(N)

# 'update(k,x)': a[k]をxに変更 O(logN)

# 'query(p,q)': [p, q)について "segfunc" したものを返す O(logN)

# 'ide_ele': 単位元。





init(A)

ans = 0

for i in range(N):

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

print(ans)

import fractions

N = int(eval(input()))

A = [int(i) for i in input().split()]



GCD_l = [A[0]]

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

    GCD_l.append(fractions.gcd(GCD_l[-1], A[i]))



A = A[::-1]

GCD_r = [A[0]]

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

    GCD_r.append(fractions.gcd(GCD_r[-1], A[i]))

GCD_r = GCD_r[::-1]



# print(GCD_l, GCD_r)



ans = 1

for i in range(N):

    if i == 0:

        ans = max(ans, GCD_r[0])

    elif i == N-1:

        ans = max(ans, GCD_l[N-2])

    else:

        ans = max(ans, fractions.gcd(GCD_l[i-1], GCD_r[i]))

print(ans)

import fractions

N = int(eval(input()))
A = [int(i) for i in input().split()]


def segfunc(x, y):
    return fractions.gcd(x, y)


def init(init_val):
    # set_val
    for i in range(N):
        seg[i + num - 1] = init_val[i]
    # built
    for i in range(num - 2, -1, -1):
        seg[i] = segfunc(seg[2 * i + 1], seg[2 * i + 2])


def update(k, x):
    k += num - 1
    seg[k] = x
    while k:
        k = (k - 1) // 2
        seg[k] = segfunc(seg[k * 2 + 1], seg[k * 2 + 2])


def query(p, q):
    if q <= p:
        return ide_ele
    p += num - 1
    q += num - 2
    res = ide_ele
    while q - p > 1:
        if p & 1 == 0:
            res = segfunc(res, seg[p])
        if q & 1 == 1:
            res = segfunc(res, seg[q])
            q -= 1
        p = p // 2
        q = (q - 1) // 2
    if p == q:
        res = segfunc(res, seg[p])
    else:
        res = segfunc(segfunc(res, seg[p]), seg[q])
    return res


#####単位元######
ide_ele = 0
# num:n以上の最小の2のべき乗
num = 2 ** (N - 1).bit_length()
seg = [ide_ele] * 2 * num
# 'init(a)': 配列aで初期化。O(N)
# 'update(k,x)': a[k]をxに変更 O(logN)
# 'query(p,q)': [p, q)について "segfunc" したものを返す O(logN)
# 'ide_ele': 単位元。
init(A)
ans = 0
for i in range(N):
    ans = max(ans, fractions.gcd(query(0, i), query(i + 1, N)))
print(ans)

import fractions

N = int(eval(input()))
A = [int(i) for i in input().split()]
GCD_l = [A[0]]
for i in range(1, N - 1):
    GCD_l.append(fractions.gcd(GCD_l[-1], A[i]))
A = A[::-1]
GCD_r = [A[0]]
for i in range(1, N - 1):
    GCD_r.append(fractions.gcd(GCD_r[-1], A[i]))
GCD_r = GCD_r[::-1]
# print(GCD_l, GCD_r)
ans = 1
for i in range(N):
    if i == 0:
        ans = max(ans, GCD_r[0])
    elif i == N - 1:
        ans = max(ans, GCD_l[N - 2])
    else:
        ans = max(ans, fractions.gcd(GCD_l[i - 1], GCD_r[i]))
print(ans)

- - -def segfunc(x, y): -    return fractions.gcd(x, y) - - -def init(init_val): -    # set_val -    for i in range(N): -        seg[i + num - 1] = init_val[i] -    # built -    for i in range(num - 2, -1, -1): -        seg[i] = segfunc(seg[2 * i + 1], seg[2 * i + 2]) - - -def update(k, x): -    k += num - 1 -    seg[k] = x -    while k: -        k = (k - 1) // 2 -        seg[k] = segfunc(seg[k * 2 + 1], seg[k * 2 + 2]) - - -def query(p, q): -    if q <= p: -        return ide_ele -    p += num - 1 -    q += num - 2 -    res = ide_ele -    while q - p > 1: -        if p & 1 == 0: -            res = segfunc(res, seg[p]) -        if q & 1 == 1: -            res = segfunc(res, seg[q]) -            q -= 1 -        p = p // 2 -        q = (q - 1) // 2 -    if p == q: -        res = segfunc(res, seg[p]) +GCD_l = [A[0]] +for i in range(1, N - 1): +    GCD_l.append(fractions.gcd(GCD_l[-1], A[i])) +A = A[::-1] +GCD_r = [A[0]] +for i in range(1, N - 1): +    GCD_r.append(fractions.gcd(GCD_r[-1], A[i])) +GCD_r = GCD_r[::-1] +# print(GCD_l, GCD_r) +ans = 1 +for i in range(N): +    if i == 0: +        ans = max(ans, GCD_r[0]) +    elif i == N - 1: +        ans = max(ans, GCD_l[N - 2]) -        res = segfunc(segfunc(res, seg[p]), seg[q]) -    return res - - -#####単位元###### -ide_ele = 0 -# num:n以上の最小の2のべき乗 -num = 2 ** (N - 1).bit_length() -seg = [ide_ele] * 2 * num -# 'init(a)': 配列aで初期化。O(N) -# 'update(k,x)': a[k]をxに変更 O(logN) -# 'query(p,q)': [p, q)について "segfunc" したものを返す O(logN) -# 'ide_ele': 単位元。 -init(A) -ans = 0 -for i in range(N): -    ans = max(ans, fractions.gcd(query(0, i), query(i + 1, N))) +        ans = max(ans, fractions.gcd(GCD_l[i - 1], GCD_r[i]))