Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

n = int(input())
A = list()
for i in range(0, n):
    A.append(int(input()))

G = [1]  # G[0]????????¨?????????
cnt = 0

# G[i] = 3*Gi-1 + 1
for i in range(1, 100):
    h = 3 * G[i - 1] + 1
    if(h > n):  # h???n?¶???????????????§??????
        m = i
        break
    else:
        G.append(h)


for g in reversed(G):
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v


print(m)
print(" ".join(str(x) for x in reversed(G)))
print(cnt)

print("\n".join(str(x) for x in A))

### FIXED CODE ###

n = int(input())
A = list()
G = [1]
cnt = 0

for i in range(0, n):
    A.append(int(input()))


def insertion_sort(A, n, g):
    global cnt
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j -= g
            cnt += 1
        A[j+g] = v


# G[i] = 3*Gi-1 + 1
def shell_sort():
    for i in range(1, 101):
        h = 3 * G[0] + 1
        if h > n:  # h???n?¶???????????????§?????????4n+3*2n-1+1
            break
        else:
            G.insert(0, h)
    for g in G:
        insertion_sort(A, n, g)

shell_sort()
print(len(G))
print(" ".join(str(x) for x in G))
print(cnt)
print("\n".join(str(x) for x in A))
### BUGGY CODE ###

def main():
    S = list(input())
    ans = 0
    while True:
        for i in range(len(S)-1):
            if S[i] < S[i+1]:
                tmp = S[i+1]
                S[i+1] = S[i]
                S[i] = tmp
                ans += 1
                break
        else:
            break
    print(ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    S = list(input())
    accum = [0]
    for i in range(1,len(S)):
        tmp = accum[i-1] + 1 if S[i-1] == "B" else accum[i-1]
        accum.append(tmp)
    ans = 0
    for i in range(len(S)):
        tmp = 0 if S[i] == "B" else accum[i]
        ans += tmp
    print(ans)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

N=int(input())
A=list(map(int,input().split()))
flag=0
for i in range(N):
  for j in range(i+1,N):
    if A[i]==A[j]:
      flag=1
      
if flag==0:
  print("YES")
else:
  print("NO")

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
if len(A)==len(set(A)):
  print("YES")
else:
  print("NO")
### BUGGY CODE ###

import itertools

N=int(input())
S=[int(input()) for _ in range(N)]
ans=0

for i in range(1,N+1):
  for j in itertools.combinations(S,i):
    s=sum(j)
    if s%10!=0:
      ans=max(ans,s)
print(ans)

### FIXED CODE ###

import sys

N=int(input())
S=[int(input()) for _ in range(N)]
S.sort()
ans=sum(S)

if ans%10!=0:
  print(ans)
  sys.exit()
else:
  for i in range(N):
    if S[i]%10!=0:
      print(ans-S[i])
      sys.exit()
  else:
    print(0)
### BUGGY CODE ###

N,W = map(int,input().split())

w = [-1 for i in range(N)]
v = [-1 for i in range(N)]

for i in range(N):
    w[i],v[i] = map(int,input().split())
    

dp = [[-1 for i in range(W+1)] for j in range(N)]

def rec_dp(i,j):
    #もうない
    if i == N:
        return 0
    #既に調べてある
    if dp[i][j] != -1:
        return dp[i][j]
    #残りの容量が足りない
    elif j<w[i]:
        res = rec_dp(i+1,j)
    else:
        res = max(rec_dp(i+1,j),rec_dp(i+1,j-w[i])+v[i])
    return res

print(rec_dp(0,W))


### FIXED CODE ###

from itertools import accumulate

def chk(samp):
    for i in samp:
        print(samp)

N,W = map(int,input().split())

w = [0 for i in range(N)]
v = [0 for i in range(N)]

for i in range(N):
    w[i],v[i]=map(int,input().split())



#価値毎に置き換える
wl = [[] for i in range(4)]

#価値ごとのりすとに入れていく
for i in range(N):
    wl[w[i]-w[0]].append(v[i])


#ソートして最初に0を追加する。0は選択しない場合
for i in range(4):
    wl[i].sort(reverse = 1)
    wl[i].insert(0,0)
    

#累積和を作る
for i in range(4):
    wl[i] = list(accumulate(wl[i]))
    
#出力用変数
out = 0


for i,wl0 in enumerate(wl[0]):
   for j,wl1 in enumerate(wl[1]):
       for k,wl2 in enumerate(wl[2]):
           for l,wl3 in enumerate(wl[3]):
               if i*(w[0])+j*(w[0]+1)+k*(w[0]+2)+l*(w[0]+3) > W:
                   pass
               else:
                   out = max(out,wl0+wl1+wl2+wl3)
                   
print(out)
### BUGGY CODE ###

# =map(int,input().split())
n,m=map(int,input().split())
a =[list(map(int,input().split())) for i in range(n)]
ans=[]
# print(a)
for i in range(n):
    for k in range(a[i][1]):
        ans.append(a[i][0])
# print(ans)
# ans=[int(i) for i in ans]
# print(ans)
ans.sort()
print(ans[m-1])

### FIXED CODE ###

# =map(int,input().split())
n,m=map(int,input().split())
a =[list(map(int,input().split())) for i in range(n)]
a.sort()
import sys
# ans=dict(a)
# print(a)
cnt=0
for i in range(n):
    z=cnt+a[i][1]
    if z>=m:
        print(a[i][0])
        sys.exit()
    else:
        cnt=z

# print(a)
# for i in range(n):
#     for k in range(a[i][1]):
#         ans.append(a[i][0])
# print(ans)
# ans=[int(i) for i in ans]
# print(ans)
# print(ans[m-1])
### BUGGY CODE ###

import heapq
def SME(start,end):
    count = 0
    ANS = [heapq.heappush(A,[x,i]) for i,x in enumerate(Whole)]
    for j in range(start,end):
        a = heapq.heappop(A)
        if None not in ANS[a[1]:a[1]+L] : continue
        for i in range(L):
            idx = a[1] + i
            try :
                if ANS[idx] : continue
                else :
                    ANS[idx] = a[0]
                    count += 1
            except IndexError : continue
        if count > N * parameter : break
    for i in range(L):
        if ANS[i] : continue
        else : ANS[i] = min(Whole[:i+1])
    for i in range(L,N):
        if ANS[i] : continue
        else : ANS[i] = min(Whole[i+1-L:i+1])
    return ANS
[N,L] = [int(x) for x in input().split()]
Whole = [int(x) for x in input().split()]
A = []
parameter = 0.9997
ANS = [None]*N
ANS = SME(0, N)
for i in ANS[L-1:-1]:print(i, end=" ")
print(ANS[-1])

### FIXED CODE ###

def ascend(a,b):
    mini = min(A[a:a+L])
    ans[a] = mini
    for i in range(a+1,b):
        if A[i+L-1] <= mini : mini = A[i+L-1]
        elif A[i-1] == mini : mini = min(A[i:i+L])
        ans[i] = mini

def descend(a,b):
    mini = min(A[b-1:b+L-1])
    ans[b-1] = mini
    for i in range(b-2,a-1,-1):
        if A[i] <= mini : mini = A[i]
        elif A[i+L] == mini: mini = min(A[i:i+L])
        ans[i] = mini
    
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = [None]*(N-L+1)
count = 0;
if N > 10 ** 4:
    for i in range(100):
        if A[i+1] > A[i] : count += 1
    if count > 80 : descend(0, N-L+1)
    else : ascend(0,N-L+1)
else :
    ascend(0, N-L+1)
for i in ans[:-1] : print(i, end=" ")
print(ans[-1])
### BUGGY CODE ###

from collections import Counter
n=int(input())
l=[]
dfs=[]
ans=[0]*n
for i in range(n):
    s=input()
    m=len(dfs)
    ss=Counter(s)
    for j in range(m):
        if l[j]==ss:
            ans[j]+=1
            break
    l.append(ss)
    dfs.append(i)
    ans[i]+=1
k=len(ans)
answer=0
for i in range(k):
    answer+=ans[i]*(ans[i]-1)//2
    
print(answer)

### FIXED CODE ###

from collections import Counter
n=int(input())
l={}
ans=0
for i in range(n):
  s=input()
  ss=sorted(s)
  s="".join(ss)
  ans+=l.setdefault(s, 0) 
  l[s]+=1
print(ans)
### BUGGY CODE ###

from collections import defaultdict

n = int(input())
s = input()
passwords = defaultdict(int)
for i in range(1000):
    password = "0" * (3 - len(str(i))) + str(i)
    for j in range(n):
        if s[j] == password[0]:
            #print("OK1", password)
            for k in range(j + 1, n):
                if s[k] == password[1]:
                    #print("OK2")
                    for l in range(k + 1, n):
                        if s[l] == password[2]:
                            #print("OK3", password)
                            passwords[password] += 1
                            break
                
                    break
            break

print(len(passwords))

### FIXED CODE ###

N = int(input())
S = input()

ans = 0
for i in range(1000):
    num = str(i).zfill(3)
    if S.find(num[0]) == -1:
        continue
    S1 = S[S.find(num[0]) + 1:]
    if S1.find(num[1]) == -1:
        continue
    S2 = S1[S1.find(num[1]) + 1:]
    if S2.find(num[2]) == -1:
        continue
    ans += 1

print(ans)
### BUGGY CODE ###

N,K=map(int,input().split())
while abs(N-K) < N:
  N = abs(N-K)
print(N)

### FIXED CODE ###

N,K=map(int,input().split())
if N > K:
  N = N%K
print(min(N,abs(N-K)))
### BUGGY CODE ###

a, b, x = map(int, input().split())
for i in range(x):
    if a >= 1:
        a -= 1
    elif b >= 1:
        b -= 1
    else:
        pass
    
print(a, b)

### FIXED CODE ###

a, b, x = map(int, input().split())
if a + b < x:
    a = 0
    b = 0
    print(a, b)
elif a < x:
    b = b - x + a
    a = 0
    print(a, b)
else:
    a = a - x
    print(a, b)
### BUGGY CODE ###

N, K = [int(c) for c in input().split()]
S = [int(c) for c in input()]

longest=0

for bgn_flip in range(len(S)):

    S_copy=S[:]
    zero=False
    icluster=-1
    for i,s in enumerate(S):
        if s==0 and zero==False:
            zero=True
            icluster+=1
        if s==1:
            zero=False

        if s==0 and icluster>=bgn_flip and icluster < bgn_flip+K:
            S_copy[i]=1

    seq=0
    for sc in S_copy:
        if sc==1: seq+=1
        if sc==0: seq=0
        if seq>longest:longest=seq

print(longest)


### FIXED CODE ###

N, K = list(map(int,input().split()))
S = input()

n = 1
c = []
if S[0]=='0': c.append(0)
for i in range(1,N):
    if S[i]!=S[i-1]:
        c.append(n)
        n=1
    else:
        n+=1
c.append(n)
if S[-1]=='0': c.append(0)

t = sum(c[:2*K+1])
m = t
for i in range(2*K+1, len(c), 2):
    t += c[i] + c[i+1] - c[i-(2*K+1)] - c[i+1-(2*K+1)]
    m = max(m,t)

print(m)
### BUGGY CODE ###

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

for i in range(min(k, 50)):
    l = [0] * n
    for j in range(n):
        for k in range(max(0, j-a[j]), min(n, j+a[j]+1)):
            l[k] += 1

    a = l[:]

    if min(a) == n:
        break

a = list(map(str, a))
print(" ".join(a))

### FIXED CODE ###

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

for i in range(min(50, k)):
    DP = [0] * (n+1)
    for j in range(n):
        light = A[j]
        DP[max(0, j-light)] += 1
        DP[min(n, j+light+1)] -= 1

    for j in range(1, n):
        DP[j] += DP[j-1]

    A = DP[:-1]

print(*A)
### BUGGY CODE ###

a=raw_input()
ary=list(a)
count = 0

tmp=""
for i,v in enumerate(ary):
  if v == tmp:
    del(ary[i])
    tmp=v
  else:
    tmp=v

def countStr(arys):
  cW=0
  cB=0
  for i in arys:
    if i == "B":
      cB += 1
    else:
      cW += 1
  return cW, cB

while len(set(ary)) != 1:
  count += 1
  #W, B=countStr(ary)

  
  if ary[len(ary)-1] == "W":
    ary.append("B")
    m = 2
    for i in ary:
      if ary[len(ary)-m] == "W":
        ary[len(ary)-m] = "B"
        m += 1 
      else:
        break
  else:
    ary.append("W")
    m=2
    for i in ary:
      if ary[len(ary)-m] == "B":
        ary[len(ary)-m] = "W"
        m += 1
      else:
        break
  
print count

### FIXED CODE ###

a=raw_input()
ary=list(a)
count = 0

tmp=ary[0]
for i,v in enumerate(ary):
  if v == tmp:
    tmp=v
  else:
    tmp=v
    count += 1

print count
### BUGGY CODE ###

import math
n=int(input())
s=0
for i in range(1,n+1):
    s+=i*((math.floor(n/i)*math.floor(n/i+1))/2)
print (int(s))

### FIXED CODE ###

import math
n=int(input())
s=0
for i in range(1,n+1):
    s+=i*((math.floor(n/i)*math.floor(n/i+1))/2)
print (int(s))
### BUGGY CODE ###

#!/usr/bin/python3.6
import sys
input = sys.stdin.readline
INF = 10**9

a = [int(item) for item in list(input().rstrip())]
n = len(a)
# DP[i-th item][0:pay just / 1:pay over]
dp = [[INF] * 2 for _ in range(n + 1)] 
dp[0][0] = 0

for i, item in enumerate(a):
    dp[i+1][0] = min(dp[i+1][0], dp[i][0] + item, dp[i][1] + item)
    dp[i+1][1] = min(dp[i+1][1], dp[i][0] + 10 - item + 1, dp[i][1] + 10 - item - 1)

print(min(dp[n]))

### FIXED CODE ###

#!/usr/bin/python3.6
import sys
input = sys.stdin.readline
INF = 10**9

a = [int(item) for item in list(input().rstrip())]
n = len(a)
# DP[i-th item][0:pay just / 1:pay over]
dp = [[INF] * 2 for _ in range(n + 1)] 
dp[0][0] = 0

for i, item in enumerate(a):
    dp[i+1][0] = min(dp[i+1][0], dp[i][0] + item, dp[i][1] + item)
    dp[i+1][1] = min(dp[i+1][1], dp[i][0] + 10 - item + 1, dp[i][1] + 10 - item - 1)

print(min(dp[n]))
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from itertools import *
from copy import *

N, W = map(int, input().split())
MV = N * 10**3 + 1
INF = float('inf')
dp1 = [INF] * MV
dp1[0] = 0
for i in range(N):
    dp2 = [INF] * MV
    w, v = map(int, input().split())
    for j in range(MV):
        dp2[j] = min(dp1[j], dp1[j-v]+w)
    dp1 = deepcopy(dp2)
for i in range(MV-1, -1, -1):
    if dp1[i] <= W:
        print(i)
        break


### FIXED CODE ###

import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from itertools import *
from copy import *

N, W = map(int, input().split())
MV = N * 10**3 + 1
INF = float('inf')
dp = [[INF] * MV for i in range(N+1)]
dp[0][0] = 0
for i in range(N):
    w, v = map(int, input().split())
    for j in range(MV):
        if v <= j:
            dp[i+1][j] = min(dp[i][j], dp[i][j-v]+w)
        else:
            dp[i+1][j] = dp[i][j]
dp = dp[N]
for i in range(0, MV)[::-1]:
    if dp[i] <= W:
        print(i)
        break
### BUGGY CODE ###

K = int(input())
S = list(input())
R = []
G = []
B = []
total = 0

for a in range(0,K):
  if S[a]=="R":
    R.append(a)
  elif S[a]=="G":
    G.append(a)
  else :
    B.append(a)

for a in R:
  for b in G:
    for c in B:
      tmp = [a,b,c]
      tmp.sort()
      if tmp[1]-tmp[0] != tmp[2]-tmp[1]:
        total += 1
        #print(tmp)
print(total)

### FIXED CODE ###

K = int(input())
S = list(input())
total = 0
R,G,B = 0,0,0

for a in range(0,K):
  if S[a]=="R":
    R += 1
  elif S[a]=="G":
    G += 1
  else :
    B += 1
    
total = R*G*B

for i in range(0,K):
  for j in range(i,K):
    k = 2*j-i
    if k<K:
      if S[i] != S[k] and S[i] != S[j] and S[j] != S[k]:
        total -= 1
print(total)
### BUGGY CODE ###

N = int(input())

ans = 0
for i in range(1,N):
    ans += i
print(ans)


### FIXED CODE ###

N = int(input())

ans = ((N-1)*N//2)

print(ans)
### BUGGY CODE ###

a, b, k = map(int, input().split())

int_list = [i for i in range(a, b + 1)]
out_list = sorted(int_list[:k] + int_list[-k:])

last_val = 0
for out_val in out_list:
    if last_val != out_val:
        print(out_val)
    last_val = out_val

### FIXED CODE ###

a, b, k = map(int, input().split())

lower_list = [i for i in range(a, a + k)]
upper_list = [i for i in range(b, b - k, -1)]
out_list = sorted(set(lower_list + upper_list))

for out_val in out_list:
    if a <= out_val <= b:
        print(out_val)
### BUGGY CODE ###

n=int(input());c=[0,0,0];x=[1.0/i for i in range(1,n+1)];dp=[[[-1]*(n+2) for i in range(n+2)]for i in range(n+2)]
for i in list(map(int,input().split())):c[i-1]+=1
for k in range(n+1):
  for j in range(n-k+1):
    for i in range(n-k-j+1):
      if i+j+k>0:dp[i][j][k]=(n+dp[i-1][j][k]*i+dp[i+1][j-1][k]*j+dp[i][j+1][k-1]*k)*x[i+j+k-1]
print(dp[c[0]][c[1]][c[2]]+1)

### FIXED CODE ###

n,a=int(input()),map(int,input().split());c=[0]*3
for i in a:c[i-1]+=1
x,y,z=c;dp=[[[None]*(z+2) for i in range(n-x+2)]for i in range(n+2)];dp[0][0][0]=0
for k in range(z+1):
  for j in range(n-x-k+1):
    for i in range(n-k-j+1):
      if i+j+k:dp[i][j][k]=((dp[i-1][j][k]*i if i else 0)+(dp[i+1][j-1][k]*j if j else 0)+(dp[i][j+1][k-1]*k if k else 0)+n)/(i+j+k)
print(dp[x][y][z])
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**5)
readline = sys.stdin.readline
writelines = sys.stdout.writelines
write = sys.stdout.write

N, M = map(int, readline().split())
*A, = map(int, readline().split())

A.sort(reverse=1)
CS = [0,2,5,5,4,5,6,3,7,6]

INV = (None, 0)
EMP = ([], 0)

memo = [[-1]*(N+1) for i in range(M+1)]
mM = memo[M]
mM[0] = EMP
for i in range(1, N+1):
    mM[i] = INV
def dfs(rest, i):
    mi = memo[i]
    if mi[rest] != -1:
        return mi[rest]
    v = A[i]; cost = CS[v]
    r = None
    cnt = 0
    k = 0
    kc = 0
    for k in range((rest // cost) + 1):
        r0, c0 = dfs(rest-k*cost, i+1)
        if r0 is not None:
            cnt0 = k + c0
            if r is None or cnt <= cnt0:
                r = r0
                cnt = cnt0
                kc = k
    if r is None:
        mi[rest] = INV
        return INV
    mi[rest] = res = [kc] + r, cnt
    return res
res, _ = dfs(N, 0)
ans = []
for i in range(M):
    ans.append(str(A[i]) * res[i])
writelines(ans)
write("\n")

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**5)
readline = sys.stdin.readline
writelines = sys.stdout.writelines
write = sys.stdout.write

N, M = map(int, readline().split())
*A, = map(int, readline().split())

A.sort(reverse=1)
CS = [0,2,5,5,4,5,6,3,7,6]

INV = (None, 0)
EMP = ([], 0)

memo = [[-1]*(N+1) for i in range(M+1)]
mM = memo[M]
mM[0] = EMP
for i in range(1, N+1):
    mM[i] = INV
def dfs(rest, i):
    mi = memo[i]
    if mi[rest] != -1:
        return mi[rest]
    v = A[i]; cost = CS[v]
    r = None
    cnt = 0
    k = 0
    kc = 0
    for k in range((rest // cost) + 1):
        r0, c0 = dfs(rest-k*cost, i+1)
        if r0 is not None:
            cnt0 = k + c0
            if r is None or cnt <= cnt0:
                r = r0
                cnt = cnt0
                kc = k
    if r is None:
        mi[rest] = INV
        return INV
    mi[rest] = res = [kc] + r, cnt
    return res
res, _ = dfs(N, 0)
ans = []
for i in range(M):
    ans.append(str(A[i]) * res[i])
writelines(ans)
write("\n")
### BUGGY CODE ###

# -*- coding: utf-8 -*-
n = int(input())
ab = []

for _ in range(n):
    ab.append(tuple(map(int, input().split())))

flag = True
a = 0
b = 0
for _ in range(n):
    if flag:
        ab = sorted(ab, key=lambda x: (x[0], x[1]))
        a += ab.pop()[0]
    else:
        ab = sorted(ab, key=lambda x: (x[1], x[0]))
        b += ab.pop()[1]
    flag = not(flag)

print(a - b)


### FIXED CODE ###

# -*- coding: utf-8 -*-
def select(list_, selected_set):
    while True:
        s = list_.pop()
        if not s[0] in selected_set:
            return s


n = int(input())
ab = []

for i in range(n):
    ai, bi = map(int, input().split())
    ab.append((i, ai, bi))

flag = True
list_a = sorted(ab, key=lambda x: (x[1] + x[2]))
list_b = sorted(ab, key=lambda x: (x[2] + x[1]))
a = 0
b = 0
selected = set()
for _ in range(n):
    s = None
    if flag:
        s = select(list_a, selected)
        a += s[1]
    else:
        s = select(list_b, selected)
        b += s[2]
    selected.add(s[0])

    flag = not(flag)

print(a - b)
### BUGGY CODE ###

n = int(input())
num_list = [int(i) for i in input().split()]
count = 0

while num_list:
    max_num_index = num_list.index(max(num_list))
    for i in range(max_num_index,len(num_list)):
        count += (num_list[max_num_index]-num_list[i])
        num_list[i] = num_list[max_num_index]
    num_list.remove(num_list[max_num_index])

print(count)

### FIXED CODE ###

n = int(input())
num_list = [int(i) for i in input().split()]
count = 0

for i in range(1,n):
    if num_list[i] < num_list[i-1]:
        count += (num_list[i-1] - num_list[i])
        num_list[i] = num_list[i-1]

print(count)
### BUGGY CODE ###

from collections import deque

h,w = map(int,input().split())

matrix = [[1]*(w+2)]
matrix += [[1] + [x == '#' for x in input().rstrip()] + [1] for _ in range(h)]
matrix.append([1]*(w+2))

matrix_list1 = deque()
cnt = -1

for i in range(1,h+1):
    for j in range(1,w+1):
        if matrix[i][j]:
            matrix_list1.append([i,j])

while len(matrix_list1) != 0:     
    for _ in range(len(matrix_list1)):
        x,y = matrix_list1.popleft()
        if not matrix[x+1][y]:
            matrix[x+1][y] = 1
            matrix_list1.append([x+1,y])
        if not matrix[x-1][y]:
            matrix[x-1][y] = 1
            matrix_list1.append([x-1,y])
        if not matrix[x][y+1]:
            matrix[x][y+1] = 1
            matrix_list1.append([x,y+1])
        if not matrix[x][y-1]:
            matrix[x][y-1] = 1
            matrix_list1.append([x,y-1])
    cnt += 1
    
print(cnt)

### FIXED CODE ###

from collections import deque

h,w = map(int,input().split())
matrix = [["a" for _ in range(w+2)]] + [list("a" + input() + "a") for _ in range(h)] + [["a" for _ in range(w+2)]]

matrix_list1 = deque()
cnt = 0

for i in range(1,h+1):
    for j in range(1,w+1):
        if matrix[i][j] == "#":
            matrix_list1.append([i,j])

while len(matrix_list1) != 0:     
    for _ in range(len(matrix_list1)):
        x,y = matrix_list1.popleft()
        if matrix[x+1][y] == ".":
            matrix[x+1][y] = "#"
            matrix_list1.append([x+1,y])
        if matrix[x-1][y] == ".":
            matrix[x-1][y] = "#"
            matrix_list1.append([x-1,y])
        if matrix[x][y+1] == ".":
            matrix[x][y+1] = "#"
            matrix_list1.append([x,y+1])
        if matrix[x][y-1] == ".":
            matrix[x][y-1] = "#"
            matrix_list1.append([x,y-1])
    else:
        if len(matrix_list1) > 0:
            cnt += 1
    
print(cnt)
### BUGGY CODE ###

import sys 
sys.setrecursionlimit(10**6)
s = input()
def dfs(t):
    if t==s:
        return True
    if len(t)>=len(s):
        return False
    if s[len(t)] == 'd':
        for i in ['dream', 'dreamer']:
            if dfs(t+i):
                return True
    elif s[len(t)]:
        for i in ['erase', 'eraser']:
            if dfs(t+i):
                return True
    else:
        return False
if dfs(''):
    print('YES')
else:
    print('NO')

### FIXED CODE ###

import sys 
sys.setrecursionlimit(10**6)
s = input()
def dfs(s):
    while True:
        f = True
        for i in ['erase', 'eraser', 'dream', 'dreamer']:
            if s[-len(i):]==i:
                s = s[:-len(i)]
                if s=='':
                    return True
                f = False
        if f: return False
    
if dfs(s):
    print('YES')
else:
    print('NO')
### BUGGY CODE ###

N = int(input())
S = []
for i in range(N):
  s = list(input())
  s.sort()
  S.append(s)
ans = 0
for i in range(N-1):
  for j in range(i+1,N):
    ans += S[i]==S[j]
print(ans)

### FIXED CODE ###

N = int(input())
S = []
for i in range(N):
  s = list(input())
  s.sort()
  S.append(s)
S.sort()
ans = 0
snt = 1
for i in range(N-1):
  if S[i]==S[i+1]:
    snt += 1
  else :
    ans += (snt*(snt-1))//2 if snt>1 else 0
    snt = 1
ans += (snt*(snt-1))//2 if snt>1 else 0
print(ans)
### BUGGY CODE ###

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

    # divisors.sort()
    return divisors

def main():
    N = int(input())
    A = list(map(int, input().split()))

    res = {}
    for a in A:
        for divisor in divisors(a):
            if divisor not in res:
                res[divisor] = 1
            else:
                res[divisor] += 1

    print(max([key for key, value in res.items() if value == N or value == N - 1]))


if __name__ == '__main__':
    main()

### FIXED CODE ###

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

def main():
    N = int(input())
    A = list(map(int, input().split()))

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

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


if __name__ == '__main__':
    main()