from collections import defaultdict

from math import sqrt

inpl = lambda: list(map(int,input().split()))

 

def primes(N):

    P = []

    for i in range(2,N):

        sieve = 1

        for p in P:

            if p*p > i:

                break

            elif i % p == 0:

                sieve = 0

                break

        if sieve == 0:

            continue

        else:

            P.append(i)

    return P

 

def factorize(n, P=None):

    if P is None:

        P = primes(int(sqrt(n))+1)

    factor = []

    power = []

    for p in P:

        if p * p > n:

            break

        elif n % p == 0:

            k = 0

            while n % p == 0:

                n //= p

                k += 1

            factor.append(p)

            power.append(k)

    if n > 1:

        factor.append(n)

        power.append(1)

    return factor, power

 

class Counter:

    def __init__(self, start=0):

        self.index = start-1

 

    def __call__(self):

        self.index += 1

        return self.index

 

N = int(eval(input()))

A = inpl()

 

P_MAX = 32000

infty = 100

P = primes(P_MAX)

 

np = defaultdict(Counter())

Np = 0

 

lowest_powers = []

bottle_necks = []

primelist = []

all_factors = set()

for n in range(N):

    primes, powers = factorize(A[n],P)

    pp = [0]*Np

    for i in range(len(primes)):

        k = np[primes[i]]

        if k >= Np:

            Np += 1

            pp.append(powers[i])

            primelist.append(primes[i])

            if n > 1:

                lowest_powers.append([0,0])

                bottle_necks.append(-1)

            elif n == 1:

                lowest_powers.append([0,infty])

                bottle_necks.append(0)

            else:

                lowest_powers.append([infty,infty])

                bottle_necks.append(-1)

        else:

            pp[k] = powers[i]

    for k in range(Np):

        lowest = lowest_powers[k]

        if pp[k] == lowest[0]:

            lowest[1] = lowest[0]

            bottle_necks[k] = -1

        elif pp[k] < lowest[0]:

            lowest[1] = lowest[0]

            lowest[0] = pp[k]

            bottle_necks[k] = n

        elif pp[k] < lowest[1]:

            lowest[1] = pp[k]

 

bottleneck_factors = [ [] for _ in range(N) ]

for k in range(Np):

    n = bottle_necks[k]

    if n >= 0:

        lowest = lowest_powers[k]

        bottleneck_factors[n].append([primelist[k],lowest[1]-lowest[0]])

best_n = -1

largest_f = 1

for n in range(N):

    f = 1

    for pp in bottleneck_factors[n]:

        f *= pp[0]**pp[1]

    if f > largest_f:

        largest_f = f

        best_n = n

 

ans = 1

pn = [ s[0] for s in bottleneck_factors[best_n] ]

for k in range(Np):

    p = primelist[k]

    if bottle_necks[k] == best_n:

        ans *= p**lowest_powers[k][1]

    else:

        ans *= p**lowest_powers[k][0]

print(ans)
from fractions import gcd

inpl = lambda: list(map(int,input().split()))



class SegCalcTree:

    def __init__(self, value, N=0, calc=lambda x,y: x+y):

        M = max(len(value),N)

        N = 2**(len(bin(M))-3)

        if N < M: N *= 2

        self.N = N

        self.node = [None] * (2*N-1)

        for i, v in enumerate(value):

            self.node[i+N-1] = v

        self.calc = lambda x, y: x if y is None else y if x is None else calc(x,y)

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

            left, right = self.node[2*i+1], self.node[2*i+2]

            self.node[i] = self.calc(left, right)



    def set_value(self, n, v):

        i = (self.N-1) + n

        self.node[i] = v

        while i > 0:

            i = (i-1)//2

            left, right = self.node[2*i+1], self.node[2*i+2]

            new = self.calc(left,right)

            if self.node[i] == new:

                break

            else:

                self.node[i] = new



    def get(self,

            a=0, b=-1,

            k=0, l=0, r=-1):

        if b < 0:

            b = self.N

        if r < 0:

            r = self.N

        if a <= l and r <= b:

            return self.node[k]

        elif r <= a or b <= l:

            return None

        else:

            left = self.get(a,b,2*k+1,l,(l+r)//2)

            right = self.get(a,b,2*k+2,(l+r)//2,r)

            return self.calc(left,right)



N = int(eval(input()))

A = inpl()

sct = SegCalcTree(A,calc=gcd)

ans = 0

for i in range(N):

    a = A[i]

    sct.set_value(i,None)

    c = sct.get()

    if c > ans:

        ans = c

    sct.set_value(i,a)

print(ans)
from collections import defaultdict
from math import sqrt

inpl = lambda: list(map(int, input().split()))


def primes(N):
    P = []
    for i in range(2, N):
        sieve = 1
        for p in P:
            if p * p > i:
                break
            elif i % p == 0:
                sieve = 0
                break
        if sieve == 0:
            continue
        else:
            P.append(i)
    return P


def factorize(n, P=None):
    if P is None:
        P = primes(int(sqrt(n)) + 1)
    factor = []
    power = []
    for p in P:
        if p * p > n:
            break
        elif n % p == 0:
            k = 0
            while n % p == 0:
                n //= p
                k += 1
            factor.append(p)
            power.append(k)
    if n > 1:
        factor.append(n)
        power.append(1)
    return factor, power


class Counter:
    def __init__(self, start=0):
        self.index = start - 1

    def __call__(self):
        self.index += 1
        return self.index


N = int(eval(input()))
A = inpl()
P_MAX = 32000
infty = 100
P = primes(P_MAX)
np = defaultdict(Counter())
Np = 0
lowest_powers = []
bottle_necks = []
primelist = []
all_factors = set()
for n in range(N):
    primes, powers = factorize(A[n], P)
    pp = [0] * Np
    for i in range(len(primes)):
        k = np[primes[i]]
        if k >= Np:
            Np += 1
            pp.append(powers[i])
            primelist.append(primes[i])
            if n > 1:
                lowest_powers.append([0, 0])
                bottle_necks.append(-1)
            elif n == 1:
                lowest_powers.append([0, infty])
                bottle_necks.append(0)
            else:
                lowest_powers.append([infty, infty])
                bottle_necks.append(-1)
        else:
            pp[k] = powers[i]
    for k in range(Np):
        lowest = lowest_powers[k]
        if pp[k] == lowest[0]:
            lowest[1] = lowest[0]
            bottle_necks[k] = -1
        elif pp[k] < lowest[0]:
            lowest[1] = lowest[0]
            lowest[0] = pp[k]
            bottle_necks[k] = n
        elif pp[k] < lowest[1]:
            lowest[1] = pp[k]
bottleneck_factors = [[] for _ in range(N)]
for k in range(Np):
    n = bottle_necks[k]
    if n >= 0:
        lowest = lowest_powers[k]
        bottleneck_factors[n].append([primelist[k], lowest[1] - lowest[0]])
best_n = -1
largest_f = 1
for n in range(N):
    f = 1
    for pp in bottleneck_factors[n]:
        f *= pp[0] ** pp[1]
    if f > largest_f:
        largest_f = f
        best_n = n
ans = 1
pn = [s[0] for s in bottleneck_factors[best_n]]
for k in range(Np):
    p = primelist[k]
    if bottle_necks[k] == best_n:
        ans *= p ** lowest_powers[k][1]
    else:
        ans *= p ** lowest_powers[k][0]
print(ans)

from fractions import gcd

inpl = lambda: list(map(int, input().split()))


class SegCalcTree:
    def __init__(self, value, N=0, calc=lambda x, y: x + y):
        M = max(len(value), N)
        N = 2 ** (len(bin(M)) - 3)
        if N < M:
            N *= 2
        self.N = N
        self.node = [None] * (2 * N - 1)
        for i, v in enumerate(value):
            self.node[i + N - 1] = v
        self.calc = lambda x, y: x if y is None else y if x is None else calc(x, y)
        for i in range(N - 2, -1, -1):
            left, right = self.node[2 * i + 1], self.node[2 * i + 2]
            self.node[i] = self.calc(left, right)

    def set_value(self, n, v):
        i = (self.N - 1) + n
        self.node[i] = v
        while i > 0:
            i = (i - 1) // 2
            left, right = self.node[2 * i + 1], self.node[2 * i + 2]
            new = self.calc(left, right)
            if self.node[i] == new:
                break
            else:
                self.node[i] = new

    def get(self, a=0, b=-1, k=0, l=0, r=-1):
        if b < 0:
            b = self.N
        if r < 0:
            r = self.N
        if a <= l and r <= b:
            return self.node[k]
        elif r <= a or b <= l:
            return None
        else:
            left = self.get(a, b, 2 * k + 1, l, (l + r) // 2)
            right = self.get(a, b, 2 * k + 2, (l + r) // 2, r)
            return self.calc(left, right)


N = int(eval(input()))
A = inpl()
sct = SegCalcTree(A, calc=gcd)
ans = 0
for i in range(N):
    a = A[i]
    sct.set_value(i, None)
    c = sct.get()
    if c > ans:
        ans = c
    sct.set_value(i, a)
print(ans)

-from collections import defaultdict -from math import sqrt +from fractions import gcd -def primes(N): -    P = [] -    for i in range(2, N): -        sieve = 1 -        for p in P: -            if p * p > i: +class SegCalcTree: +    def __init__(self, value, N=0, calc=lambda x, y: x + y): +        M = max(len(value), N) +        N = 2 ** (len(bin(M)) - 3) +        if N < M: +            N *= 2 +        self.N = N +        self.node = [None] * (2 * N - 1) +        for i, v in enumerate(value): +            self.node[i + N - 1] = v +        self.calc = lambda x, y: x if y is None else y if x is None else calc(x, y) +        for i in range(N - 2, -1, -1): +            left, right = self.node[2 * i + 1], self.node[2 * i + 2] +            self.node[i] = self.calc(left, right) + +    def set_value(self, n, v): +        i = (self.N - 1) + n +        self.node[i] = v +        while i > 0: +            i = (i - 1) // 2 +            left, right = self.node[2 * i + 1], self.node[2 * i + 2] +            new = self.calc(left, right) +            if self.node[i] == new: -            elif i % p == 0: -                sieve = 0 -                break -        if sieve == 0: -            continue +            else: +                self.node[i] = new + +    def get(self, a=0, b=-1, k=0, l=0, r=-1): +        if b < 0: +            b = self.N +        if r < 0: +            r = self.N +        if a <= l and r <= b: +            return self.node[k] +        elif r <= a or b <= l: +            return None -            P.append(i) -    return P - - -def factorize(n, P=None): -    if P is None: -        P = primes(int(sqrt(n)) + 1) -    factor = [] -    power = [] -    for p in P: -        if p * p > n: -            break -        elif n % p == 0: -            k = 0 -            while n % p == 0: -                n //= p -                k += 1 -            factor.append(p) -            power.append(k) -    if n > 1: -        factor.append(n) -        power.append(1) -    return factor, power - - -class Counter: -    def __init__(self, start=0): -        self.index = start - 1 - -    def __call__(self): -        self.index += 1 -        return self.index +            left = self.get(a, b, 2 * k + 1, l, (l + r) // 2) +            right = self.get(a, b, 2 * k + 2, (l + r) // 2, r) +            return self.calc(left, right) -P_MAX = 32000 -infty = 100 -P = primes(P_MAX) -np = defaultdict(Counter()) -Np = 0 -lowest_powers = [] -bottle_necks = [] -primelist = [] -all_factors = set() -for n in range(N): -    primes, powers = factorize(A[n], P) -    pp = [0] * Np -    for i in range(len(primes)): -        k = np[primes[i]] -        if k >= Np: -            Np += 1 -            pp.append(powers[i]) -            primelist.append(primes[i]) -            if n > 1: -                lowest_powers.append([0, 0]) -                bottle_necks.append(-1) -            elif n == 1: -                lowest_powers.append([0, infty]) -                bottle_necks.append(0) -            else: -                lowest_powers.append([infty, infty]) -                bottle_necks.append(-1) -        else: -            pp[k] = powers[i] -    for k in range(Np): -        lowest = lowest_powers[k] -        if pp[k] == lowest[0]: -            lowest[1] = lowest[0] -            bottle_necks[k] = -1 -        elif pp[k] < lowest[0]: -            lowest[1] = lowest[0] -            lowest[0] = pp[k] -            bottle_necks[k] = n -        elif pp[k] < lowest[1]: -            lowest[1] = pp[k] -bottleneck_factors = [[] for _ in range(N)] -for k in range(Np): -    n = bottle_necks[k] -    if n >= 0: -        lowest = lowest_powers[k] -        bottleneck_factors[n].append([primelist[k], lowest[1] - lowest[0]]) -best_n = -1 -largest_f = 1 -for n in range(N): -    f = 1 -    for pp in bottleneck_factors[n]: -        f *= pp[0] ** pp[1] -    if f > largest_f: -        largest_f = f -        best_n = n -ans = 1 -pn = [s[0] for s in bottleneck_factors[best_n]] -for k in range(Np): -    p = primelist[k] -    if bottle_necks[k] == best_n: -        ans *= p ** lowest_powers[k][1] -    else: -        ans *= p ** lowest_powers[k][0] +sct = SegCalcTree(A, calc=gcd) +ans = 0 +for i in range(N): +    a = A[i] +    sct.set_value(i, None) +    c = sct.get() +    if c > ans: +        ans = c +    sct.set_value(i, a)