CodeEff/ECCO huggingface dataset:
# Original solution
import sys

def generate_next_hexes(x, y):
    hexes = list()
    hexes.append((x, y - 1))
    hexes.append((x, y + 1))
    hexes.append((x - 1, y))
    hexes.append((x + 1, y))
    if y % 2:
        hexes.append((x - 1, y - 1))
        hexes.append((x - 1, y + 1))
    else:
        hexes.append((x + 1, y - 1))
        hexes.append((x + 1, y + 1))
    return hexes

def update_map(hex_map, hexes):
    num_updated_hexes = 0
    distance = 0
    while hexes:
        next_hexes = []
        for pos in hexes:
            x = pos[0]
            y = pos[1]
            if (1 <= x <= m and 1 <= y <= n
                    and (pos not in hex_map or distance < hex_map[pos])):
                hex_map[pos] = distance
                num_updated_hexes += 1
                next_hexes += generate_next_hexes(x, y)
        distance += 1
        hexes = next_hexes
    return num_updated_hexes

while True:
    (m, n) = [int(i) for i in sys.stdin.readline().split()]
    if m == n == 0:
        break

    s = int(sys.stdin.readline())
    stores = []
    for i in range(s):
        cord = [int(j) for j in sys.stdin.readline().split()]
        stores.append(tuple(cord))
    hex_map = {}
    update_map(hex_map, stores)

    t = int(sys.stdin.readline())
    candidates = []
    for i in range(t):
        cord = [int(j) for j in sys.stdin.readline().split()]
        candidates.append(tuple(cord))

    # search max num
    max_num_blocks = 0
    for candidate in candidates:
        new_hex_map = hex_map.copy()
        num_blocks = update_map(new_hex_map, [candidate])
        max_num_blocks = max(max_num_blocks, num_blocks)

    print(max_num_blocks)

# Optimized solution
import sys

def generate_next_hexes(x, y):
    hexes = [(x, y - 1), (x, y + 1), (x - 1, y), (x + 1, y)]
    if y % 2:
        hexes += [(x - 1, y - 1), (x - 1, y + 1)]
    else:
        hexes += [(x + 1, y - 1), (x + 1, y + 1)]
    return hexes

def update_map(hex_map, hexes):
    num_updated_hexes = 0
    distance = 0
    while hexes:
        next_hexes = []
        for pos in hexes:
            if (1 <= pos[0] <= m and 1 <= pos[1] <= n) and (pos not in hex_map or distance < hex_map[pos]):
                hex_map[pos] = distance
                num_updated_hexes += 1
                next_hexes += generate_next_hexes(pos[0], pos[1])
        distance += 1
        hexes = next_hexes
    return num_updated_hexes

while True:
    (m, n) = [int(i) for i in sys.stdin.readline().split()]
    if m == n == 0:
        break

    s = int(sys.stdin.readline())
    stores = []
    for i in range(s):
        pos = [int(j) for j in sys.stdin.readline().split()]
        stores.append(tuple(pos))
    hex_map = {}
    update_map(hex_map, stores)

    t = int(sys.stdin.readline())
    candidates = []
    for i in range(t):
        pos = [int(j) for j in sys.stdin.readline().split()]
        candidates.append(tuple(pos))

    max_num_blocks = 0
    for candidate in candidates:
        new_hex_map = hex_map.copy()
        num_blocks = update_map(new_hex_map, [candidate])
        max_num_blocks = max(max_num_blocks, num_blocks)

    print(max_num_blocks)
# Original solution
Q, H, S, D = list(map(int, input().split()))
N = int(eval(input()))

ans1 = 4 * Q * N
ans2 = 2 * H * N
ans3 = S * N

if N < 2:
    ans4 = float('INF')
elif N % 2 == 0:
    ans4 = (N // 2) * D
else:
    t = (N // 2) * D
    ans4 = t + min(4 * Q, 2 * H, 1 * S)

# print(ans1, ans2, ans3, ans4)
ans = min(ans1, ans2, ans3, ans4)
print(ans)

# Optimized solution
Q, H, S, D = list(map(int, input().split()))
N = int(eval(input()))

t = min(4*Q, 2*H, S)
if D < 2 * t:
    if N % 2 == 0:
        ans = (N // 2) * D
    else:
        ans = (N // 2) * D + t
else:
    ans = N * t

print(ans)
# Original solution
q, h, s, d = [int(i) for i in input().split()]
n = int(eval(input()))
d = min(min(d, s*2), min(h*4, q*8))
s = min(s, min(h*2, q*4))
h = min(h, q*2)
ans = (n // 2) * d
n %= 2
while n > 0:
    if n >= 1:
        n -= 1
        ans += s
    elif n >= 0.5:
        n -= 0.5
        ans += h
    else:
        n -= 0.25
        ans += q

print(ans)

# Optimized solution
q, h, s, d = [int(i) for i in input().split()]
n = int(eval(input()))
d = min(min(d, s*2), min(h*4, q*8))
s = min(s, min(h*2, q*4))
print(((n // 2) * d + (n % 2) * s))
# Original solution
Q,H,S,D = (int(i) for i in input().split())
N = int(eval(input()))

q = Q*4
h = H*2
s = S
d = D/2

if min(q,h,s,d)==d:
    if N%2 == 0:
        money = D*(N//2)
    else:
        money = (N//2)*D + min(q,h,s)
else:
    money = min(q,h,s)*N

print((int(money)))

# Optimized solution
Q,H,S,D = (int(i) for i in input().split())
N = int(eval(input()))

Qper025L = Q
Hper025L = H / 2
Sper025L = S / 4
Dper025L = D / 8

teainfo = [["Q",Qper025L,Q,0.25],["H",Hper025L,H,0.50],["S",Sper025L,S,1],["D",Dper025L,D,2]]

sortedtea = sorted(teainfo, key = lambda x:(x[1],x[2]), reverse = False)

price = 0

for i in range(4):
    if sortedtea[i][3] <= N:
        numbottles = int(N / sortedtea[i][3])
        N -= sortedtea[i][3] * numbottles
        price += sortedtea[i][2] * numbottles

print((int(price)))
# Original solution
q,h,s,d = list(map(int,input().split()))
n = int(eval(input()))
twoL = min(q*8,4*h,2*s,d)
oneL = min(q*4,2*h,s)
p = (n//2)*twoL + (n%2)*oneL
print(p)


# Optimized solution
Q,H,S,D=list(map(int,input().split()))
N=int(eval(input()))
ans=0
#each 2L
ans+=(N//2)*min([8*Q,4*H,2*S,D])
#1L
ans+=(N%2)*min([4*Q,2*H,S])
print(ans)
# Original solution
q, h, s, d = list(map(int, input().split()))
n = int(eval(input()))
l = [4 * q, 2 * h, s, d / 2]
ans = 0
if n >= 2:
  a = l.index(min(l))
  if a == 0:
    ans = 4 * q * n
  elif a == 1:
    ans = 2 * h * n
  elif a == 2:
    ans = s * n
  elif a == 3:
    if n % 2 == 0:
      ans = n // 2 * d
    elif n % 2 == 1:
      ans = n // 2 * d
      b = l.index(min(l[:3]))
      if b == 0:
        ans += 4 * q
      elif b == 1:
        ans += 2 * h
      elif b == 2:
        ans += s
else:
  b = l.index(min(l[:3]))
  if b == 0:
    ans = 4 * q * n
  elif b == 1:
    ans = 2 * h * n
  elif b == 2:
    ans = s * n
print(ans)


# Optimized solution
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    quota,half,single,double = list(map(int,input().split()))
    want_icetea=int(eval(input()))
    cost_list = [4 * quota, 2 * half, single, double / 2]
    ans=0
    if want_icetea >= 2:
        idx1 = cost_list.index(min(cost_list))
        if idx1 == 0:
            ans = 4 * quota * want_icetea
        elif idx1 == 1:
            ans = 2 * half * want_icetea
        elif idx1 == 2:
            ans = single * want_icetea
        elif idx1 == 3:
            if want_icetea % 2 == 0:
                ans = want_icetea // 2 * double
            elif want_icetea % 2 == 1:
                ans = want_icetea // 2 * double
                idx2 = cost_list.index(min(cost_list[:3]))
                if idx2 == 0:
                    ans += 4 * quota
                elif idx2 == 1:
                    ans += 2 * half
                elif idx2 == 2:
                    ans += single
    else:
        idx2 = cost_list.index(min(cost_list[:3]))
        if idx2 == 0:
            ans = 4 * quota * want_icetea
        elif idx2 == 1:
            ans = 2 * half * want_icetea
        elif idx2 == 2:
            ans = single * want_icetea
    print(ans)
if __name__=="__main__":
    main()
# Original solution
cost = list(map(int, input().split()))
size = [1, 2, 4, 8]
N = int(eval(input())) * 4

ans = 0
while N > 0:
    min_ = (N // size[0]) * cost[0]
    q = 0
    for i in range(1,4):
        tmp = (N//size[i]) * cost[i]
        if tmp < min_ and tmp != 0:
            min_ = tmp
            q = i
    ans += min_
    N = N%size[q]
print(ans)


# Optimized solution
import sys
input = sys.stdin.readline

def main():
    Q, H, S, D = list(map(int, input().split()))
    N = int(eval(input()))
    c1 = min(Q*4, H*2, S)
    c2 = min(c1*2, D)
    ans = 0
    ans += c2 * (N//2)
    rest = int(N%2)
    ans += c1 * rest
    print(ans)


if __name__ == "__main__":
    main()
# Original solution
Q,H,S,D=list(map(int,input().split()))
N=int(eval(input()))
Min1=min(4*Q,2*H,S)
Min2=min(2*Min1,D)
Even=N//2
Odd=N%2
ans=Even*Min2+Odd*Min1
print(ans)

# Optimized solution
Q,H,S,D=list(map(int,input().split()))
N=int(eval(input()))
N2,N1=divmod(N,2)
tmp2=min(8*Q,4*H,2*S,D)
tmp1=min(4*Q,2*H,S)
ans2=N2*tmp2
ans1=N1*tmp1
ans=ans1+ans2
print(ans)
# Original solution
q,h,s,d = list(map(int,input().split()))
n = int(eval(input()))
m = min(8*q,4*h,2*s,d)*(n//2) + min(4*q,2*h,s)*(n%2)
print(m)

# Optimized solution
q,h,s,d=list(map(int,input().split()))
n=int(eval(input()))
m=n//2*min(8*q,4*h,2*s,d)+n%2*min(4*q,2*h,s)
print(m)
# Original solution
Q, H, S, D = list(map(int,input().split()))
N = int(eval(input()))
print((min(D,2*S,4*H,8*Q)*(N//2)+min(S,2*H,4*Q)*(N%2)))


# Optimized solution
import sys
def input():
    return sys.stdin.readline()[:-1]
def main():
    Q, H, S, D = list(map(int,input().split()))
    N = int(eval(input()))
    print(((N//2)*min(Q*8,H*4,S*2,D)+(N%2)*min(Q*4,H*2,S)))
    
if __name__ == '__main__':
    main()
# Original solution
# -*- coding: utf-8 -*-
q,h,s,d = list(map(int,input().split()))
n = int(eval(input()))

q = 4*q
h = 2*h

if n%2==0:
    t = q*n
    t = min(t, h*n)
    t = min(t, s*n)
    t = min(t, d*n//2)
else:
    t = q*n
    t = min(t, h*n)
    t = min(t, s*n)
    t = min(t, (n//2)*d + min(q,h,s))
print(t)


# Optimized solution
q,h,s,d = list(map(int, input().split()))
n = int(eval(input()))

q = 4*q
h = 2*h
x = min(q,h,s)

print(((n//2)*min(2*x,d)+(n%2)*x))
# Original solution
Q,H,S,D = list(map(int,input().split()))
N = int(eval(input()))
a2 = min(Q*8,H*4,S*2,D)
ans = (N//2)*a2
a1 = min(Q*4,H*2,S)
ans += (N%2)*a1
print(ans)

# Optimized solution
Q,H,S,D = list(map(int,input().split()))
N = int(eval(input()))
x2 = min(D,2*S,4*H,8*Q)
cnt = (N//2)*x2
N = N%2
x1 = min(S,2*H,4*Q)
cnt += N*x1
print(cnt)
# Original solution
# AtCoder Grand Contest 019
# A - Ice Tea Store

def f(Q,H,S,D,N,M):
    QQ=Q
    QH=H/2
    QS=S/4
    QD=D/8

    if N==0:
        return M

    if N==1:
        if QQ==min(QQ,QH,QS):
            return M+(4*Q)

        if QH==min(QQ,QH,QS):
            return M+(2*H)
        
        if QS==min(QQ,QH,QS):
            return M+(S)
    else:
        if QQ==min(QQ,QH,QS,QD):
            return M+4*Q*N
            
        if QH==min(QQ,QH,QS,QD):
            return M+2*H*N
        
        if QS==min(QQ,QH,QS,QD):
            return M+S*N
        
        if QD==min(QQ,QH,QS,QD):
            if N%2==0:
                return M+(N//2)*D
            else:
                return f(Q,H,S,D,1,M+(N//2)*D)




Q,H,S,D=list(map(int,input().split()))
N=int(eval(input()))

print((f(Q,H,S,D,N,0)))

# Optimized solution
Q,H,S,D=list(map(int,input().split()))
N=int(eval(input()))

one=min (4*Q,2*H,S)
if N==1:
    print(one)
else :
    if 2*one<=D:
        print((N*one))
    else:
        if N%2==0:
            print(((N//2)*D))
        else:
            print(((N//2)*D+one))
# Original solution
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    q, h, s, d = list(map(int, readline().split()))
    n = int(readline())
    h = min(h, q * 2)
    s = min(s, h * 2, q * 4)
    d = min(d, s * 2, h * 4, q * 8)
    cnt = 0
    cnt += n // 2 * d
    n -= n // 2 * 2
    cnt += n // 1 * s
    n -= n // 1
    print(cnt)


if __name__ == '__main__':
    solve()


# Optimized solution
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    ls = list(map(int, readline().split()))
    n = int(readline())
    ls[1] = min(ls[1], ls[0] * 2)
    ls[2] = min(ls[2], ls[1] * 2)
    ls[3] = min(ls[3], ls[2] * 2)
    t = 0
    for i in range(3, -1, -1):
        if i == 3:
            t += n // 2 * ls[i]
            n -= n // 2 * 2
        elif i == 2:
            t += n // 1 * ls[i]
            n -= n // 1 * 1
        elif i == 1:
            t += n / 0.5 * ls[i]
            n -= n // 0.5 * 0.5
        else:
            t += n // 0.25 * ls[i]
            n -= n // 0.25 * 0.25
        if n == 0:
            break
    print((int(t)))


if __name__ == '__main__':
    solve()
# Original solution
Q,H,S,D = list(map(int, input().split()))
N = int(eval(input()))

h = min(Q*2, H)
s = min(h*2, S)
d = min(s*2, D)

ans = (N // 2)*d + (0 if N%2 == 0 else s)
print(ans)


# Optimized solution
Q,H,S,D = list(map(int,input().split()))
N = int(eval(input()))

half = min(Q*2,H)
one = min(half*2,S)
doub = min(one*2,D)

ans = (N//2)*doub + (N%2)*one
print(ans)
# Original solution
Q, H, S, D = list(map(int, input().split()))
N = int(eval(input()))

PS = [[Q * 8, 0.25], [H * 4, 0.5], [S * 2, 1], [D, 2]]

PS.sort(key=lambda x: x[0])


R = N
ans = 0
for i in range (4):
    if R == 0:
        break
    elif R >= PS[i][1]:
        ans += int(PS[i][0] * PS[i][1] // 2 * (R // PS[i][1]))
        R = R % PS[i][1]

print(ans)

# Optimized solution
Q, H, S, D = list(map(int, input().split()))
N = int(eval(input()))

ans = (N//2) * min(8 * Q, 4 * H, S * 2, D) + (N % 2) * min(4 * Q, 2 * H, S)

print(ans)
# Original solution
A="".join(["11000000",
           "11"])

B="".join(["10000000",
           "10000000",
           "10000000",
           "1"])

C="".join(["1111"])

D="".join(["01000000",
           "11000000",
           "1"])

E="".join(["11000000",
           "011"])

F="".join(["10000000",
           "11000000",
           "01"])

G="".join(["01100000",
           "11"])

teto=[A,B,C,D,E,F,G]

while True:
    try:
        a="".join([input() for i in range(8)])
        for i in range(len(teto)):
            if a.find(teto[i])>=0:
                print(chr(i+ord("A")))
        input()
    except:
        break
#temp

# Optimized solution
A="".join(["11000000",
           "11"])

B="".join(["10000000",
           "10000000",
           "10000000",
           "1"])

C="".join(["1111"])

D="".join(["01000000",
           "11000000",
           "1"])

E="".join(["11000000",
           "011"])

F="".join(["10000000",
           "11000000",
           "01"])

G="".join(["01100000",
           "11"])

teto=[A,B,C,D,E,F,G]

while True:
    try:
        a="".join([input() for i in range(8)])
        for i in range(len(teto)):
            if a.find(teto[i])>=0:
                print(chr(i+ord("A")))
        input()
    except:
        break
# Original solution
import re
while True:
    try:
        s = ''.join([input() for s in range(8)])
        print('    C    GAE    D F      B'[len(re.findall('1.*1', s)[0])])
        input()
    except EOFError:
        break

# Optimized solution
import sys;import re
for s in sys.stdin.read().split('\n\n'):print('    C    GAE    D F      B'[len(re.findall('1.*1', s.replace('\n',''))[0])])
# Original solution
from functools import reduce


def gcd(v1, v2):
    v3 = v1 % v2
    if v3 == 0:
        return v2
    return gcd(v2, v3)


def main():
    N = int(eval(input()))
    A = [int(v) for v in input().split()]

    max_gcd = max(reduce(gcd, A[1:]), reduce(gcd, A[:N-1]))

    for i in range(1, N - 1):
        v1 = reduce(gcd, A[:i])
        v2 = reduce(gcd, A[i + 1:])

        #print(A[:i], A[i+1:])

        max_gcd = max(max_gcd, gcd(v1, v2))

    #print(reduce(gcd, A))

    print(max_gcd)


if __name__ == "__main__":
    main()


# Optimized solution
from functools import reduce


def gcd(v1, v2):
    v3 = v1 % v2
    if v3 == 0:
        return v2
    return gcd(v2, v3)


def main():
    N = int(eval(input()))
    A = [int(v) for v in input().split()]

    max_gcd = max(reduce(gcd, A[1:]), reduce(gcd, A[:N-1]))

    left = [1] * N
    left[0] = A[0]
    for i in range(1, N):
        left[i] = gcd(A[i], left[i - 1])

    right = [1] * N
    right[N-1] = A[N-1]
    for i in range(N - 2, -1, - 1):
        right[i] = gcd(A[i], right[i + 1])

    # print(left)
    # print(right)

    max_gcd = max(right[1], left[N-2])
    for i in range(1, N - 1):
        max_gcd = max(max_gcd, gcd(left[i - 1], right[i + 1]))

    print(max_gcd)


if __name__ == "__main__":
    main()
# Original solution
import sys
from functools import reduce
import sys
input = sys.stdin.readline
n = int(eval(input()))
A = list(map(int, input().split()))

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

def gcd_list(numbers):
    return reduce(gcd, numbers)

ans = 0
for i in range(n):
    ans = max(ans, gcd_list(A[0:i] + A[i + 1:]))

print(ans)

# Optimized solution
# -*- coding: utf-8 -*-
import sys
from functools import reduce
import sys
input = sys.stdin.readline
n = int(eval(input()))
A = list(map(int, input().split()))

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


L = [0] + [None] * (n - 1)
R = [0] + [None] * (n - 1)
for i in range(1, n):
	L[i] = gcd(L[i - 1], A[i - 1])
	R[i] = gcd(R[i - 1], A[-i])

M = [None] * n
R = R[::-1]
for i in range(n):
	M[i] = gcd(L[i], R[i])

print((max(M)))
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))
end = sorted(a)[1]

for i in range(end+1, 0, -1):
  x = 0
  for j in a:
    if j % i != 0:
      x += 1
  if x <= 1:
    print(i)
    break

# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))
end = sorted(a)[1]

for i in range(end+1, 0, -1):
  x = 0
  for j in a:
    if j % i != 0:
      x += 1
    if x >= 2:
      break
  if x <= 1:
    print(i)
    break
# Original solution
def gcd(m, n):
    r = m % n
    return n if r == 0 else gcd(n, r)


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

if n == 2:
    print((max(A)))
    exit()

GCD = []
for i in range(n):
    A2 = A[:i] + A[i + 1:]
    g = gcd(A2[0], A2[1])
    for j in range(2, n - 1):
        g = gcd(g, A2[j])
        if g == 1:
            break
    GCD.append(g)

print((max(GCD)))


# Optimized solution
def gcd(m, n):
    r = m % n
    return n if r == 0 else gcd(n, r)


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

GCD_left = A[:]
for i in range(1, n):
    GCD_left[i] = gcd(GCD_left[i - 1], GCD_left[i])
GCD_right = A[:]
for i in range(n - 2, -1, -1):
    GCD_right[i] = gcd(GCD_right[i], GCD_right[i + 1])

GCD = [1] * n
GCD[0], GCD[-1] = GCD_right[1], GCD_left[-2]
for i in range(1, n - 1):
    GCD[i] = gcd(GCD_left[i - 1], GCD_right[i + 1])

print((max(GCD)))
# Original solution
def gcd(x, y):
    while y!=0:
        x, y = y, x % y # x,yの大小が逆でも、入れ替わるので、OK
    return x

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

if n == 2:
    print((max(a)))

elif n>=3:
    l = [-1] * n
    r = [-1] * n
    l[0] = a[0]  #一番左を左に挿入
    r[-1] = a[-1] #一番右を右に挿入
# print(l)
# print(r)

    for i in range(1, n): #左から最大公約数をn-1回計算していく
        l[i] = gcd(l[i-1], a[i]) # l[0]とa[1]の最大公約数をl[1]に挿入⇒
        # l[1]とa[2]の最大公約数をl[2]に挿入。隣同士素があったら、それ以降右側全て1
        for i in range(n-2, -1, -1): #右から最大公約数を計算していく
            r[i] = gcd(r[i+1], a[i]) # r[n-1]とa[n-2]の最大公約数をr[n-2]に挿入

        # print("l",l) # lはn-1桁のlist
        # print("r",r)

        ans = max(r[1], l[-2]) # rの左から2番目とlの右から2番目の大きい方を、ansに挿入.
        # 右端、左端は、最大公約数ではないため。(元々の数列)

        for i in range(1, n-1): #両端を切り取った中で、lは右側に寄せて、rは左側に寄せているので、
            g = gcd(l[i-1], r[i+1]) #
            ans = max(ans, g)
            # print(i, g, ans)
    print(ans)

# Optimized solution
def gcd(x, y):
    while y!=0:
        x, y = y, x % y # x,yの大小が逆でも、入れ替わるので、OK
    return x

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

if n == 2:
    print((max(a)))

elif n>=3:
    l = [-1] * n
    r = [-1] * n
    l[0] = a[0]  #一番左を左に挿入
    r[-1] = a[-1] #一番右を右に挿入
# print(l)
# print(r)

    for i in range(1, n): #左から最大公約数をn-1回計算していく
        l[i] = gcd(l[i-1], a[i]) # l[0]とa[1]の最大公約数をl[1]に挿入⇒
        # l[1]とa[2]の最大公約数をl[2]に挿入。隣同士素があったら、それ以降右側全て1
    for i in range(n-2, -1, -1): #右から最大公約数を計算していく
        r[i] = gcd(r[i+1], a[i]) # r[n-1]とa[n-2]の最大公約数をr[n-2]に挿入

        # print("l",l) # lはn-1桁のlist
        # print("r",r)

    ans = max(r[1], l[-2]) # rの左から2番目とlの右から2番目の大きい方を、ansに挿入.
        # 右端、左端は、最大公約数ではないため。(元々の数列)

    for i in range(1, n-1): #両端を切り取った中で、lは右側に寄せて、rは左側に寄せているので、
        g = gcd(l[i-1], r[i+1]) #
        ans = max(ans, g)
        # print(i, g, ans)
    print(ans)
# Original solution
import math
from functools import reduce

def gcd(list):
  return reduce(math.gcd, list)

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

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

print(ans)

# Optimized solution
from math import *

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

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

ans = l[n-2]
r = a[n-1]
for i in range(n-2,0,-1):
  r = gcd(r, a[i+1])
  ans = max(ans, gcd(l[i-1], r))
ans = max(ans, gcd(r,a[1]))
print(ans)
# Original solution

from functools import reduce

def gcd(a,b):
  x = max([a,b])
  y = min([a,b])
  while y:
    x, y = y, x % y
  return x

def gcd_list(nums):
  return reduce(gcd, nums)

n = int(eval(input()))

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


ans = 0
for i in range(n):
      tmp_list = a[:i] + (a[i+1:])
      #print(tmp_list)
      tmp = gcd_list(tmp_list)
      if ans < tmp:
            ans = tmp

print(ans)


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


def gcd(a,b):
  x = max([a,b])
  y = min([a,b])
  while y:
    x, y = y, x % y
  return x

L = [0]
R = [0]

for i in range(N):
    L.append(gcd(L[-1], A[i]))
    
for i in reversed(list(range(N))):
    R.append(gcd(R[-1], A[i]))

R = list(reversed(R))


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

ans = max(ans, R[1])
ans = max(ans, L[-2])

print(ans)
#print(R)
#print(L)
# Original solution
N = int(eval(input()))
A = sorted(list(map(int, input().split())))
if N == 2:
    print((max(A)))
    exit()
result = []
num = 0
for a in A[1:]:
    if a % A[0] != 0:
        num += 1
        if num == 2:
            break
else:
    result.append(A[0])
for n in range(A[0], 0, -1):
    if A[0] % n != 0:
        continue
    num = 0
    for a in A[1:]:
        if a % n != 0:
            num += 1
            if num == 2:
                break
    else:
        result.append(n)
num = 0
for a in A[0:1] + A[2:]:
    if a % A[1] != 0:
        num += 1
        if num == 2:
            break
else:
    result.append(A[1])
for n in range(A[1], 0, -1):
    if A[1] % n != 0:
        continue
    num = 0
    for a in A[0:1] + A[2:]:
        if a % n != 0:
            num += 1
            if num == 2:
                break
    else:
        result.append(n)
print((max(result)))


# Optimized solution
import math
N = int(eval(input()))
A = sorted(list(map(int, input().split())))
if N == 2:
    print((max(A)))
    exit()
result = []
num = 0
for a in A[1:]:
    if a % A[0] != 0:
        num += 1
        if num == 2:
            break
else:
    result.append(A[0])
for n in range(2, int(math.sqrt(A[0])) + 1):
    if A[0] % n != 0:
        continue
    num = 0
    x = A[0] // n
    for a in A[1:]:
        if a % x != 0:
            num += 1
            if num == 2:
                break
    else:
        result.append(x)
    num = 0
    for a in A[1:]:
        if a % n != 0:
            num += 1
            if num == 2:
                break
    else:
        result.append(n)
num = 0
B = A[0:1] + A[2:]
for a in B:
    if a % A[1] != 0:
        num += 1
        if num == 2:
            break
else:
    result.append(A[1])
for n in range(2, int(math.sqrt(A[1])) + 1):
    if A[1] % n != 0:
        continue
    num = 0
    x = A[1] // n
    for a in B:
        if a % x != 0:
            num += 1
            if num == 2:
                break
    else:
        result.append(x)
    num = 0
    for a in B:
        if a % n != 0:
            num += 1
            if num == 2:
                break
    else:
        result.append(n)
if len(result) != 0:
    print((max(result)))
else:
    print((1))