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

from collections import deque
import sys
def main():
    input = sys.stdin.readline
    h, w = map(int, input().split())
    G = [["#"]*(w+2)]+[["#"]+list(map(lambda x: "#" if x == "\n" else x, list(input()))) for i in range(h)]+[["#"]*(w+2)]
    dy, dx = [-1, 1, 0, 0], [0, 0, -1, 1]
    dist = [[-1 for j in range(w+2)] for i in range(h+2)]
    que = deque()
    
    for i in range(1, h+1):
        for j in range(1, w+1):
            if G[i][j] == "#":
                dist[i][j] = 0
                que.append((i, j))
    
    while (len(que) != 0):
        y, x = que[0][0], que[0][1]
        que.popleft()

        for i in range(4):
            ny, nx = y+dy[i], x+dx[i]
            if G[ny][nx] == "#":
                continue
            if dist[ny][nx] == -1:
                dist[ny][nx] = dist[y][x] + 1
                que.append((ny, nx))
    
    ans = 0
    for i in range(1, h + 1):
        for j in range(1, w + 1):
            ans = max(ans, dist[i][j])
    print(ans)
if __name__ == "__main__":
    main()

### FIXED CODE ###

from collections import deque

def main():
    h, w = map(int, input().split())
    G = [["#"]*(w+2)]+[["#"]+list(input())+["#"] for i in range(h)]+[["#"]*(w+2)]
    dy, dx = [-1, 1, 0, 0], [0, 0, -1, 1]
    dist = [[-1 for j in range(w+2)] for i in range(h+2)]
    que = deque()
    
    for i in range(1, h+1):
        for j in range(1, w+1):
            if G[i][j] == "#":
                dist[i][j] = 0
                que.append((i, j))
    
    while (len(que) != 0):
        y, x = que[0][0], que[0][1]
        que.popleft()

        for i in range(4):
            ny, nx = y+dy[i], x+dx[i]
            if G[ny][nx] == "#":
                continue
            if dist[ny][nx] == -1:
                dist[ny][nx] = dist[y][x] + 1
                que.append((ny, nx))
    
    ans = 0
    for i in range(1, h + 1):
        for j in range(1, w + 1):
            ans = max(ans, dist[i][j])
    print(ans)
if __name__ == "__main__":
    main()
### BUGGY CODE ###

ls = [i for i in range(101)]
def comb(n,s,sp):
	if n == 0:
		return 1 if s == 0 else 0
	if sp+n > 100: return 0
	mn,mx = sum(ls[sp:sp+n]),sum(ls[::-1][:n])
	if s < mn or mx < s: return 0
	elif mn == s or mx == s: return 1
	
	sm = 0
	for i in range(sp,101):
		if ls[i] > s:
			break
		sm += comb(n-1,s-ls[i],i+1)
	return sm

while True:
	n,s = map(int, raw_input().split())
	if n == 0: break
	print comb(n,s,0)

### FIXED CODE ###

ls = [[0]*1001 for i in range(10)]
ls[0][0] = 1
for i in range(101):
	for j in range(9,0,-1):
		for k in range(i,1000):
			ls[j][k] += ls[j-1][k-i] 
	

while True:
	n,s = map(int, raw_input().split())
	if n == 0: break
	print ls[n][s]
### BUGGY CODE ###

from fractions import gcd

def answer():
    def make_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

    a, b = map(int, input().split())
    g = gcd(a, b)
    divisors = make_divisors(g)
    set_divisors = set(divisors)

    for div1 in divisors[1:]:
        for div2 in divisors[1:]:
            item = div1*div2
            if item in set_divisors:
                set_divisors.remove(item)

    print(len(set_divisors))


if __name__ == '__main__':
    answer()


### FIXED CODE ###

from fractions import gcd

def answer():
    def make_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

    a, b = map(int, input().split())
    g = gcd(a, b)
    divisors = make_divisors(g)

    length = len(divisors)
    removed = 1

    for i in range(1, length):
        d1 = divisors[i]
        for d2 in divisors[i:-1]:
            if d1 * d2 in divisors:
                divisors.remove(d1*d2)
                removed += 1
        if i + removed >= length:
            break

    print(length - removed + 1)


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

# -*- coding: utf-8 -*-
s = input()

ans = 0
while(True):
    cnt = s.count("ABC")
    if cnt == 0:
        break
    ans += cnt
    s = s.replace("ABC", "BCA")

print(ans)

### FIXED CODE ###

# -*- coding: utf-8 -*-
import re

s = input()
s = s.replace('BC', 'D')

ans = 0
num_a = 0
for char in s:
    if char == 'A':
        num_a += 1
    elif char == 'D':
        ans += num_a
    else:
        num_a = 0

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

s = input()
q = int(input())
pre = 0
reverse = 0
for _ in range(q):
    query = input()
    if query == '1':
        if pre:
            pre = 0
        else:
            pre = 1
        reverse += 1
    else:
        _, f, c = query.split()
        if f == '1':
            if pre == 0:
                s = c + s
            else:
                s = s + c
        else:
            if pre == 1:
                s = c + s
            else:
                s = s + c
if reverse % 2 == 1:
    s = s[::-1]
print(s)

### FIXED CODE ###

from collections import deque
s = input()
queue = deque(list(s))
q = int(input())
pre = 0
reverse = 0
for _ in range(q):
    query = input()
    if query == '1':
        if pre:
            pre = 0
        else:
            pre = 1
        reverse += 1
    else:
        _, f, c = query.split()
        if f == '1':
            if pre == 0:
                # s = c + s
                queue.appendleft(c)
            else:
                # s = s + c
                queue.append(c)
        else:
            if pre == 1:
                # s = c + s
                queue.appendleft(c)
            else:
                # s = s + c
                queue.append(c)
if reverse % 2 == 1:
    queue = reversed(queue)
print(''.join(queue))
### BUGGY CODE ###

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

LR = [map(int, input().split()) for _ in range(K)]
MOD = 998244353
dic = set()
for l, r in LR:
    for i in range(l, r+1):
        dic.add(i)
dic = list(dic)
dp = [0]*(N+1)
dp[1] = 1

for i in range(2, N+1):
    tmp = i-1
    t = [x for x in dic if x <= tmp]
    for s in t:
        dp[i] += dp[i-s]
        dp[i] %= MOD
print(dp[-1])


### FIXED CODE ###

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

    LR = [list(map(int, input().split())) for _ in range(K)]
    MOD = 998244353

    dp = [0]*(N+1)
    S = [0]*(N+1)
    dp[1] = 1
    S[1] = 1

    for i in range(2, N+1):
        for l, r in LR:
            if i-l < 0:
                continue
            else:
                dp[i] += S[i-l] - S[max(i-r-1, 0)]
        dp[i] %= MOD
        S[i] = S[i-1] + dp[i]
    print(dp[-1]%MOD)

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

from collections import deque
import copy
from collections import deque
import copy
h,w=map(int,input().split())
a=[[j=='#' for j in input()] for _ in range(h)]

que=deque([(i,j) for i in range(h) for j in range(w) if a[i][j]])
count=0
while True:
  count+=1
  nque=deque()
  while que:
    y,x=que.popleft()
    if x>0 and not a[y][x-1]:
      a[y][x-1]=True
      nque.append((y,x-1))
    if x<w-1 and not a[y][x+1]:
      a[y][x+1]=True
      nque.append((y,x+1))
    if y>0 and not a[y-1][x]:
      a[y-1][x]=True
      nque.append((y-1,x))
    if y<h-1 and not a[y+1][x]:
      a[y+1][x]=True
      nque.append((y+1,x))
  if nque:
    que=copy.copy(nque)
  else:
    break
print(count-1)

### FIXED CODE ###

from collections import deque
import copy

def main():
    h, w = map(int, input().split())
    a = [[j == "#" for j in input()] for _ in range(h)]


    # スタート地点をqueueに追加
    que = deque([(i, j) for i in range(h) for j in range(w) if a[i][j]])

    count = 0
    while True:
        count += 1
        nque = deque()
        while que:
            y, x = que.popleft()
            if x > 0 and not a[y][x-1]:
                a[y][x-1] = True
                nque.append((y,x-1))
            if x < w-1 and not a[y][x+1]:
                a[y][x+1] = True
                nque.append((y,x+1))
            if y > 0 and not a[y-1][x]:
                a[y-1][x] = True
                nque.append((y-1,x))
            if y < h-1 and not a[y+1][x]:
                a[y+1][x] = True
                nque.append((y+1,x))

        if nque:
            que = copy.copy(nque)
        else:
            break

    print(count - 1)

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

N = int(input())
P = [int(p) for p in input().split()]
# 先頭は必ずカウント
count = 1
for c in range(1, N):
    is_clear = True
    for e in P[:c]:
        if P[c] > e:
            is_clear = False
            break
    if is_clear:
        count += 1
print(count)

### FIXED CODE ###

N = int(input())
count = 0
min_num = N
for c in input().split():
    p = int(c)
    min_num = min(min_num, p)
    if min_num == p:
        count += 1
print(count)
### BUGGY CODE ###

from itertools import accumulate

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

for j in range(k):
    a01 = [0] * (n + 1)
    for i, ai in enumerate(a):
        l, r = max(0, i - ai), min(i + ai + 1, n)
        a01[l] += 1
        a01[r] -= 1
    a = list(accumulate(a01))[:-1]
    if all(ai == n for ai in a):
        break
print(*a)


### FIXED CODE ###

from itertools import accumulate
from math import log2

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

for j in range(k):
    a01 = [0] * (n + 1)
    for i, ai in enumerate(a):
        l, r = max(0, i - ai), min(i + ai + 1, n)
        a01[l] += 1
        a01[r] -= 1
    a = list(accumulate(a01))
    if all(ai == n for ai in a[:-1]):
        break
print(*a[:-1])
### BUGGY CODE ###

if __name__ == '__main__':
    n,x,y = map(int, input().split())
    costList = [0]*n

    for i in range(n):
        for j in range(n):
            minCost = min(abs(i-j),abs( x-i-1) +abs(y-j-1)+1,abs( y-i-1) +abs(x-j-1)+1 )
            costList[minCost] = costList[minCost]+1


    for i in range(n):
        if i >0:
            print(costList[i]//2)

### FIXED CODE ###

import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

if __name__ == '__main__':
    n,x,y = map(int, input().split())
    costList = [0]*n

    for i in range(1, n):
        for j in range(i+1, n+1):
            if j > i:
                minCost = min(abs(i-j),abs( x-i) +abs(y-j)+1,abs( y-i) +abs(x-j)+1 )
                costList[minCost] +=1


    for i in range(n):
        if i >0:
            print(costList[i])
### BUGGY CODE ###

k, s = [int(i) for i in input().split()]
print([a + b + c == s for a in range(k + 1) for b in range(k + 1) for c in range(k + 1)].count(True))

### FIXED CODE ###

k, s = [int(i) for i in input().split()]
print([0 <= s-i-j <= k for i in range(k+1) for j in range(k+1)].count(True))
### BUGGY CODE ###

n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
f = sorted(list(map(int, input().split())), reverse=True)


def test(x):
    cost = 0
    for i, j in zip(a, f):
        cost += max(0, i - x // j)
    return cost <= k


left = -1
right = 10**12
while left+1 < right:
    mid = (left+right)//2
    if test(mid):
        right = mid
    else:
        left = mid

print(right)

### FIXED CODE ###

import numpy as np
n, k = map(int, input().split())
a = np.array(sorted(list(map(int, input().split()))))
f = np.array(sorted(list(map(int, input().split())), reverse=True))


def test(x):
    cost = np.maximum(0, a-x//f).sum()
    return cost <= k


left = -1
right = 10**12
while left+1 < right:
    mid = (left+right)//2
    if test(mid):
        right = mid
    else:
        left = mid

print(right)
### BUGGY CODE ###

import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
 
from functools import reduce
# from math import *
from fractions import *
H, W = map(int, readline().split())
S = [0 for i in range(H)]
for i in range(H):
    S[i] = readline().decode().strip()

def bfs(start, goal, H, W):
    visited = [False for _ in range(H * W)]
    import queue
    q = queue.Queue()
    q.put((start[0], start[1], 0))
    while not q.empty():
        (i, j, dist) = q.get()
        if (i, j) == goal:
            return dist
        for dy in range(-1, 2):
            for dx in range(-1, 2):
                if dx * dy != 0 or dx == dy:
                    continue
                if i + dy < 0 or i + dy >= H or j + dx < 0 or j + dx >= W:
                    continue
                if S[i + dy][j + dx] == '#':
                    continue
                if visited[(i + dy) * W + j + dx]:
                    continue
                q.put((i + dy, j + dx, dist + 1))
    return -1

ans = 0
for i in range(H * W):
    start = (i // W, i % W)
    if S[start[0]][start[1]] == '#':
        continue
    for j in range(H * W):
        goal = (j // W, j % W)
        if S[goal[0]][goal[1]] == '#':
            continue
        if start == goal:
            continue
        ans = max(ans, bfs(start, goal, H, W))
print(ans)


### FIXED CODE ###

import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
 
from functools import reduce
# from math import *
from fractions import *
H, W = map(int, readline().split())
S = [0 for i in range(H)]
for i in range(H):
    S[i] = readline().decode().strip()

from collections import deque
def bfs(start, H, W):
    INF = 10 ** 9
    dist = [INF] * (H * W)
    q = deque([start])
    dist[start[0] * W + start[1]] = 0
    while q:
        (i, j) = q.popleft()
        d = dist[i * W + j]
        for dy in range(-1, 2):
            for dx in range(-1, 2):
                if dx * dy != 0:
                    continue
                if dx == dy:
                    continue
                if i + dy < 0 or i + dy >= H or j + dx < 0 or j + dx >= W:
                    continue
                if S[i + dy][j + dx] == '#':
                    continue
                if dist[(i + dy) * W + j + dx] != INF:
                    continue
                dist[(i + dy) * W + j + dx] = d + 1
                q.append((i + dy, j + dx))
    return max(x for x in dist if x < INF)

ans = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            continue
        start = (i, j)
        ans = max(ans, bfs(start, H, W))
print(ans)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = [a[i] - b[i] for i in range(n)]
c.sort()
k = 0
neg = 0

if sum(a) < sum(b):
  print(-1)
else:
  k = sum(x < 0 for x in c)
  neg = sum(c[:k])
  
  if k == 0:
    print(0)
  else:
    for i in range(n):
      if sum(c[len(c) - 1 - i:]) >= abs(neg):
        print(k + i + 1)
        break

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = sorted([a[i] - b[i] for i in range(n)])
k = sum(x < 0 for x in c)
neg = -sum(c[:k])
pos = c[len(c) - 1]

if sum(c) < 0:
  print(-1)
elif k == 0:
  print(0)
else:
  for i in range(n):
    if pos >= neg:
      print(k + i + 1)
      break
    else: pos += c[len(c) - 2 - i]
### BUGGY CODE ###

# import bisect
# # import heapq
# # from copy import deepcopy
from collections import deque
# # from collections import Counter
# # from itertools import accumulate
# # from itertools import permutations
# import numpy as np
# # import math

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

friend =[[] for _ in range(n)]
block = [[] for _ in range(n)]
for i in range(m):
    a,b = map(int, input().split())
    a,b = a-1,b-1
    friend[a].append(b); friend[b].append(a)

for i in range(k):
    c,d = map(int, input().split())
    c,d = c-1,d-1
    block[c].append(d); block[d].append(c)

def suggest(s):
    count = 0
    seen = [False] * n
    que = deque([s])
    while que:
        start = que.pop()
        seen[start] = True
        for i in friend[start]:
            if seen[i]: continue
            else:
                que.append(i)

    for i in range(n):
        if i != s and seen[i] and (i not in friend[s]) and (i not in block[s]):
            count += 1

    return count

for i in range(n):
    print(suggest(i))





### FIXED CODE ###

# import bisect
# # import heapq
# # from copy import deepcopy
from collections import deque
# # from collections import Counter
# # from itertools import accumulate
# # from itertools import permutations
# import numpy as np
# # import math

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

class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -self.parents[self.find(x)]

uf = UnionFind(n)
friend =[[] for _ in range(n)]
block = [[] for _ in range(n)]
for i in range(m):
    a,b = map(int, input().split())
    a,b = a-1,b-1
    uf.union(a,b)
    friend[a].append(b); friend[b].append(a)

for i in range(k):
    c,d = map(int, input().split())
    c,d = c-1,d-1
    if uf.same(c,d):
        block[c].append(d); block[d].append(c)

w = [0] * n
for i in range(n):
    w[i] = uf.size(i) - len(friend[i]) - len(block[i]) - 1

print(*w)
### BUGGY CODE ###

def f():
    import sys
    input=sys.stdin.readline
    n,m=[int(i) for i in input().split()]
    s=[int(i) for i in input().split()]
    t=[int(i) for i in input().split()]
    mod=10**9+7
    dp=[[0]*(m+1) for i in range(n+1)]
    dp[0][0]=1
    for i in range(n+1):
        for j in range(m+1):
            if i!=0:
                dp[i][j]+=dp[i-1][j]
            if j!=0:
                dp[i][j]+=dp[i][j-1]
            if i!=0 and j!=0:
                if s[i-1]!=t[j-1]:
                    dp[i][j]-=dp[i-1][j-1]
            dp[i][j]%=mod
    print(dp[-1][-1])


f()


### FIXED CODE ###

n,m=[int(i) for i in input().split()]
s=[int(i) for i in input().split()]
t=[int(i) for i in input().split()]
mod=10**9+7
dp=[[0]*(m+1) for i in range(n+1)]
dp[0][0]=1
for i in range(n+1):
    for j in range(m+1):
        if i!=0:
            dp[i][j]+=dp[i-1][j]
        if j!=0:
            dp[i][j]+=dp[i][j-1]
        if i!=0 and j!=0:
            if s[i-1]!=t[j-1]:
                dp[i][j]-=dp[i-1][j-1]
        dp[i][j]%=mod
print(dp[-1][-1])
### BUGGY CODE ###

N,K=list(map(int,input().split()))
dp_list=[None]*N
h=list(map(int,input().split()))
dp_list[0]=0
for i in range(0,N):
    for j in range(1,K+1):
        j=i+j
        if j<N:
            if dp_list[j] is None:dp_list[j]=abs(h[j]-h[i])+dp_list[i]
            else:dp_list[j]=min(dp_list[j],abs(h[j]-h[i])+dp_list[i])
print(dp_list[-1])



### FIXED CODE ###

import numpy as np
N,K=list(map(int,input().split()))
dp_list=np.full(N,10**10,dtype=int)
h=list(map(int,input().split()))
h=np.array(h)
dp_list[0]=0
for i in range(1,N):
        dp_list[i:i+K] = np.fmin(dp_list[i:i+K], dp_list[i-1] + np.abs(h[i:i+K] - h[i-1]))
print(dp_list[-1])
### BUGGY CODE ###

import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def prime_factorization(n):
    res = []
    for i in range(2, int(pow(n, 0.5)) + 1):
        if n % i == 0:
            ex = 0
            while n % i == 0:
                ex += 1
                n //= i
            res.append([i, ex])
    if n != 1:
        res.append([n, 1])
    return res


def resolve():
    n = int(input())
    A = list(map(int, input().split()))

    prime = [0] * max(A)
    for a in A:
        primes = prime_factorization(a)
        for num, ex in primes:
            prime[num - 1] = max(prime[num - 1], ex)

    L = 1
    for i in range(len(prime)):
        if prime[i] == 0:
            continue
        L *= pow(i + 1, prime[i])

    res = 0
    for a in A:
        res += L // a
        res %= mod
    print(res)


if __name__ == '__main__':
    resolve()


### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def prime_factorization(n):
    res = []
    for i in range(2, int(pow(n, 0.5)) + 1):
        if n % i == 0:
            ex = 0
            while n % i == 0:
                ex += 1
                n //= i
            res.append([i, ex])
    if n != 1:
        res.append([n, 1])
    return res


def resolve():
    n = int(input())
    A = list(map(int, input().split()))

    prime = [0] * max(A)
    for a in A:
        primes = prime_factorization(a)
        for num, ex in primes:
            prime[num - 1] = max(prime[num - 1], ex)

    L = 1
    for i in range(len(prime)):
        if prime[i] == 0:
            continue
        L *= pow(i + 1, prime[i])

    res = 0
    for a in A:
        res += L * pow(a, mod - 2, mod)
        res %= mod
    print(res)


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

N = int(input())
A = sorted(list(map(int,input().split())))
def gcd(L):
    
    
    minb = L[0]
    while True:
        NL = []
        #print(L)
        rs = 0
        minb = L[0]
        for l in L:
            r = l % minb
            if r != 0:
                NL.append(r)
                rs += r
        NL.append(minb)
        L = NL
        
        if rs == 0:
            return minb

max = 0
for i in range(1,len(A)+1):
    g = gcd(A[0:i-1]+A[i:])
    #print(i,g,(A[0:i-1]+A[i:]))
    if max < g:
        max = g
print(max)


### FIXED CODE ###

N = int(input())
A = sorted(list(map(int,input().split())))
def gcdaaaaaaaaa(L):
    nextminb = L[0]
    nextn = len(L)
    while True:
        n = nextn
        minb = nextminb
        for l in L[:n]:
            nextn = 0
            r= l % minb
            
            if r != 0:
                L[nextn] = r
                nextn += 1
                if r < nextminb :
                    nextminb = r
        if minb == nextminb:
            return minb
        
def gcd(a,b):
    r = a % b
    if r == 0:
        return b
    else:
        return gcd(b,r)
def gcdL(L):
    g = L[0]
    for l in L:
        g = gcd(g,l)
    return g



lgcd = [0] * N
rgcd = [0] * N

lg = A[0]
rg = A[-1]
for i in range(N):
    
    lg = gcd(lg,A[i])
    lgcd[i] = lg
    rg = gcd(rg,A[N-i-1])
    rgcd[N-i-1] = rg
    
maxg = max(lgcd[N-2],rgcd[1])
for i in range(1,N-1):
    g = gcd(lgcd[i-1],rgcd[i+1])
    if maxg < g:
        maxg = g

print(maxg)
### BUGGY CODE ###

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

s=set(a)
count=0

for i in s:
    if a.count(i)-i<0:
        count+=a.count(i)
    else:
        count+=a.count(i)-i
print(count)

### FIXED CODE ###

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

a=sorted(a)
s=set(a)
count=0

base=0
judge=0

for i in a:
    if base!=i:
        #print(judge,base)
        if judge>=base:
            count+=judge-base
        else:
            count+=judge
        base=i
        judge=1
    else:
        judge+=1
if judge>=base:
    count+=judge-base
else:
    count+=judge


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

S = list(input())
count = 0

tmpJ = 0
for i in range(len(S)):
  if S[i] == 'W':
    for j in range(tmpJ,i):
      if S[j] == 'B':
        tmpJ = j + 1
        S[i] = 'B'
        count += (i-j)
        break
print(count)

### FIXED CODE ###

S = list(input())
count = 0
valueA = 0
for i in range(len(S)):
  if S[i] == 'B':
    count += 1
    valueA += i

valueB = 0
for i in range(count):
  valueB += (len(S) - 1 - i)
  
print(valueB - valueA)