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

import sys
import numpy as np

rl = sys.stdin.readline

n, k = map(int, rl().split())

li = list(map(int, rl().split()))

dp = np.full(n, float('inf'))

dp[0] = 0
dp[1] = abs(li[0] - li[1])

if k < n:    
    for i in range(2, k):
        for j in range(i):
            a = dp[j] + abs(li[j] - li[i])
            if dp[i] > a:
                dp[i] = a
    for i in range(k, n):
        for j in range(i-k, i):
            a = dp[j] + abs(li[j] - li[i])
            if dp[i] > a:
                dp[i] = a
else:
    for i in range(n):
        for j in range(i):
            a = dp[j] + abs(li[j] - li[i])
            if dp[i] > a:
                dp[i] = a
        
print(int(dp[-1]))




### FIXED CODE ###

import sys

rl = sys.stdin.readline

n, k = map(int, rl().split())

li = list(map(int, rl().split()))

dp = [1<<60]*n

dp[0] = 0
dp[1] = abs(li[0] - li[1])

if k < n:    
    for i in range(2, k):
        for j in range(i):
            a = dp[j] + abs(li[j] - li[i])
            if dp[i] > a:
                dp[i] = a
    for i in range(k, n):
        for j in range(i-k, i):
            a = dp[j] + abs(li[j] - li[i])
            if dp[i] > a:
                dp[i] = a
else:
    for i in range(n):
        for j in range(i):
            a = dp[j] + abs(li[j] - li[i])
            if dp[i] > a:
                dp[i] = a
        
print(int(dp[-1]))
### BUGGY CODE ###

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

a = sorted(a)
f = sorted(f,reverse = True)

hq = []

upper_limit = int(1e+12)
lower_limit = int(0)

def is_ok(checking):
    cost = 0
    for i in range(n):
        cost += max(0,math.ceil((a[i]*f[i]-checking)/f[i]))
    if cost <= k:
        return True
    else:
        return False

def meguru_bisect(ng, ok):
    while (abs(ok-ng)>1):
        mid = (ok+ng)//2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok

ok = meguru_bisect(-1, 1e+20) 
print(int(ok))
# 初期値の範囲は取りえる値-1～+1とする←範囲内はok,ngどちらもあり得るため

### FIXED CODE ###

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

a = sorted(a)
f = sorted(f,reverse = True)

hq = []

def is_ok(checking):
    cost = 0
    for i in range(n):
        cost += max(0,math.ceil((a[i]*f[i]-checking)/f[i]))
    if cost <= k:
        return True
    else:
        return False

def meguru_bisect(ng, ok):
    while (abs(ok-ng)>1):
        mid = (ok+ng)//2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok

ok = meguru_bisect(-1, 1e+12+1) 
print(int(ok))
# 初期値の範囲は取りえる値-1～+1とする←範囲内はok,ngどちらもあり得るため
### BUGGY CODE ###

import math

K=int(input())
sum=0

for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      sum+=math.gcd(math.gcd(i,j),k)

        
print(sum)

### FIXED CODE ###

import math

K=int(input())
sum=0

for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      sum+=math.gcd(math.gcd(i,j),k)

        
print(sum)
### BUGGY CODE ###

h, w = map(int, input().split())
# 壁あり
A = [['#'] * (w + 2)] +  [['#'] + list(input()) + ['#'] for _ in range(h)] + [['#'] * (w + 2)]

from copy import deepcopy

dxdy = [[1, 0], [-1, 0], [0, 1], [0, -1]]
cnt = 0
while True:
    cnt_white = sum([e.count('.') for e in A])
    if cnt_white == 0:
        break
    B = deepcopy(A)
    for i in range(1, h + 1):
        for j in range(1, w + 1):
            if A[i][j] == '#':
                for x, y in dxdy:
                    B[i + x][j + y] = '#'
    A = deepcopy(B)
    cnt += 1

print(cnt)

### FIXED CODE ###

H, W = map(int, input().split())
# 壁あり
A = [['#'] * (W + 2)] +  [['#'] + list(input()) + ['#'] for _ in range(H)] + [['#'] * (W + 2)]

visited = [[True] * (W + 2) for _ in range(H + 2)]
for h in range(1, H + 1):
    for w in range(1, W + 1):
        if A[h][w] == '.':
            visited[h][w] = False

que = []
for h in range(1, H + 1):
    for w in range(1, W + 1):
        if visited[h][w]:
            que.append((h, w))

res = -1
while que:
    q = []
    res += 1
    for dx, dy in [(0, 1), (0, -1), (1, 0), (-1, 0)]:
        for x, y in que:
            nx, ny = x + dx, y + dy
            if not visited[nx][ny]:
                visited[nx][ny] = True
                q.append((nx, ny))
    que = q

print(res)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

def main():
  h, w = map(int, input().split())
  S = [input().rstrip() for _ in range(h)]
  L = [[0]*w for _ in range(h)]
  R = [[0]*w for _ in range(h)]
  U = [[0]*w for _ in range(h)]
  D = [[0]*w for _ in range(h)]
  for i in range(h):
    for j in range(w):
      if j > 0:
        if S[i][j-1] == ".":
          L[i][j] = L[i][j-1]+1
        if S[i][w-j] == ".":
          R[i][w-1-j] = R[i][w-j]+1
      if i > 0:
        if S[i-1][j] == ".":
          U[i][j] = U[i-1][j]+1
        if S[h-i][j] == ".":
          D[h-1-i][j] = D[h-i][j]+1
  ans = 0
  for i in range(h):
    for j in range(w):
      if S[i][j] == ".":
        temp = L[i][j]+R[i][j]+U[i][j]+D[i][j]+1
        ans = max(ans, temp)
  print(ans)

if __name__ == "__main__":
  main()

### FIXED CODE ###

MOD = 10**9+7
h, w = map(int, input().split())
S = [input() for _ in range(h)]
L = [[0]*w for _ in range(h)]
R = [[0]*w for _ in range(h)]
U = [[0]*w for _ in range(h)]
D = [[0]*w for _ in range(h)]
for i in range(h):
  for j in range(w):
    if j > 0:
      if S[i][j-1] == ".":
        L[i][j] = L[i][j-1]+1
      if S[i][w-j] == ".":
        R[i][w-1-j] = R[i][w-j]+1
    if i > 0:
      if S[i-1][j] == ".":
        U[i][j] = U[i-1][j]+1
      if S[h-i][j] == ".":
        D[h-1-i][j] = D[h-i][j]+1
ans = 0
for i in range(h):
  for j in range(w):
    if S[i][j] == ".":
      temp = L[i][j]+R[i][j]+U[i][j]+D[i][j]+1
      ans = max(ans, temp)
print(ans)
### BUGGY CODE ###

k=int(input())
import math
cnt=0
for a in range(1,k+1):
    for b in range(1,k+1):
        for c in range(1,k+1):
            cnt+=math.gcd(math.gcd(a,b),c)
print(cnt)


### FIXED CODE ###

k=int(input())
import math
if k==1:
    print(1)
else:
    s1=k*(k+1)//2
    s2=k-1
    for i in range(2,k):
        for j in range(i+1,k+1):
                s2+=math.gcd(i,j)
    s2=s2*6
    s3=0
    if k>2:
        for a in range(1,k-1):
            for b in range(a+1,k):
                for c in range(b+1,k+1):
                    s3+=math.gcd(math.gcd(a,b),c)
        s3=s3*6
    print(s1+s2+s3)
### BUGGY CODE ###

import numpy as np
h,w,a,b = map(int,input().split())
x = np.array([1]*a + [-1]*(w-a), int)
y = np.array([1]*b + [-1]*(h-b), int).reshape(-1,1)
m = x * y
#print(m)
m *= m > 0
#print(m)
for row in m:
  print(*row, sep='')

### FIXED CODE ###

h,w,a,b = map(int,input().split())
x = '1'*a + '0'*(w-a)
xinv = '0'*a + '1'*(w-a)
for i in range(h):
  row = x if i < b else xinv
  print(row)
### BUGGY CODE ###

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

def make_divisors(n: int):
    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)
    return divisors

from collections import defaultdict
m = defaultdict(int)

for i in range(N):
    divisors = make_divisors(A[i])
    for d in divisors:
        m[d] += 1

ans = 1
for k, v in sorted(m.items(), key=lambda x: x[0]):
    if v >= N-1 and ans < k:
        ans = k

print(ans)

### FIXED CODE ###

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

from fractions import gcd
left = [A[0]]
right = [A[-1]]

for i in range(1, N-1):
    left.append(gcd(left[-1], A[i]))
    right.append(gcd(right[-1], A[-1-i]))

ans = 1
for i in range(N):
    if i == 0:
        tmp = right[-1]
    elif i == N-1:
        tmp = left[-1]
    else:
        tmp = gcd(left[i-1], right[N-2-i])
    ans = max(ans, tmp)

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

N = int(input())
listh = list(map(int, input().split()))
#print(listh)
lista = []
count = -1
rem = 0
for n in range(N):
    hi = listh[n]
    if rem >= hi:
        lista.append(count)
        rem = hi
    else:
        count = count + 1
        lista.append(count) 
        rem = hi
#print(lista)  
A = lista[N-1]
listans = []
for a in range(A+1):
    ans = lista.count(a)
    listans.append(ans)    
#print(listans)    
ans = max(listans)
print(ans-1)


### FIXED CODE ###

N = int(input())
listh = list(map(int, input().split()))
#print(listh)
lista = [0]
count = 0
for n in range(1,N):
    if listh[n] > listh[n-1]:
        count = 0
        lista.append(count)
    else:
        count = count + 1
        lista.append(count) 
#print(lista)        
print(max(lista))
### BUGGY CODE ###

t = int(input())
A = [list(map(int, input().split())) for _ in range(t)]
for i in range(t):
    state = True
    a,b,c,d = A[i]
    keep = []
    keep.append(a)
    if a < b:
        state = False
    else:
        a -= b
        if a <= c:
            a += d
        keep.append(a)
        while True:
            if a < b:
                state = False
                break
            a -= b
            if a <= c:
                a += d
            if a in keep:
                if keep[keep.index(a)-1] == keep[-1]:
                    break
            keep.append(a)
    if state:
        print('Yes')
    else:
        print('No')


### FIXED CODE ###

from fractions import gcd
n = int(input())
A = [list(map(int, input().split())) for _ in range(n)]
for i in range(n):
    a,b,c,d = A[i]
    g = gcd(b,d)
    if a < b or b > d or b-g+(a%g)>c:
        print('No')
    else:
        print('Yes')
### BUGGY CODE ###

import itertools
import sys
import math
import numpy as np
from collections import deque
from itertools import combinations
from functools import reduce
from functools import lru_cache
sys.setrecursionlimit(10**9)

def main():
    S = input()
    Q = int(input())

    head = []
    tail = []
    def insert(s,type):
        if type == 1:
            head.insert(0,s)
        else:
            tail.append(s)

    non_reverse = True
    for _ in range(Q):
        inp = input()
        if inp == "1":
            non_reverse = not non_reverse
        else:
            _,F,C = inp.split()
            F = int(F)
            if non_reverse:
                insert(C,F)
            else:
                insert(C,1 if F == 2 else 2)

    S = "".join(head) + S + "".join(tail)
    if non_reverse:
        print(S)
    else:
        print(S[::-1])



if __name__ == "__main__":
  main()

### FIXED CODE ###

import itertools
import sys
import math
import numpy as np
from collections import deque
from itertools import combinations
from functools import reduce
from functools import lru_cache
from collections import deque
sys.setrecursionlimit(10**9)

def main():
    S = input()
    Q = int(input())
    d = deque(list(S))
    rev = False

    def insert(x,f):
        g = f == "2" # append
        if rev:
            g = not g

        if g:
            d.append(x)
        else:
            d.appendleft(x)


    for q in range(Q):
        inp = input()
        if inp == "1":
            rev = not rev
        else:
            _,F,C = inp.split()
            insert(C,F)


    if rev:
        d.reverse()

    print("".join(d))



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

import sys
sys.setrecursionlimit(1000000000)
from collections import defaultdict

ans=[]
V=defaultdict(list)

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

a,b=map(int,input().split())
V[a].append(b)
V[b].append(a)
ans.append(a)
ans.append(b)

for i in range(1,M):
  a,b=map(int,input().split())
  V[a].append(b)
  V[b].append(a)

def solve(li):
  s=li[0]
  e=li[-1]
  for v in V[s]:
    if not(v in li):
      return solve([v]+li)
  for v in V[e]:
    if not(v in li):
      return solve(li+[v])
  print(len(li))
  print(*li)
  return

solve(ans)


### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000000)

from collections import defaultdict
N, M = [int(_) for _ in input().split()]
V = defaultdict(list)
for i in range(M):
    A, B = [int(_) for _ in input().split()]
    V[A].append(B)
    V[B].append(A)

def solve(N, M, V):
    result = [1, V[1][0]]
    used = [False] * (N + 1)
    for x in result:
        used[x] = True

    def check_edge(i):
        for e in V[result[i]]:
            if not used[e]:
                if i == -1:
                    result.append(e)
                else:
                    result.insert(i, e)
                used[e] = True
                return True
        return False

    while True:
        if check_edge(0): continue
        if check_edge(-1): continue
        return result

result = solve(N, M, V)
print(len(result))
print(*result)
### BUGGY CODE ###

N=int(input())
A=list(map(int,input().split()))
dp=[0]*61
for i in range(N):
  a=len(bin(A[i]))-2
  for j in range(a):
    if A[i]>>j&1==1:
      dp[j]+=1
ans=0
mod=10**9+7
for i in range(60,-1,-1):
  
  ans+=pow(2,i)*dp[i]*(N-dp[i])
  ans%=mod
print(ans)

### FIXED CODE ###

def main():
  N=int(input())
  A=list(map(int,input().split()))
  mod=10**9+7
  ans=0
  for i in range(60):
    c=0
    for j in A:
      if j>>i&1:
        c+=1
    ans+=pow(2,i,mod)*c*(N-c)
    ans%=mod
  print(ans)
if __name__=='__main__':
  main()
### BUGGY CODE ###

import math

n = int(input())
i = int(math.sqrt(n))
while i<=n:
  if n%i==0:
    print(len(str(i)))
    break
  i+=1


### FIXED CODE ###

import math

n = int(input())
i = int(math.sqrt(n))
while i>0:
  if n%i==0:
    print(len(str(int(n/i))))
    break
  i-=1
### BUGGY CODE ###

# coding: utf-8
# Your code here!
def main():
    import math
    h,n = map(int, input().split())
    aa = [None for _ in range(n+1)]
    bb = [None for _ in range(n+1)]
    mp = [[None for _ in range(n+1)] for _ in range(h+1)]
    # 体力i 技の種類j
    for j in range(1, n+1):
      aa[j], bb[j] = map(int, input().split())
    for i in range(1, h+1):
        mp[i][0] = float("inf")
    for j in range(1, n+1):
        for i in range(1, h+1):
            if i - aa[j] >= 1:
              # print(i, j, i - aa[j])
              mp[i][j] = min(mp[i][j-1], mp[i - aa[j]][j] + bb[j])
            else:
              mp[i][j] = min(mp[i][j-1], bb[j])
    print(mp[h][n])

if __name__ == '__main__':
    main()

### FIXED CODE ###

# coding: utf-8
# Your code here!
def main():
    import math
    h,n = map(int, input().split())
    aa = [0]*(n+1)
    bb = [0]*(n+1)
    mp = [[None for _ in range(n+1)] for _ in range(h+1)]
    # 体力i 技の種類j
    for j in range(1, n+1):
      mp[0][j] = 0
      aa[j], bb[j] = map(int, input().split())
    for i in range(1, h+1):
        mp[i][0] = float("inf")
    for j in range(1, n+1):
        for i in range(1, h+1):
        	mp[i][j] = min(mp[i][j-1], mp[max(0, i - aa[j])][j] + bb[j])
    print(mp[h][n])

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

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

A = []
#B = []
for i in range(N):
#    print(i)
#    a, b = map(int, input().split())
    A.append(list(map(int, input().split())))
#    B.append(b)
    
    A.sort(key=lambda x: x[0])

ans = 0
for i in range(N):
    if A[i][1] > M:
        ans += A[i][0] * M
        break
    else:
        ans += A[i][0] * A[i][1]
        M -= A[i][1]

print(ans)

### FIXED CODE ###

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

A = []
#B = []
for i in range(N):
#    print(i)
#    a, b = map(int, input().split())
    A.append(list(map(int, input().split())))
#    B.append(b)
    
A.sort(key=lambda x: x[0])

ans = 0
for i in range(N):
    if A[i][1] > M:
        ans += A[i][0] * M
        break
    else:
        ans += A[i][0] * A[i][1]
        M -= A[i][1]

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

if __name__ == '__main__':
	N, X, Y = map(int, input().split())

	ans = 0

	for k in range(1,N):
		ans = 0
		for i in range(1,N):
			for j in range(i+1,N+1):
				l1 = abs(j-i)
				l2 = abs(X-i) + 1 + abs(j-Y)
				l3 = abs(Y-i) + 1 + abs(j-X)

				lm = min(l1,l2,l3)

				if lm == k:
					ans += 1

		print(ans)

### FIXED CODE ###

if __name__ == '__main__':
	N, X, Y = map(int, input().split())

	ans = [0] * (N - 1)

	for i in range(1,N):
		for j in range(i+1,N+1):
			l1 = abs(j-i)
			l2 = abs(X-i) + 1 + abs(j-Y)
			lm = min(l1,l2)
			ans[lm - 1] += 1

	for k in range(N-1):
		print(ans[k])
### BUGGY CODE ###

#直径が答えになるわけではない

N = int(input())
S = [list(map(int, input())) for _ in range(N)]

# for s in S:
#     print (s)

lst = [0] * N
lst[0] = 1

stack = [0]
flag = True
while len(stack) != 0:
    tmp = stack.pop()
    for index, x in enumerate(S[tmp]):
        if x == 0:
            continue
        if lst[index] == 0:
            lst[index] = -lst[tmp]
            stack.append(index)
        else:
            if lst[tmp] == -lst[index]:
                pass
            else:
                flag = False
                break
    if not flag:
        print (-1)
        exit()

INF = 10 ** 9
for i in range(N):
    for j in range(N):
        if S[i][j] == 0 and i != j:
            S[i][j] = INF

for k in range(N):
    for i in range(N):
        for j in range(N):
            S[i][j] = min(S[i][j], S[i][k] + S[k][j])
            
ans = 0
for i in range(N):
    for j in range(N):
        ans = max(S[i][j], ans)

print (ans + 1)

### FIXED CODE ###

#直径が答えになるわけではない

N = int(input())
S = [list(map(int, input())) for _ in range(N)]

# for s in S:
#     print (s)

lst = [0] * N
lst[0] = 1

stack = [0]
flag = True
while len(stack) != 0:
    tmp = stack.pop()
    for index, x in enumerate(S[tmp]):
        if x == 0:
            continue
        if lst[index] == 0:
            lst[index] = -lst[tmp]
            stack.append(index)
        else:
            if lst[tmp] == -lst[index]:
                pass
            else:
                flag = False
                break
    if not flag:
        print (-1)
        exit()

INF = 10 ** 9
for i in range(N):
    for j in range(N):
        if S[i][j] == 0 and i != j:
            S[i][j] = INF

for k in range(N):
    for i in range(N):
        for j in range(N):
            S[i][j] = min(S[i][j], S[i][k] + S[k][j])
            
ans = 0
for i in range(N):
    for j in range(N):
        ans = max(S[i][j], ans)

print (ans + 1)
### BUGGY CODE ###


def Cf(n):
    if n == 1:
        return 0
    else:
        return n*(n-1)//2



N, P = map(int, input().split())
S = list(map(int, input()))
ans = 0
if P == 2:
    for i in range(N):
        if S[i]%2 == 0:
            ans +=i+1
    print(ans)

elif P ==5:
    for i in range(N):
        if S[i]%5 == 0:
            ans +=i+1
    print(ans)
else:
    S[-1] = S[-1]%P
    for i in range(N-2,-1,-1):
        S[i] = (S[i+1] + S[i]*(10**(N-i-1))) %P
    S.sort()
    cnt = 1
    for i in range(N-1):
        if S[i] == S[i+1]:
            cnt +=1
        else:
            ans += Cf(cnt)
            cnt =1
        if S[i] ==0:
            ans+=1
    if S[-1] == 0:
        ans +=1
    if cnt >1:
        ans += Cf(cnt)
    print(ans)

### FIXED CODE ###

N, P = map(int, input().split())
S = list(map(int, input()))
ans = 0
if P == 2:
    for i in range(N):
        if S[i]%2 == 0:
            ans +=i+1
    print(ans)

elif P ==5:
    for i in range(N):
        if S[i]%5 == 0:
            ans +=i+1
    print(ans)
else:
    data =[0]*P
    tens = 1
    k = 0
    for i in range(N-1,-1,-1):
        k += S[i] *tens %P
        k = k%P
        data[k] += 1
        tens *=10
        tens %=P

    for i in data:
        ans += i*(i-1)/2
    ans +=data[0]
    print(int(ans))
### BUGGY CODE ###

num = input()
inp = input().split()
res = []
final = ""
tem = 0
for i in inp:
   tem = inp.count(i)
   res.append(tem)
   tem = 0
for i in res:
   if i >= 2:
      final = "NO"
      break
   else:
      final = "YES"
print(final)


### FIXED CODE ###

num = input()
inp = input().split()
len1 = len(inp)
out = set(inp)
len2 = len(out)
if len1 == len2:
   print("YES")
else:
   print("NO")
### BUGGY CODE ###

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

if k == 1:
  print(0)
  exit()

min = 10**18

while True:
  n = abs(n-k)
  if min > n:
    min = n
  else:
    break

print(min)

### FIXED CODE ###

n,k = map(int, input().split())
n = n % k
a = abs(n-k)
if n <= a:
  print(n)
else:
  print(a)
### BUGGY CODE ###

s=raw_input()
l=len(s)

str=""
i=0
LSUM=[0]
cnt=0
ans=0
while i<l:
	x=s[i]
	if x=="A":
		str+="A"
		i+=1
		cnt=LSUM[-1]+1
	elif i+1<l and s[i]=="B" and s[i+1]=="C":
		str+="D"
		i+=2
		cnt=LSUM[-1]
		ans+=cnt
	else:
		str+="X"
		i+=1
		cnt=0
	LSUM.append( cnt )


print ans

### FIXED CODE ###

s=raw_input()
l=len(s)

i=0
cnt=0
ans=0
while i<l:
	x=s[i]
	if x=="A":
		i+=1
		cnt+=1
	elif i+1<l and s[i]=="B" and s[i+1]=="C":
		i+=2
		ans+=cnt
	else:
		i+=1
		cnt=0


print ans
### BUGGY CODE ###

n=int(input())
l=list(map(int,input().split()))
s=0
m=1000000007
for i in range(n):
  for j in range(i+1,n):
    if l[j]>0 and l[i]>0:
      s=(s+(l[i]%m*l[j]%m)%m)%m
print(s)
      

### FIXED CODE ###

n=int(input())
l=list(map(int,input().split()))
s=0
m=1000000007
s1=sum(l)
s1=(s1*s1)
s2=0
for i in range(n):
  s2=s2+l[i]*l[i]
print(((s1-s2)//2)%m)
### BUGGY CODE ###

N, K, Q = map(int,input().split())
A = [0]*Q
survive = [0]*N

for i in range (Q):
    A[i] = input()

for i in range (N):
    c=A.count(str(i+1))
    if Q-c >= K:
        survive[i] = "No"
    else:
        survive[i] = "Yes"

ans = '\n'.join(survive)
print(ans)

### FIXED CODE ###

N, K, Q = map(int,input().split())
A = [0]*Q
survive = [0]*N

for i in range (Q):
    A[i] = int(input())

result={}
for i in range (0,len(A)):
    item = A[i]
    if item in result:
        result[item] = result[item]+1
    else:
        result[item] = 1

for i in range (1,N+1):
    item = i
    if item not in result:
        result[item] = 0

result_sort = sorted(result.items())

for i in range (N):
    if Q - result_sort[i][1] >= K:
        print("No")
    else:
        print("Yes")
### BUGGY CODE ###

from itertools import accumulate
N, K, *A = map(int, open(0).read().split())
for _ in range(min(K, 41)):
    next_A = [0] * (N + 1)
    for i, a in enumerate(A):
        next_A[max(0, i - a)] += 1
        next_A[min(N, i + a + 1)] -= 1
    A = list(accumulate(next_A))
A.pop()
print(*A)

### FIXED CODE ###

from itertools import accumulate
N, K, *A = map(int, open(0).read().split())
for _ in range(min(K, 41)):
    next_A = [0] * (N + 1)
    for i, a in enumerate(A):
        next_A[max(0, i - a)] += 1
        next_A[min(N, i + a + 1)] -= 1
    A = list(accumulate(next_A))
A.pop()
print(*A)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**7)

def main():
    N, Z, W = map(int, input().split())
    A = list(map(int, input().split()))
    dp = [0] * N
    def hoge(z, w, n, turn):
        if n == 0:
            return abs(z - w)
        if turn:
            return max(hoge(A[N - 1 - i], w, i, not turn) for i in range(n))
        else:
            return min(hoge(z, A[N - 1 - i], i, not turn) for i in range(n))
    return hoge(Z, W, N, True)

print(main())


### FIXED CODE ###

def main():
    N, Z, W = map(int, input().split())
    A = list(map(int, input().split()))
    if N == 1:
        return abs(A[-1] - W)
    return max(abs(A[-1] - W), abs(A[-1] - A[-2]))


print(main())
### BUGGY CODE ###

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

import math, copy

def all_gcd(l):
    a = l[0]
    for i in range(1,len(l)):
        b = l[i]
        a = math.gcd(a, b)
    return a

max_gcd = 0
for n in A:
    copied_A = copy.copy(A)
    copied_A.remove(n)
    max_gcd = max(max_gcd, all_gcd(copied_A)) 

print(max_gcd) 

### FIXED CODE ###

import math

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

gcd_l = [0]
gcd_r = [0]


for i in range(N):
    gcd_l.append(math.gcd(gcd_l[i], A[i]))
    gcd_r.append(math.gcd(gcd_r[i], A[-(i+1)]))

gcd_r = gcd_r[::-1]

max_gcd = 0
for i in range(N):
    max_gcd = max(max_gcd, math.gcd(gcd_l[i], gcd_r[i+1]))

print(max_gcd)