Harryxun/stf_run huggingface dataset:
# -*- coding: utf-8 -*-


def sum_and_average():
    _sum_list = []
    _avg_list = []

    while 1:
        try:
            _sum, _avg = [int(e) for e in input().split()]
            _sum_list.append(_sum)
            _avg_list.append(_avg)
        except EOFError:
            break
    return sum(_sum_list), (sum(_avg_list) / len(_avg_list))

if __name__ == '__main__':
    _sum, _avg = sum_and_average()
    print(round(_sum, 1), round(_avg, 1))

### FIXED CODE ###

# -*- coding: utf-8 -*-

_sum = 0
_avg = 0
n = 0


while 1:
    try:
        _s, _a = [int(e) for e in input().split(',')]
        _sum += _s * _a
        _avg += _a
        n += 1
    except:
        print(_sum)
        print(int(_avg / n + 0.5))
        break
N = input()
A = sorted([input() for i in range(N)])

if N % 2 == 0:
    ans = 2 * (sum(A[N // 2:]) - sum(A[:N // 2])) - (A[N // 2] - A[N // -1])
else:
    ans = 2 * (sum(A[N // +1:]) - sum(A[:N // 2])) - min(A[N // 2] - A[N // 2 - 1], A[N // 2 + 1] - A[N // 2])

print(ans)


### FIXED CODE ###

N = int(input())
A = sorted([int(input()) for i in range(N)])

if N % 2 == 0:
    print(2 * (sum(A[N // 2:]) - sum(A[:N // 2])) - (A[N // 2] - A[N // 2 - 1]))
else:
    print(2 * (sum(A[N // 2 + 1:]) - sum(A[:N // 2])) - min(A[N // 2] - A[N // 2 - 1], A[N // 2 + 1] - A[N // 2]))
import math
N=int(input())
A=[int(input()) for i in range(5)]
print(math.ceil(N/min(A)+4)

### FIXED CODE ###

import math
n=int(input())
l=[int(input()) for i in range(5)]
print(math.ceil(n/min(l))+4)
A = input()
B = input()
c = len(B)
del B[c-1]
if A == B:
  print(Yes)
else:
  print(NO)


### FIXED CODE ###

A = list(input())
B = list(input())
c = len(B)
del B[c-1]
if A == B:
  print("Yes")
else:
  print("No")
X, Y = [int(), input().split()]

if X % 2 == 0 and 2 * X < Y < 4 * X:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

X, Y = map(int, input().split())

if Y % 2 == 0 and 2 * X <= Y <= 4 * X:
    print("Yes")
else:
    print("No")
n = int(input())
l = list(input)
cnt = 0
for i in range(1,n):
    three = [l[i-1],l[i],l[i+1]]
    three.sort()
    if three[1] == list[i]:
        cnt += 1

print(cnt)



### FIXED CODE ###

n = int(input())
l = [int(i) for i in input().split()]
cnt = 0
for i in range(1,n-1):
    three = [l[i-1],l[i],l[i+1]]
    three_sort_list = sorted(three)
    if three[1] == three_sort_list[1]:
        cnt += 1

print(cnt)
a,b,c,k = map(int,input().split())
if a < k:
    print(k)
else if a+b <= k:
    print(a)
else :
    print(a-(k-a-b))

### FIXED CODE ###

a,b,c,k = map(int,input().split())
if a+b >= k:
    if a > k:
        print(k)
    else:
        print(a)
else :
    print(a-(k-a-b))
N,K=map(int,input().split())
V=list(map(int,input().split()))
ans=0
KK=K
if K>N:
    KK=N
for i in range(KK+1):
    j=KK-i
    a=V[:i]
    b=V[N-j:]
    ans=max(ans,sum(a)+sum(b))
    k=sum(a)+sum(b)
    c=a+b
    c.sort(reverse=True)
    W=K+max(0,K-N)
    W-=2
    while(W>0):
        if c==[]:
            break
        t=c.pop()
        if t in a:
            a.remove(t)
        else:
            b.remove(t)
        if a!=[] and b!=[] :
            if a[-1]<=b[0]:
                h=a.pop(-1)
            else:
                h=b.pop(0)
        elif a!=[] and b==[]:
            h=a.pop(-1)
        elif b!=[] and a==[]:
            h=b.pop(0)
        else:
            break
        k=k-t-h
        ans=max(k,ans)
        W-=2
print(ans)


### FIXED CODE ###

N,K=map(int,input().split())
V=list(map(int,input().split()))
ans=0

for i in range(1,N+1):#何個取るか
    if i>K:
        break
    for r in range(i+1):

        l=i-r
        a=V[:r]
        b=V[N-l:]
        f=max(0,K-i)
        c=a+b
        c.sort()
        k=0
        t=0
        for j in c:
            if t<f and j<0:
                t+=1
                continue
            k+=j
        ans=max(ans,k)
print(ans)
N = int(input())
A = list(map(input().split()))

for i in range(N):
  print(A.count(i+1))

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
x = [0]*(2*10**5+1)
for i in range(N-1):
    x[A[i]] += 1
for i in range(1,N+1):
    print(x[i])
n = input()
s = raw_input()
l = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"
r = ""
for i in s:
    r += l[l.index(i)+n]
print r


### FIXED CODE ###

n = int(input())
chars = input()

alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
ans = ""
for c in chars:
    pos = alphabet.find(c)
    ans += alphabet[(pos + n) % 26]

print(ans)
l=[list(map(int,input())) for i in range(3)]

sum_l=0
ans="No"

for i in l:
  sum_l+=sum(i)
  
if sum_l%3==0:
  ans="Yes"

print(ans)

### FIXED CODE ###

c=[list(map(int,input().split())) for i in range(3)]
if (c[0][0]+c[1][1]+c[2][2])*2==c[0][1]+c[0][2]+c[1][0]+c[1][2]+c[2][0]+c[2][1]:
  print('Yes')
else:
  print('No')
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,*A = map(int,read().split())

from functools import lru_cache
from collections import Counter

@lru_cache(None)
def F(one,two,thr):
    if one==two==thr==0:
        return 0
    x = 1
    if one:
        x += one/N*F(one-1,two,thr)
    if two:
        x += two/N*F(one+1,two-1,thr)
    if thr:
        x += thr/N*F(one,two+1,thr-1)
    x *= N; x /= (one+two+thr)
    return x

counter = Counter(A)

answer = F(*[counter[n] for n in [1,2,3]])
print(answer)

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

import numpy as np
N = int(input())

sushi = np.bincount(np.array(input().split(), dtype=np.int8),minlength=4)
total = (sushi * np.arange(4)).sum()

# a,b,c = 1個、2個、3個
# S = a + 2b + 3c：total スシ
# S の小さい方から求めていく
# S ごとには、b,c だけ持てば a が分かる

b = np.arange(N+1)[:,None]
c = np.arange(N+1)[None,:]
S_bc = 2 * b + 3 * c
dp = np.zeros((N+1,N+1))
for S in range(1,total+1):
    prev = dp
    a = S - S_bc
    dp = prev * a + N
    dp[1:] += prev[:-1] * b[1:]
    dp[:-1,1:] += prev[1:,:-1] * c[:,1:]
    dp /= (a+b+c)
    dp[a < 0] = 0

answer = dp[sushi[2],sushi[3]]
print(answer)
f=lambda:map(int,input().split())
N,M=f()
q=[list(f()) for _ in [0]*M]
res=-1
A=range(10**(N-1),10**N)
if N==1:A+=[0]
for i in :
    for j in range(M):
        if str(i)[q[j][0]-1]!=str(q[j][1]):
            break
    else:
        res=i
        break
print(res)

### FIXED CODE ###

f=lambda:map(int,input().split())
N,M=f()
q=[list(f()) for _ in [0]*M]
res=-1
A=list(range(10**(N-1),10**N))
if N==1:A=[0]+A
for i in A:
    for j in range(M):
        if str(i)[q[j][0]-1]!=str(q[j][1]):
            break
    else:
        res=i
        break
print(res)
sk = input()
count = 0
for i in range(s + 2):
    for j in range(i + 1, s + 2):
        x = i
        y = j - i - 1
        z = s - y - x
        if x <= k and y <= k and z <= k:
            count += 1
print(count)

### FIXED CODE ###

ks = input()
k, s = [int(x) for x in ks.split(" ")]
comb = []
for x in range(min(k,s) + 1)[::-1]:
    for y in range(min(x + 1, s - x + 1))[::-1]:
        z = s - x - y
        if (x <= k and y <= k and z <= k and y <= x and z <= y):
            comb.append([x,y,z])
count = 0
for c in comb:
    l = len(set(c))
    if l == 1:
        count += 1
    elif l == 2:
        count += 3
    else:
        count += 6
print(count)
s = input()
list = ['SUN','MON','TUE','WED','THU','FRY','SAT']
index = 0
for i in list:
    if s == i:
        ans = 7 - index
    index += 1
print(ans)

### FIXED CODE ###

s = input()
list = ['SUN','MON','TUE','WED','THU','FRI','SAT']
index = 0
for i in list:
    if s == i:
        ans = 7 - index
    index += 1
print(ans)
from math import floor,ceil
x = input().split()
a = int(x[0])
b = int(x[1])
c = int(x[2])
print(int(floor(a*c/b)-a*floor(c/b)))


### FIXED CODE ###

k = int(input())
x = input().split()
a = int(x[0])
b = int(x[1])
c = 0
for i in range(a,b+1):
  if i%k==0:
    c = 1
    break
if c==1:
  print("OK")
else:
  print("NG")
n=int(raw_input())
tr=[[] for i in range(n)]
for i in range(n-1) :
  a,b,c=map(int,raw_input().split())
  a -= 1
  b -= 1
  tr[a].append((b,c))
  tr[b].append((a,c))
m,k=map(int,raw_input().split())
k -= 1
dis=[0 for i in range(n)]
def dfs(u,w=-1,l=0) :
  dis[u]=l
  for v,v1 in tr[u] :
    if v!=w :
      dfs(v,u,l+v1)
dfs(k)
for i in range(m) :
  x,y=map(int,raw_input().split())
  x-=1
  y-=1
  print dis[x]+dis[y]


### FIXED CODE ###

import sys  
sys.setrecursionlimit(200000)
n=int(raw_input())
tr=[[] for i in range(n)]
for i in range(n-1) :
  a,b,c=map(int,raw_input().split())
  a -= 1
  b -= 1
  tr[a].append((b,c))
  tr[b].append((a,c))
m,k=map(int,raw_input().split())
k -= 1
dis=[0 for i in range(n)]
def dfs(u,w=-1,l=0) :
  dis[u]=l
  for v,v1 in tr[u] :
    if v!=w :
      dfs(v,u,l+v1)
dfs(k)
for i in range(m) :
  x,y=map(int,raw_input().split())
  x-=1
  y-=1
  print dis[x]+dis[y]
n = int(input())
things = input().split()
s = ""
for i in range(n):
  s += thing[0][i]
  s += thing[1][i]
print(s)

### FIXED CODE ###

n = int(input())
things = input().split()
s = ""
for i in range(n):
  s += things[0][i]
  s += things[1][i]
print(s)
n,k=map(int,input().split())
p=[int(i)-1for i in input().split()]
c=list(map(int,input().split()))
ans=-10**9
for i in range(n):
    start=i
    cycle=[0]
    for _ in range(n):
        i=p[i]
        cycle+=[cycle[-1]+c[i]]
        if i==start:break
    S,L=cycle[-1],len(cycle)-1
    if S<0:ans=max(ans,max(cycle[1:k]))
    else:ans=max(ans,k//L*S+max(cycle[:k%L+1]))
print(ans)

### FIXED CODE ###

n,k=map(int,input().split())
p=[int(i)-1for i in input().split()]
c=list(map(int,input().split()))
ans=-10**9
for i in range(n):
    start=i
    cycle=[0]
    for _ in range(n):
        i=p[i]
        cycle+=[cycle[-1]+c[i]]
        if i==start:break
    S,L=cycle[-1],len(cycle)-1
    if S<=0:ans=max(ans,max(cycle[1:k+1]))
    else:
        if k>L:ans=max(ans,(k//L-1)*S+max(max(cycle),max(cycle[:k%L+1])+S)) 
        else:ans=max(ans,max(cycle[:k+1]))
print(ans)
import math
n = int(input())
lc = 1
for i in range(n):
    t = int(input())
    lc = lc * t // math.gcd(lc,t)
print(lc)

### FIXED CODE ###

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
n = int(input())
lc = 1
for i in range(n):
    t = int(input())
    lc = lc * t // gcd(lc,t)
print(lc)
s = input()[::-1]
l = len(s)
dp =[[0 for _ in range(13)] for _ in range(l+1)]
dp[0][0] =1
for i in range(l):
    if s[i] == "?":
        for j in range(10):
            for k in range(13):
                dp[i + 1][((j * (10 ** i)) % 13 + k) % 13] +=dp[i][k] % mod
    else:
        for k in range(13):
            dp[i + 1][((int(s[i]) * (10 ** i)) % 13 + k) % 13] +=dp[i][k] % mod
print(dp[-1][5] % mod)

### FIXED CODE ###

mod = 10 ** 9 + 7
s = input()
n = len(s)
dp = [[0 for _ in range(13)] for _ in range(n + 1)]
dp[0][0]=1
for i in range(n):
    if s[i] == '?': 
        for j in range(10):
            for k in range(13):
                dp[i + 1][(k * 10 + j) % 13]+=dp[i][k] % mod
    else:
        for k in range(13): 
            dp[i + 1][(k * 10+ int(s[i])) % 13]+=dp[i][k] % mod
print(dp[-1][5] % mod)
K, S = map(int, input().split())
ans = 0

for x in range(K+1):
    for y in range(K+1):
        if S - x - y < 0:
            break
        if K >= S - x - y >= 0:
            ans += 1
print(ans)


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

ans = 0
for right in range(max(s-k, 0), min(s+1, 2*k+1)):
  lower = max(0, right-k)
  upper = min(k, right)
  if right % 2 != 0:
    ans += upper - lower + 1
  else:
    ans += upper - lower + 1
print(ans)


### FIXED CODE ###

K, S = map(int, input().split())
ans = 0

for x in range(K+1):
    for y in range(K+1):
        if K >= S - x - y >= 0:
            ans += 1
print(ans)
def p_d():
    from bisect import bisect_right
    A, B, Q = map(int, input().split())
    INF = 10 ** 9
    s = [-INF] + [int(input()) for _ in range(A)] + [INF]
    t = [-INF] + [int(input()) for _ in range(B)] + [INF]
    for _ in range(Q):
        x = int(input())
        b, d = bisect_right(s, x), bisect_right(t, x)
        res = INF
        for S in [s[b - 1], s[b]]:
            for T in [t[d - 1], t[d]]:
                d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
                res = min((d1, d2, res))
    print(res)


if __name__ == '__main__':
    p_d()

### FIXED CODE ###

def p_d():
    from bisect import bisect_right
    A, B, Q = map(int, input().split())
    INF = 10 ** 18
    s = [-INF] + [int(input()) for _ in range(A)] + [INF]
    t = [-INF] + [int(input()) for _ in range(B)] + [INF]
    ans = []
    for _ in range(Q):
        x = int(input())
        b, d = bisect_right(s, x), bisect_right(t, x)
        res = INF
        for S in [s[b - 1], s[b]]:
            for T in [t[d - 1], t[d]]:
                d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
                res = min((d1, d2, res))
        ans.append(str(res))
    print("\n".join(ans))


if __name__ == '__main__':
    p_d()
N, Q = map(int, input().split())
S = " " + input()
l = []
r = []
for _ in range(Q):
    _l, _r = map(int, input().split())
    l.append(_l)
    r.append(_r)
dp = [0] * (N + 2) #i文字目から何個ACがあるか
cnt = 0
for i in range(1, N):
    if S[-i] == "C" and S[-i-1] == "A":
            cnt += 1
    dp[N-i] = cnt
#print(dp)
ans = 0
for q in range(Q):
    ans = dp[l[q]] - dp[r[q] + 1]
    if S[r[q]] == "A" and S[r[q] + 1] == "C":
        ans -= 1
    print(ans)

### FIXED CODE ###

N, Q = map(int, input().split())
S = " " + input()
l = []
r = []
for _ in range(Q):
    _l, _r = map(int, input().split())
    l.append(_l)
    r.append(_r)
dp = [0] * (N + 2) #i文字目から何個ACがあるか
cnt = 0
for i in range(1, N):
    if S[-i] == "C" and S[-i-1] == "A":
            cnt += 1
    dp[N-i] = cnt
#print(dp)
ans = 0
for q in range(Q):
    ans = dp[l[q]] - dp[r[q] + 1]
    if r[q] < N:
        if S[r[q]] == "A" and S[r[q] + 1] == "C":
            ans -= 1
    print(ans)
from collections import deque
N, M = map(int, input().split())

graph = [set() for _ in range(N + 1)]
edge = [[] for _ in range(N + 1)]
for m in range(M):
    a, b = map(int, input().split())
    graph[a].add(b)
    graph[b].add(a)
    edge[m + 1] = [a, b]

ans = 0
for m in range(M):
    Bridge = True
    fr, to = edge[m + 1][0], edge[m + 1][1]
    V = {fr} | set(graph[fr]) - {to}
    que = set(graph[fr]) - {to}
    while que:
        node = que.pop()
        for new_node in graph[node]:
            if new_node == to:
                Bridge = False
                break
            if new_node not in V:
                que.add(new_node)
                V.add(new_node)
        else:
            continue
        break
    if Bridge:
        ans += 1
print(ans)

### FIXED CODE ###

from collections import deque
N, M = map(int, input().split())

graph = [set() for _ in range(N + 1)]
edge = []
for m in range(M):
    a, b = map(int, input().split())
    graph[a].add(b)
    graph[b].add(a)
    edge.append([a, b])

ans = 0
for m in range(M):
    Bridge = True
    fr, to = edge[m][0], edge[m][1]
    V = {fr} | set(graph[fr]) - {to}
    que = set(graph[fr]) - {to}
    while que:
        node = que.pop()
        for new_node in graph[node]:
            if new_node == to:
                Bridge = False
                break
            if new_node not in V:
                que.add(new_node)
                V.add(new_node)
        else:
            continue
        break
    if Bridge:
        ans += 1
print(ans)
import numpy as np

N = input()

num_paper = N / 2
if (N % 2) > 0:
  num_paper += 1
else:
  pass

print(num_paper)

### FIXED CODE ###

N = input()
N = int(N)
num_paper = int(N / 2)
if (N % 2) > 0:
  num_paper += 1
else:
  pass

print(num_paper)
s = list(map(input().split()))
ans = "Yes"
for i in range(len(s)):
  if i%2 == 0 and s[i] != "h":
    ans = "No"
  elif i%2 == 1 and s[i] != "i":
    ans = "No"
if len(s)%2 == 1:
  ans = "No"
print(ans)

### FIXED CODE ###

s = list(input())
ans = "Yes"
for i in range(len(s)):
  if i%2 == 0 and s[i] != "h":
    ans = "No"
  elif i%2 == 1 and s[i] != "i":
    ans = "No"
if len(s)%2 == 1:
  ans = "No"
print(ans)
n,Q=map(int,input().split())
s=input()

a=[0]*(n+1)
for i in range(n):
    if s[i]=='A' and s[i+1]=='C':
        a[i+1]=a[i]+1
    else:
        a[i+1]=a[i]

for i in range(Q):
    l,r=map(int,input().split())
    print(a[r-1]-a[l-1])

### FIXED CODE ###

n,Q=map(int,input().split())
s=input()

a=[0]*(n+1)
for i in range(2,n+1):
    if s[i-2]=='A' and s[i-1]=='C':
        a[i]=a[i-1]+1
    else:
        a[i]=a[i-1]

for i in range(Q):
    l,r=map(int,input().split())
    print(a[r]-a[l])
from math import factorial as fact
import math
import fractions
import sys
import itertools
import numpy as np
from collections import Counter
import datetime
#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

def keta(N):
	return len(str(N))


def input_daytime(input_time):
	time,distance=input_time.split()
	t=time.split(":")
	se=str(t[-1]).split(".")
	dt1 = datetime.timedelta(hours=int(t[0]),minutes=int(t[1]),seconds=int(se[0]),milliseconds=int(se[1]))
	return dt1

def combinations(n,r):
	return list(itertools.combinations(n,r))

def all_sets(num_list):
	subsets=[]
	for i in range(2,len(num_list) + 1):
		for c in combinations(num_list, i):
			subsets.append(c) 
	return subsets

#公約数の列挙
def ch(x1):
	cf=[]
	for i in range(2,math.sqrt(x1)+1):
		if x1 % i==0:
			cf.append(i)
	return cf

def CountOneRoots(x,y):
	#x:縦，y:横
	return fact(x+y)/fact(x)/fact(y)

# 素因数分解
def factorization(n):
	tmp=n
	count=0
	for i in range(2,int(n**0.5)+2):
		if tmp%i==0:
			cnt=0
			while tmp%i==0:
				cnt+=1
				tmp//=i
			count+=1
	if tmp!=1:
		count+=1

	return count
			


s,w=input2()
if w >=s2:
	print("unsafe")
else:
	print("safe")

# a,b,c,d=input2()

# for i in range(1,101):
# 	if i%2==1:
# 		c-=b
# 		if c<=0:
# 			print("Yes")
# 			break
# 	else:
# 		a-=d
# 		if a<=0:
# 			print("No")
# 			break

	







### FIXED CODE ###

from math import factorial as fact
import math
import fractions
import sys
import itertools
import numpy as np
from collections import Counter
import datetime
#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

def keta(N):
	return len(str(N))


def input_daytime(input_time):
	time,distance=input_time.split()
	t=time.split(":")
	se=str(t[-1]).split(".")
	dt1 = datetime.timedelta(hours=int(t[0]),minutes=int(t[1]),seconds=int(se[0]),milliseconds=int(se[1]))
	return dt1

def combinations(n,r):
	return list(itertools.combinations(n,r))

def all_sets(num_list):
	subsets=[]
	for i in range(2,len(num_list) + 1):
		for c in combinations(num_list, i):
			subsets.append(c) 
	return subsets

#公約数の列挙
def ch(x1):
	cf=[]
	for i in range(2,math.sqrt(x1)+1):
		if x1 % i==0:
			cf.append(i)
	return cf

def CountOneRoots(x,y):
	#x:縦，y:横
	return fact(x+y)/fact(x)/fact(y)

# 素因数分解
def factorization(n):
	tmp=n
	count=0
	for i in range(2,int(n**0.5)+2):
		if tmp%i==0:
			cnt=0
			while tmp%i==0:
				cnt+=1
				tmp//=i
			count+=1
	if tmp!=1:
		count+=1

	return count
			


s,w=input2()
if w >=s:
	print("unsafe")
else:
	print("safe")

# a,b,c,d=input2()

# for i in range(1,101):
# 	if i%2==1:
# 		c-=b
# 		if c<=0:
# 			print("Yes")
# 			break
# 	else:
# 		a-=d
# 		if a<=0:
# 			print("No")
# 			break
import fraction

N = int(input())
T = [int(input()) for i in range(N)]
_lcm = 1
for T_i in T:
    _lcm = _lcm * T_i // fraction.gcd(_lcm, T_i)

print(_lcm)

### FIXED CODE ###

from fractions import gcd

N = int(input())
T = [int(input()) for i in range(N)]
_lcm = 1
for T_i in T:
    _lcm = _lcm * T_i // gcd(_lcm, T_i)

print(_lcm)
Flag = False
LS = 0
SS = 0
for T in range(0,len(A)):
    if LS==0 and A[T][1]>=4:
        Sq = A[T][0]**2
        Flag = True
        break
    if A[T][1]>=2:
        if LS==0:
            LS = A[T][0]
        else:
            SS = A[T][0]
            Sq = LS*SS
            Flag = True
            break
if Flag:
    print(Sq)
else:
    print(0)

### FIXED CODE ###

import collections
N = int(input())
A = sorted(collections.Counter(int(T) for T in input().split()).most_common(),reverse=True)
Flag = False
LS = 0
SS = 0
for T in range(0,len(A)):
    if LS==0 and A[T][1]>=4:
        Sq = A[T][0]**2
        Flag = True
        break
    if A[T][1]>=2:
        if LS==0:
            LS = A[T][0]
        else:
            SS = A[T][0]
            Sq = LS*SS
            Flag = True
            break
if Flag:
    print(Sq)
else:
    print(0)
N=int(input())
count=0
a=list(map(int.input().split()))
for i in range(N-1):
  for j in range(i+a[i]+1,N):
    if j-i==a[i]+a[j]:
      count+=1
print(count)

### FIXED CODE ###

N=int(input())
count=0
a=list(map(int,input().split()))
w=[]
s=[]
num=[0]*N
maxi=max(a)
for i in range(N):
  s.append(1+i-a[i])
  if 1+i+a[i]<N:
    num[1+i+a[i]]+=1
for i in range(N):
  if s[i]>=0:
    count+=num[s[i]]
print(count)
n, k = map(int, input().split())
mod = 10**9+7
edges = []
for _ in range(n-1):
  edges.append(list(map(int, input().split())))

edge_dict = {}
for i in range(1, n+1):
  edge_dict[i] = set()

for edge in edges:
  edge_dict[edge[0]].add(edge[1])
  edge_dict[edge[1]].add(edge[0])

visited = set()

def visit(node, parent):
  if parent is not None:
    ans = (k - 1 - len(visited & (edge_dict[parent])))
  else:
    ans = k
  
  visited.add(node)
  
  for child in edge_dict[node]:
    if not child is parent:
      ans = (ans * visit(child, node))%mod
  
  print("Visit {} {}".format(node, ans))
  return ans

print(visit(1, None))

### FIXED CODE ###

import queue

n, k = map(int, input().split())
edges = []
for _ in range(n-1):
  edges.append(list(map(int, input().split())))
mod = 10**9+7

edge_dict = {}
for i in range(1, n+1):
  edge_dict[i] = set()

for edge in edges:
  edge_dict[edge[0]].add(edge[1])
  edge_dict[edge[1]].add(edge[0])

visited = set()
q = queue.LifoQueue()
q.put(1)

num_cases = 1
while not q.empty():
  node = q.get()
  
  visited.add(node)
  num_available_colors = k -2 if node is not 1 else k -1
  
  for child in (edge_dict[node] - visited):
    num_cases *= num_available_colors
    num_available_colors -= 1
    num_cases %= mod
    q.put(child)

print((k*num_cases)%mod)
N, A, B, C, D = map(int, input().split())
S = list(input())
S[A-1] = '#'; S[B-1] = '#'
S.extend(['#']*2)
def dfs(a = A, b = B):
    if a == C and b == D:
        return 'Yes'

    if S[a] == '.':
        S[a] = '#'; S[a-1] = '.'
        return dfs(a+1, b)
    if S[a+1] == '.':
        S[a+1] = '#'; S[a-1] = '.'
        return dfs(a+2, b)
    if S[b] == '.':
        S[b] = '#'; S[b-1] = '.'
        return dfs(a, b+1)
    if S[b+1] == '.':
        S[b+1] = '#'; S[b-1] = '.'
        return dfs(a, b+2)
    return 'No'
print(dfs())


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

N, A, B, C, D = map(int, input().split())
S = list(input())
S[A-1] = '#'; S[B-1] = '#'
S.extend(['#']*3)
def dfs(a = A, b = B):
    if a == C and b == D:
        return 'Yes'

    if S[a] == '.' and a != C:
        S[a] = '#'; S[a-1] = '.'
        return dfs(a+1, b)
    if S[a+1] == '.' and a != C:
        S[a+1] = '#'; S[a-1] = '.'
        return dfs(a+2, b)
    if S[b] == '.' and b != D:
        S[b] = '#'; S[b-1] = '.'
        return dfs(a, b+1)
    if S[b+1] == '.' and b != D:
        S[b+1] = '#'; S[b-1] = '.'
        return dfs(a, b+2)
    return 'No'
print(dfs())
from numpy import gcd

def main():
    n,x = map(int,input().split())
    x_s = [int(i) for i in input().split()]
    x_s = sorted(x_s)
    diffs = []
    for i in x_s:
        diffs.append(abs(x-i))
    print(gcd.reduce(diffs))





if __name__ == '__main__':
    main()


### FIXED CODE ###

from fractions import gcd
from functools import reduce

def main():
    n,x = map(int,input().split())
    x_s = [int(i) for i in input().split()]
    x_s = sorted(x_s)
    diffs = []
    for i in x_s:
        diffs.append(abs(x-i))
    print(reduce(gcd,diffs))





if __name__ == '__main__':
    main()