CodeEff/ECCO huggingface dataset:
# Original solution
def GCD(a, b):
    while a % b != 0:
        r = a % b
        a, b = b, r
    return b

ans = 0
N = int(eval(input()))
A = tuple(map(int,input().split()))
for S in range(len(A)):
    Af = 0
    for i in range(len(A)):
        if S != i:
            Af = GCD(Af,A[i])
    ans = max(ans,Af)

print(ans)


# Optimized solution
def GCD(a, b):
    if a == 0 and b == 0:
        return 0
    elif a == 0:
        return b
    elif b == 0:
        return a

    while a % b != 0:
        r = a % b
        a, b = b, r
    return b

ans = 0
N = int(eval(input()))
A = tuple(map(int,input().split()))

X = [0]*N
Y = [0]*N

for i in range(1,N):
    X[i] = GCD(X[i-1],A[i-1])
for i in range(N-1)[::-1]:
    Y[i] = GCD(Y[i+1],A[i+1])

for i in range(N):
    ans = max(ans,GCD(X[i],Y[i]))

print(ans)
# Original solution
n = int(eval(input()))
v = list(map(int,input().split()))

def gcd(a,b):
  while b != 0:
    a, b = b, a % b
  return a

l_ans = [0] * n
for i in range(n):
    g = 0
    for j in range(i):
        g = gcd(g, v[j])
    l_ans[i] = g
r_ans = [0] * n
for i in range(n):
    g = 0
    for j in range(i):
        g = gcd(g, v[n-1-j])
    r_ans[i] = g
r_ans.reverse()
ans = 1
for i in range(n):
    ans = max(ans, gcd(l_ans[i], r_ans[i]))
print(ans)


# Optimized solution
n = int(eval(input()))
v = list(map(int,input().split()))

def gcd(a,b):
  while b != 0:
    a, b = b, a % b
  return a

l_ans = [0] * n
g = 0
for i in range(1, n):
    g = gcd(g, v[i-1])
    l_ans[i] = g
r_ans = [0] * n
g = 0
for i in range(1, n):
    g = gcd(g, v[n-i])
    r_ans[i] = g
r_ans.reverse()
ans = 1
for i in range(n):
    ans = max(ans, gcd(l_ans[i], r_ans[i]))
print(ans)
# Original solution
from collections import Counter


def get_dividers(n):
    """
    正の整数 n の約数を取得する
    """

    dividers = {i for i in range(1, int(n ** 0.5) + 1) if n % i == 0}
    return dividers | {n // d for d in dividers}


def lcm(a, b):
    """
    aとbの最小公倍数を計算する
    """
    from math import gcd

    return a * b // gcd(a, b)


N = int(eval(input()))
A = tuple(map(int, input().split(' ')))

counter = Counter()
for a in A:
    for d in get_dividers(a):
        counter[d] += 1

ans = 1
candidates = []
for key, value in list(counter.items()):
    if value == N:
        ans = lcm(ans, key)
    elif value == N - 1:
        candidates.append(key)

if candidates:
    ans = max([lcm(ans, c) for c in candidates])

print(ans)


# Optimized solution
from collections import Counter
from functools import lru_cache


@lru_cache(maxsize=None)
def get_dividers(n):
    """
    正の整数 n の約数を取得する
    """

    dividers = {i for i in range(1, int(n ** 0.5) + 1) if n % i == 0}
    return dividers | {n // d for d in dividers}


@lru_cache(maxsize=None)
def lcm(a, b):
    """
    aとbの最小公倍数を計算する
    """
    from math import gcd

    return a * b // gcd(a, b)


N = int(eval(input()))
A = tuple(map(int, input().split(' ')))

counter = Counter()
for a in A:
    for d in get_dividers(a):
        counter[d] += 1

ans = 1
candidates = []
for key, value in list(counter.items()):
    if value == N:
        ans = lcm(ans, key)
    elif value == N - 1:
        candidates.append(key)

if candidates:
    ans = max([lcm(ans, c) for c in candidates])

print(ans)
# Original solution
from collections import Counter
from functools import lru_cache


@lru_cache(maxsize=None)
def get_dividers(n):
    """
    正の整数 n の約数を取得する
    """

    dividers = {i for i in range(1, int(n ** 0.5) + 1) if n % i == 0}
    return dividers | {n // d for d in dividers}


@lru_cache(maxsize=None)
def lcm(a, b):
    """
    aとbの最小公倍数を計算する
    """
    from math import gcd

    return a * b // gcd(a, b)


N = int(eval(input()))
A = tuple(map(int, input().split(' ')))

counter = Counter()
for a in A:
    for d in get_dividers(a):
        counter[d] += 1

ans = 1
candidates = []
for key, value in list(counter.items()):
    if value == N:
        ans = lcm(ans, key)
    elif value == N - 1:
        candidates.append(key)

if candidates:
    ans = max([lcm(ans, c) for c in candidates])

print(ans)


# Optimized solution
from collections import Counter
from functools import lru_cache
from math import gcd


@lru_cache(maxsize=None)
def get_dividers(n):
    """
    正の整数 n の約数を取得する
    """

    dividers = {i for i in range(1, int(n ** 0.5) + 1) if n % i == 0}
    return dividers | {n // d for d in dividers}


@lru_cache(maxsize=None)
def lcm(a, b):
    """
    aとbの最小公倍数を計算する
    """

    return a * b // gcd(a, b)


N = int(eval(input()))
A = tuple(map(int, input().split(' ')))

counter = Counter()
for a in A:
    counter.update(get_dividers(a))

ans = 1
candidates = []
for key, value in list(counter.items()):
    if value == N:
        ans = lcm(ans, key)
    elif value == N - 1:
        candidates.append(key)

if candidates:
    ans = max([lcm(ans, c) for c in candidates])

print(ans)
# Original solution
from collections import Counter
from functools import lru_cache
from math import gcd


@lru_cache(maxsize=None)
def get_dividers(n):
    """
    正の整数 n の約数を取得する
    """

    dividers = {i for i in range(1, int(n ** 0.5) + 1) if n % i == 0}
    return dividers | {n // d for d in dividers}


@lru_cache(maxsize=None)
def lcm(a, b):
    """
    aとbの最小公倍数を計算する
    """

    return a * b // gcd(a, b)


N = int(eval(input()))
A = tuple(map(int, input().split(' ')))

counter = Counter()
for a in A:
    counter.update(get_dividers(a))

ans = 1
candidates = []
for key, value in list(counter.items()):
    if value == N:
        ans = lcm(ans, key)
    elif value == N - 1:
        candidates.append(key)

if candidates:
    ans = max([lcm(ans, c) for c in candidates])

print(ans)


# Optimized solution
from math import gcd

N = int(eval(input()))
A = tuple(map(int, input().split(' ')))

left = []
right = []

left.append(A[0])
for a in A[1:]:
    left.append(gcd(left[-1], a))

right.append(A[-1])
for a in A[-2::-1]:
    right.append(gcd(right[-1], a))

right = list(reversed(right))

ans = [left[-2], right[1]]

for i in range(1, len(left) - 1):
    ans.append(gcd(left[i - 1], right[i + 1]))

print((max(ans)))
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))
#a,bの最大公約数
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

#リスト l の最大公約数
def gcdlist(l):
    a = l[0]
    for i in range(len(l)):
        a = gcd(a,l[i])
    return a

gcd_ref = [A[0]]

for i in range(1, N):
    new_gcd = gcd(gcd_ref[-1], A[i])
    gcd_ref.append(new_gcd)
    
best = gcd_ref[N - 1]
for i in range(N - 1, -1, -1):
    if i > 0:
        if i == N - 1:
            a = gcd_ref[i - 1]
            if best < a:
                best = a
        else:
            a = gcd_ref[i - 1]
            l = A[i + 1:]
            gcd_without_i = gcd(a, gcdlist(l))
            if gcd_without_i > best:
                best = gcd_without_i
    else:
        l = A[1:]
        gcd_without_i = gcdlist(l)
        if gcd_without_i > best:
            best = gcd_without_i

print(best)
    

# Optimized solution
N = int(eval(input()))
A = list(map(int, input().split()))
#a,bの最大公約数
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

gcd_L = [A[0]]
gcd_R = [A[N - 1]]

for i in range(1, N):
    new_gcd_l = gcd(gcd_L[-1], A[i])
    gcd_L.append(new_gcd_l)
    new_gcd_r = gcd(gcd_R[-1], A[N - i - 1])
    gcd_R.append(new_gcd_r)
    
best = gcd_L[N - 1]
for i in range(N):
    if i > 0:
        if i == N - 1:
            a = gcd_L[i - 1]
            if best < a:
                best = a
        else:
            l = gcd_L[i - 1]
            r = gcd_R[N - 2 - i]
            gcd_without_i = gcd(l, r)
            if gcd_without_i > best:
                best = gcd_without_i
    else:
        a = gcd_R[N - 2]
        if a > best:
            best = a

print(best)
# Original solution
import math

N = int(eval(input()))
A = sorted(list(map(int,input().split())))

def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)

M = A[-1]
P = [1,M]
for k in range(2,math.ceil(math.sqrt(M))+1):
    if M % k == 0:
        P.append(k)
        P.append(M//k)
M = A[-2]
P.append(M)
for k in range(2,math.ceil(math.sqrt(M))+1):
    if M % k == 0:
        P.append(k)
        P.append(M//k)
P = set(list(P))
ans = 1
for p in P:
    t = 0
    for k in range(N):
        if A[k]%p != 0:
            t += 1
        if t == 2:
            break
    if t <= 1:
        ans = max(ans,p)

print(ans)


# Optimized solution
import math
N = int(eval(input()))
A = sorted(list(map(int,input().split())))

def yakusuu(a):
    P = [a]
    for k in range(2,math.floor(math.sqrt(a))+1):
        if a % k == 0:
            P.append(k)
            P.append(a//k)
    return P

P = set(yakusuu(A[-1])+yakusuu(A[-2]))
ans = 1
for e in P:
    f = 0
    for a in A:
        if a%e != 0:
            f += 1
        if f == 2:
            break
    if f <= 1:
        ans = max(ans,e)
print(ans)
# Original solution
n = int(eval(input()))
ai = list(map(int,input().split()))

def gcd(a, b):
  while b:
    a, b = b, a%b
  return a

resmax = 0
for j in range(n):
	if j == 0:
		res = ai[1]
		for i in range(2,n):
			res = gcd(ai[i],res)
	else:
		res = ai[0]
		for i in range(1,n):
			if i == j:
				continue
			else:
				res = gcd(ai[i],res)
	if res > resmax:
		resmax = res

#print(resi)
print(resmax)


# Optimized solution
n = int(eval(input()))
ai = list(map(int,input().split()))

def gcd(a, b):
  while b:
    a, b = b, a%b
  return a

r=[]
l=[]
resr = ai[0]
resl = ai[n-1]
r.append(ai[0])
l.append(ai[n-1])
for i in range(1,n):
	resr=gcd(resr,ai[i])
	r.append(resr)
	resl=gcd(resl,ai[n-1-i])
	l.append(resl)

#print(r)
#print(l)

resmax = 1
for i in range(n):
	if i == 0:
		res = l[n-1-1]
	elif i == n-1:
		res = r[n-1-1]
	else:
		res = gcd(r[i-1], l[n-1-i-1])
	if res > resmax:
		resmax = res

print((int(resmax)))
# Original solution
import math
from functools import reduce

def gcd(numbers):
    if len(numbers)>=2:
        return reduce(math.gcd,numbers)
    else:
        return math.gcd(0,*numbers)


N = int(eval(input()))
A = list(map(int,input().split()))

ans = []

for i in range(N):
    if i == 0:
        ans.append(gcd(A[i+1:]))
    elif i == N-1:
        ans.append(gcd(A[:N-1]))
    else:#N=1からN-2
        ans.append(math.gcd(gcd(A[:i]),gcd(A[i+1:])))
#print(ans)
print((max(ans)))



# Optimized solution
from math import gcd

N = int(eval(input()))
A = list(map(int,input().split()))

L,R = [0],[0]

for i in range(N-1):
    L += [gcd(L[i],A[i])]
    R += [gcd(R[i],A[-i-1])]

print((max(gcd(L[i],R[-i-1])for i in range(N))))
# Original solution
from functools import lru_cache
from math import gcd

N = int(eval(input()))
A = list(map(int, input().split()))


@lru_cache(None)
def func(*x):
    n = len(x)
    if n == 2:
        return gcd(x[0], x[1])
    elif n == 1:
        return x[0]
    return gcd(func(*x[:n//2]), func(*x[n//2:]))


ans = 0
for i in range(N):
    tmp = A[i]
    A[i] = A[i+1 if i < N-1 else 0]
    ans = max(ans, func(*A))
    A[i] = tmp
print(ans)

# Optimized solution
from itertools import accumulate
from math import gcd

N = int(eval(input()))
A = list(map(int, input().split()))

l = list(accumulate(A[:-1], gcd, initial=0))
r = list(accumulate(A[::-1], gcd, initial=0))
print((max(gcd(l[i], r[N-i-1]) for i in range(N))))
# Original solution
# coding: utf-8
# Your code here!

N = int(input().rstrip())
A = list(map(int, input().rstrip().split()))

def gcd(x, y):
    if x == 0:
        return y
    if y == 0:
        return x
        
    if y > x:
        temp = y
        y = x
        x = temp
    amari = x % y
    if amari == 0:
        return y
    else:
        return gcd(y, amari)
        
L = [0]
for i in range(N):
    l = L[-1]
    L.append(gcd(l, A[i]))
    
R = [0]
for i in reversed(list(range(N))):
    r = R[0]
    R.insert(0, gcd(r, A[i]))

M = [gcd(L[i], R[i+1]) for i in range(N)] # i=1,...,N

print((max(M)))


# Optimized solution
# coding: utf-8
# Your code here!

N = int(input().rstrip())
A = list(map(int, input().rstrip().split()))

def gcd(x, y):
    if x == 0:
        return y
    if y == 0:
        return x
        
    if y > x:
        temp = y
        y = x
        x = temp
    amari = x % y
    if amari == 0:
        return y
    else:
        return gcd(y, amari)
        
L = list(range(N))
L[0] = 0
for i in range(N-1):
    L[i+1] = gcd(L[i], A[i])
    
R = list(range(N))
R.append(0)
for i in reversed(list(range(N))):
    R[i] = gcd(R[i+1], A[i])

M = [gcd(L[i], R[i+1]) for i in range(N)] # i=1,...,N

print((max(M)))
# Original solution
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

n = int(eval(input()))
a = list(map(int, input().split()))

dp = [a[1], a[0], gcd(a[0], a[1])]
for i in range(2, n):
    for j in range(i+1):
        if j != i:
            dp[j] = gcd(a[i], dp[j])
    dp += [gcd(a[i], dp[i])]


print((max(dp)))

# Optimized solution
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

n = int(eval(input()))
a = list(map(int, input().split()))

l = [0 for i in range(n+1)]
r = [0 for i in range(n+1)]

for i in range(1, n+1):
    l[i] = gcd(l[i-1], a[i-1])

for i in range(n)[::-1]:
    r[i] = gcd(r[i+1], a[i])

m = [0 for i in range(n)]

for i in range(n):
    m[i] = gcd(l[i], r[i+1])

print((max(m)))
# Original solution
import functools

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

n = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
for i in range(n):
    b = a[i]
    a.remove(b)
    c = functools.reduce(gcd, a)
    if ans < c:
        ans = c
    a.insert(i,b)
print(ans)

# Optimized solution
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

n = int(eval(input()))
a = list(map(int, input().split()))
a.sort()
if n == 2:
    print((max(a)))
else:
    a1 = gcd(a[0],a[1])
    a2 = gcd(a[1],a[2])
    a3 = gcd(a[2],a[0])
    m = max(a1,a2,a3)
    judge = 0
    for i in range(m):
        if judge == 1:
            break
        cnt = 0
        for j in range(n):
            if a[j] % (m-i) != 0:
                cnt += 1
            if cnt > 1:
                break
            if j == n-1 and cnt <= 1:
                print((m-i))
                judge = 1
# Original solution
import copy
from collections import deque

n = int(eval(input()))
a = list(map(int, input().split()))

max_a = max(a)

def gcd(n, m):
    if m == 0:
        return n
    
    return gcd(m, n % m)

ans = 0

if len(a) == 1:
    print((a[0]))
    exit()

for i in range(n):
    _a = copy.deepcopy(a)

    del _a[i]

    que = deque(_a)

    while len(que) > 1:
        n = que.pop()
        m = que.pop()
        l = gcd(n, m)
        
        que.append(l)

    tmp_max = que.pop()
    ans = max(ans, tmp_max)

print(ans)

# Optimized solution
import copy

n = int(eval(input()))
a = list(map(int, input().split()))

max_a = max(a)


def gcd(n, m):
    if m == 0:
        return n
    
    return gcd(m, n % m)


# 事前処理
# あらかじめ、左端からi個でgcdを計算しておく
# 同様に右からも
l = [0] * n
r = [0] * n

l[0] = a[0]
r[-1] = a[-1]

for i in range(0, n-1):
    l[i+1] = gcd(l[i], a[i+1])

for i in range(n-1, 0, -1):
    r[i-1] = gcd(r[i], a[i-1])


tmp = 0
ans = 0

for i in range(n):
    if i == 0:
        tmp = r[i+1]
    elif i == n-1:
        tmp = l[i-1]
    else:
        tmp = gcd(l[i-1], r[i+1])
    
    ans = max(ans, tmp)

print(ans)
# Original solution
# C
import functools
def gcd(a,b):
    if a<b:a,b=b,a
    if a%b==0:return b
    return gcd(b,a%b)

n = int(eval(input()))
a = list(map(int, input().split()))
a.sort()
ans = 0
pre_a = -1

for i in range(n):
    if pre_a != a[i]:
        if len(a[:i]) >= 1 and len(a[i+1:]) >= 1:
            res = gcd(functools.reduce(gcd, a[:i]), functools.reduce(gcd, a[i+1:]))
        else:
            values = a[:i] + a[i+1:]
            res = functools.reduce(gcd, values)
        ans = max(ans, res)
    pre_a = a[i]
print(ans)


# Optimized solution
# C
import functools
# 3.4以前は math の gcd が対応していないので fractions のものを使う
# from fractions import gcd
def gcd(a,b):
    if a<b:a,b=b,a
    if a%b==0:return b
    return gcd(b,a%b)


n = int(eval(input()))
a = list(map(int, input().split()))

gcd_left = [a[0]]
gcd_right = [a[-1]]
for i in range(1,n):
    if gcd_left[i-1] != 1:
        res = gcd(gcd_left[i-1], a[i])
    else:
        res = 1
    gcd_left.append(res)

for i in range(1,n):
    if gcd_right[i-1] != 1:
        res = gcd(gcd_right[i-1], a[-(i+1)])
    else:
        res = 1
    gcd_right.append(res)
gcd_right = gcd_right[::-1]


ans = 0
for i in range(n):
    if i == 0:
        res = gcd_right[1]
    elif i == n-1:
        res = gcd_left[-2]
    else:
        res = gcd(gcd_right[i+1], gcd_left[i-1])
    ans = max(res, ans)
print(ans)
# Original solution
def gca(x, y):
    if x == 0:
        return y
    return gca(y % x, x)

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

dic = {}



maxg = 0
for ignore in  range(N):
    g = A[0]
    if ignore == 0:
        g = A[1]
    for i in range(N):
        if i == ignore:
            continue
        x = g
        y = A[i]
        if y > x : x, y = y, x
        if (x, y) in dic:
            g = dic[(x, y)]
        else:
            g = gca(g, A[i])
        dic[(x, y)] = g

    maxg = max(g, maxg)

print(maxg)

# Optimized solution
def gca(x, y):
    if x == 0:
        return y
    return gca(y % x, x)

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

L = [0] * N
R = [0] * N
L[0] = A[0]
R[N - 1] = A[N - 1]

for i in range(1, N):
    L[i] = gca(A[i], L[i - 1])
for i in range(N - 2, -1, -1):
    R[i] = gca(A[i], R[i + 1])
maxg = 0
for i in range(1, N - 1):
    maxg = max(maxg, gca(L[i - 1], R[i + 1]))

print((max(L[N - 2], R[1], maxg)))
# Original solution
# -*- coding: utf-8 -*-
def gcd(a, b):
    if (b == 0):
        return a
    return gcd(b, a % b)


n = int(eval(input()))
a = list(map(int, input().split()))
g = [1] * n

ans = 1
for i in range(n):
    if i == 0:
        g[0] = a[1]
    else:
        g[0] = a[0]
    for j in range(1, n):
        if i == j:
            g[j] = g[j - 1]
            continue
        g[j] = gcd(g[j - 1], a[j])
    ans = max(ans, g[n - 1])

print(ans)


# Optimized solution
# -*- coding: utf-8 -*-
def gcd(a, b):
    if (b == 0):
        return a
    return gcd(b, a % b)


n = int(eval(input()))
a = list(map(int, input().split()))
li = [0] * (n + 1)
r = [0] * (n + 1)

for i in range(n):
    li[i + 1] = gcd(li[i], a[i])

for i in range(n - 1, -1, -1):
    r[i] = gcd(r[i + 1], a[i])

ans = 0
for i in range(n):
    ans = max(ans, gcd(li[i], r[i + 1]))

print(ans)
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))

def common_divisor(n):
    cd = []
    for i in range(1,int(n**0.5)+2):
        if n%i==0:
            cd.append(i)
            if i != n//i:
                cd.append(n//i)
    return set(cd)

#print(cd_dic)
cds = common_divisor(A[0]).union(common_divisor(A[1]))
ans = 1
for k in cds:
    #print(cd_dic)
    cnt = 0
    for a in A:
        if a%k!=0:
            cnt += 1
            if cnt == 2:
                break
    else:
        ans = max(ans,k)

print(ans)

# Optimized solution
class SegmentTree():
  def __init__(self, n, oper, e):
    self.n = n
    self.oper = oper
    self.e = e
    self.log = (n - 1).bit_length()
    self.size = 1 << self.log
    self.data = [e] * (2 * self.size)

  def update(self, k):
    self.data[k] = self.oper(self.data[2 * k], self.data[2 * k + 1])

  def build(self, arr):
    #assert len(arr) <= self.n
    for i in range(self.n):
      self.data[self.size + i] = arr[i]
    for i in range(self.size-1,0,-1):
      self.update(i)

  def set(self, p, x):
    #assert 0 <= p < self.n
    p += self.size
    self.data[p] = x
    for i in range(self.log):
      p >>= 1
      self.update(p)

  def get(self, p):
    #assert 0 <= p < self.n
    return self.data[p + self.size]

  def prod(self, l, r):
    #assert 0 <= l <= r <= self.n
    sml = smr = self.e
    l += self.size
    r += self.size
    while l < r:
      if l & 1:
        sml = self.oper(sml, self.data[l])
        l += 1
      if r & 1:
        r -= 1
        smr = self.oper(self.data[r], smr)
      l >>= 1
      r >>= 1
    return self.oper(sml, smr)

  def all_prod(self):
    return self.data[1]

  def max_right(self, l, f):
    #assert 0 <= l <= self.n
    #assert f(self.)
    if l == self.n: return self.n
    l += self.size
    sm = self.e
    while True:
      while l % 2 == 0: l >>= 1
      if not f(self.oper(sm, self.data[l])):
        while l < self.size:
          l = 2 * l
          if f(self.oper(sm, self.data[l])):
            sm = self.oper(sm, self.data[l])
            l += 1
        return l - self.size
      sm = self.oper(sm, self.data[l])
      l += 1
      if (l & -l) == l: break
    return self.n

  def min_left(self, r, f):
    #assert 0 <= r <= self.n
    #assert f(self.)
    if r == 0: return 0
    r += self.size
    sm = self.e
    while True:
      r -= 1
      while r > 1 and (r % 2): r >>= 1
      if not f(self.oper(self.data[r], sm)):
        while r < self.size:
          r = 2 * r + 1
          if f(self.oper(self.data[r], sm)):
            sm = self.oper(self.data[r], sm)
            r -= 1
        return r + 1 - self.size
      sm = self.oper(self.data[r], sm)
      if (r & -r) == r: break
    return 0

import sys
input = sys.stdin.readline

from math import gcd

e = 0

N = int(eval(input()))
A = list(map(int, input().split()))

st = SegmentTree(N,gcd,e)
st.build(A)

ans = max(st.prod(1,N),st.prod(0,N-1))
for i in range(1,N-1):
  ans = max(ans, gcd(st.prod(0,i),st.prod(i+1,N)))
print(ans)
# Original solution
n = int(eval(input()))
v = [int(i) for i in input().split()]


def gcd(x, y):
    if y > x:
        x, y = y, x
    if y == 0:
        return x
    if x % y == 0:
        return y
    return gcd(y, x % y)


l = [0 for i in range(n)]
r = [0 for i in range(n)]

for i in range(1, n):
    l[i] = gcd(l[i - 1], v[i - 1])
    r[-i-1] = gcd(r[-i], v[-i])
m = [gcd(l[i], r[i]) for i in range(n)]
print((max(m)))


# Optimized solution
n = int(eval(input()))
v = [int(i) for i in input().split()]


def gcd(x, y):
    if y > x:
        x, y = y, x
    if y == 0:
        return x
    if x % y == 0:
        return y
    return gcd(y, x % y)


l = [0 for i in range(n)]
r = l[:]

for i in range(1, n):
    l[i] = gcd(l[i - 1], v[i - 1])
    r[-i-1] = gcd(r[-i], v[-i])
m = [gcd(l[i], r[i]) for i in range(n)]
print((max(m)))
# Original solution
import sys

def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

n=int(eval(input()))
al=input().split()
al_i = [int(s) for s in al]

if (n == 2):
   print((max(al_i[0],al_i[1])))
   sys.exit()

fg = [0] * n
bg = [0] * n

for x in range(n):
   if (x == 0):
       fg[0] = al_i[0]
       y = 1
   else:
      while y <= x:
         fg[y] = gcd(fg[y-1], al_i[y])
         y += 1

for x in range(n):
   if (x == 0):
      bg[0] = al_i[n-1]
      y = 1
   else:
      while y <= x:
         bg[y] = gcd(bg[y-1], al_i[n-1-y])
         y += 1

m = 0
gm = 0

for x in range(n):
   if (x == 0):
      g = bg[n-2]
   elif (x == n-1):
      g = fg[n-2]
   else:
      g = gcd(fg[x-1],bg[n-2-x])
   if (g > gm):
      gm = g

print(gm)


# Optimized solution
def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

n=int(eval(input()))
al=[int(x) for x in input().split()]

fg = [0] * n
bg = [0] * n

fg[0] = al[0]
bg[0] = al[n-1]

for x in range(1,n):
    fg[x] = gcd(fg[x-1], al[x])
    bg[x] = gcd(bg[x-1], al[n-1-x])

gm = max(bg[n-2], fg[n-2])

for x in range(1,n-1):
   g = gcd(fg[x-1],bg[n-2-x])
   if (g > gm):
      gm = g

print(gm)
# Original solution
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

N = int(eval(input()))
A= list(map(int,input().split()))
output=0

for i in range(N):
        M = [A[i-1]]
        hoge = A[i]
        A[i] = A[i-1]
        for k in range(N):
                M.append(gcd(M[k],A[k]))

        if M[N] >= output:
                output = M[N]
        A[i]=hoge

print(output)

# Optimized solution
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

N = int(eval(input()))
A= list(map(int,input().split()))
output=0
KA=[0 for i in range(N)]
LA=[0 for i in range(N)]
GCD = []

for k in range(1,N):
        LA[k]=gcd(A[k-1],LA[k-1])

for k in range(1,N):
        KA[k]=gcd(A[N-k],KA[k-1])


for k in range(N):
        GCD.append(gcd(LA[k],KA[N-k-1]))
output = max(GCD)
print(output)