Problem:
 Score : 300 points    Problem Statement There are N cities on a number line. The i -th city is located at coordinate x_i .  Your objective is to visit all these cities at least once.  In order to do so, you will first set a positive integer D .  Then, you will depart from coordinate X and perform Move 1 and Move 2 below, as many times as you like:   Move 1 : travel from coordinate y to coordinate y + D .  Move 2 : travel from coordinate y to coordinate y - D .   Find the maximum value of D that enables you to visit all the cities.  Here, to visit a city is to travel to the coordinate where that city is located.      Constraints  All values in input are integers.  1 \leq N \leq 10^5  1 \leq X \leq 10^9  1 \leq x_i \leq 10^9  x_i are all different.  x_1, x_2, ..., x_N \neq X         Input Input is given from Standard Input in the following format:  N  X  x_1  x_2  ...  x_N       Output Print the maximum value of D that enables you to visit all the cities.        Sample Input 1 3 3
1 7 11      Sample Output 1 2  Setting D = 2 enables you to visit all the cities as follows, and this is the maximum value of such D .   Perform Move 2 to travel to coordinate 1 .  Perform Move 1 to travel to coordinate 3 .  Perform Move 1 to travel to coordinate 5 .  Perform Move 1 to travel to coordinate 7 .  Perform Move 1 to travel to coordinate 9 .  Perform Move 1 to travel to coordinate 11 .        Sample Input 2 3 81
33 105 57      Sample Output 2 24       Sample Input 3 1 1
1000000000      Sample Output 3 999999999

Solution (Python):
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


N, X = map(int, input().split())
x = list(map(lambda s: abs(int(s) - X), input().split()))

if len(x) < 2:
    print(x[0])
    exit()
d = gcd(x[0], x[1])

for i in range(2, len(x)):
    d = gcd(d, x[i])
print(d)

Solution (Python):
from fractions import gcd    
from functools import reduce

N, X = map(int, input().split())
x    = map(int, input().split())

dist = [abs(y - X) for y in x]

print(reduce(gcd, dist))

Solution (Python):
n, x = map(int, input().split())

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


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


a = [abs(i - x) for i in a]
from functools import reduce
print(reduce(gcd, a))

Solution (Python):
N, X = map(int, input().split())
x_list = [abs(int(i) - X) for i in input().split()]


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
res = [x_list[0]]
for i in range(1, N):
    res.append(gcd(res[i-1], x_list[i]))
print(min(res))

Solution (Python):


from functools import reduce


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


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


def main():
    n, x = map(int, input().split())
    xi = map(int, input().split())

    diffs = []
    for i in xi:
        diffs.append(abs(x - i))

    print(gcd_list(diffs))


if __name__ == '__main__':
    main()

Solution (Python):
import functools
  
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)

inputs = input().split()
n = int(inputs[0])
x = int(inputs[1])
point = list(map(int, input().split()))
point.sort()
space = []

space.append(abs(x - point[0]))

for i in range(1, n):
    space.append(abs(point[i] - point[i -1]))

gcd = functools.reduce(gcd, space)

print(gcd)

Solution (Python):
import fractions

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

b=[]
for i in a:
    b.append(abs(x-i))

if n==1:
    print(abs(x-a[0]))

else:
    ans=fractions.gcd(b[0],b[1])

    for i in range(2,n):
        ans = fractions.gcd(ans ,b[i])

    print(ans)

Solution (Python):
def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a % b)

N,X = map(int,input().split())
x = sorted([X] + list(map(int,input().split())))

ans = x[1] - x[0]
for i in range(2,N+1):
    ans = gcd(ans,x[i] - x[i-1])

print(ans)

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

def main():    
    N,X = map(int,input().split())
    x = list(map(int,input().split()))
    for i in range(N):
        x[i] = abs(x[i]-X)
    y = x[0]
    for i in range(N):
        if x[i]%y == 0:
            continue
        y = gcd(y,x[i])
    print(y)

if __name__ == "__main__":
    main()

Solution (Python):
N,X = map(int,input().split())
x = [int(i) for i in input().split()]
def main():
      global X
      global x
      print(answer(pre(X,x)))
def pre(a,b):
      b = [i-a for i in b]
      return b
def answer(k):
      Min = min([abs(i) for i in k])
      flag = False
      for i in range(1,Min+1):
            if flag == True:
                  break
            flag = True
            if Min%i==0:
                  ans = Min//i
                  for j in k:
                        if j%ans!=0:
                              flag = False
            else:
                  flag = False
      return ans
main()

Solution (Python):
N,X = map(int,input().split())
x = [int(i) for i in input().split()]
x = [i-X for i in x]
Min = min([abs(i) for i in x])
flag = False
for i in range(1,Min+1):
    if flag == True:
        break
    flag = True
    if Min%i==0:
        ans = Min//i
        for j in x:
            if j%ans!=0:
                flag = False
    else:
        flag = False
print(ans)

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

n, x = map(int,input().split())
cities = list(map(int, input().split()))
min = pow(10,9)
a = []
for i in range(n):
    a.append(abs(x-cities[i]))
for i in range(n-1):
    a[i+1] = gcd(a[i],a[i+1])
print(a[-1])

Solution (Python):
import sys
import functools
import fractions

if __name__ == '__main__':
    NX = [int(n) for n in input().split()]
    X = [int(n) for n in input().split()]
    if len(X) == 1:
        print(abs(X[0]-NX[1]))
        sys.exit(0)

    X.append(NX[1])
    X.sort()
    diff = [X[i] - X[i-1] for i in range(1, len(X))]
    D = functools.reduce(fractions.gcd, diff)
    print(D)

Solution (Python):
def gcd(a, b):
    if a < b:
        a, b = b, a
    r = a % b
    if r == 0:
        return b
    return gcd(r, b)

N,X = map(int,input().split())
x = list(map(int,input().split()))

x.append(X)
x.sort()
diff = [x[1]-x[0]]
for i in range(N):
    diff.append(x[i+1]-x[i])

D = gcd(diff[0],diff[1])
for i in range(2,N+1):
    D = gcd(D,diff[i])
print(D)

Solution (Python):
def gcd(x,y):
    while x%y:
        x%=y
        x,y=(y,x)
    return y
n,x=map(int,input().split())
xlist=list(map(int,input().split()))
xlist.sort(key=lambda xx:abs(xx-x))
for i in range(n):
    xlist[i]-=x
    xlist[i]=abs(xlist[i])
m=xlist[-1]
while xlist!=[0]*n:
    for i in range(n):
        
        xlist[i]%=m
        if xlist[i]>0:
            m=gcd(m,xlist[i])
print(m)

Solution (Python):
def getGcd(num1, num2):
    while True:
        tmp = num1
        num1 = num2 % num1
        num2 = tmp
        if(num1 == 0):
            return tmp

[n, x] = map(int, input().split(" "))
xs = list(map(int, input().split(" ")))

xs.append(x)
xs.sort()

gc = xs[1] - xs[0]

for i in range(1, n + 1):
    gc = getGcd(gc,  xs[i] - xs[i - 1])

print(gc)

Solution (Python):


import math
from functools import reduce


def gcd(a,b):
    l = max(a,b)
    m = min(a,b)
    while m != 0:
        extra = l%m
        l = m
        m = extra
    return l

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

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

x = [int(i) for i in input().split()]

x.append(X)

x.sort()

minus=[]

for i in range(len(x)-1):
    minus.append(x[i+1]-x[i])


D = gcd_multi(minus)

print(int(D))

Solution (Python):
n, X = map(int, input().split())
x = list(map(int, input().split()))
rec = set()
for i in range(n):
    rec.add(abs(x[i] - X))

rec = sorted(list(rec))


def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)


num = rec[0]
for k in range(1, len(rec)):
    num = gcd(num, rec[k])


print(num)

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

N, X = map(int, raw_input().split())
xs = map(int, raw_input().split())
gc = map(lambda x: abs(x - X), xs)
print reduce(gcd, gc)

Solution (Python):
def gcd(a, b):
    while(b != 0):
        amari = a % b

        a = b
        b = amari
    return(a)


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

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

tmp = abs(X[0] - K)
for i in range(1, N):
    tmp = gcd(tmp, abs(X[i] - K))

print(tmp)

Solution (Python):
def gcd(a,b):
    if a == 0:
        return b
    return gcd(b%a, a)
n,x = map(int, input().split())
l = list(map(int, input().split()))
for i in range(n):
    l[i] -= x
    l[i] = abs(l[i])
ans = []
if len(l) == 1:
    ans.append(l[0])
while len(ans) != 1:
    ans = []
    for i in range(1,len(l)):
        ans.append(gcd(l[i], l[i-1]))
    ans = list(set(ans))
    l = []
    for i in ans:
        l.append(i)
print(ans[0])

Solution (Python):

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

N, X = map(int,input().split())
k = [abs(int(x) - X) for x in input().split()] 
a = k[0]
for i in range(1,N):
    a = gcd(a,k[i])
print(str(a))

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

N, X = map(int, input().split())
x = [int(_) for _ in input().split(' ')]

dist = [abs(i - X) for i in x]

ans = dist[0]

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

print(ans)

Solution (Python):
def main4():
    import fractions
    N, X = list(map(int, input().split()))
    xs = list(map(int, input().split()))

    diffs = []
    for x in xs:
        diffs.append(abs(X-x))

    if len(diffs) == 1:
        print(diffs[0])
        exit()

    ans = 10**9+1
    for i in range(len(diffs)-1):
        ans = min(fractions.gcd(diffs[i], diffs[i+1]), ans)
    print(ans)

if __name__ == "__main__":
    main4()

Solution (Python):
N, X = list(map(int, input().split()))
x = list(map(int, input().split()))

diff = [abs(i - X) for i in x]

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)

ans = diff[0]

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

print(ans)

Solution (Python):
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)

n, x = map(int, input().split())
xlist = list(map(int, input().split()))
for i in range(n):
    xlist[i] = abs(xlist[i]-x)
    
if len(xlist)==1:
    print(xlist[0])
else:
    maxgcd = gcd(xlist[0], xlist[1])
    for i in range(2,n):
        maxgcd = gcd(maxgcd, xlist[i])
    print(maxgcd)

Solution (Python):
import sys
sys.setrecursionlimit(500000)

def gcd(a, b):
	
	
	

	if b:
		return gcd(b, a % b)
	else:
		return a

def gcd_list(li):
	if len(li) > 2:
		x = gcd(li[-1], li[-2])
		li = li[:-2] + [x]
		return gcd_list(li)
	else:
		return gcd(li[0], li[1])

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

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

li = [abs(i - X) for i in x]



if len(li) == 1:
	print(li[0])
else:
	ans = li[0]
	for i in range(1,N):
		ans = gcd(ans, li[i])
	print(ans)

Solution (Python):
def gcd(a,b):
    if b==0:
        return a 
    return gcd(b,a%b)
n,x = map(int,input().split())
l = [int(ele) for ele in input().split()]
l.append(x)
l.sort()
g = 0 
for i in range(1,n+1):
    g = gcd(g,l[i]-l[i-1])
print(g)

Solution (Python):




from fractions import gcd
from functools import reduce
n, x = map(int, input().split())
a = list(map(int, input().split()))
ans = reduce(gcd, [abs(x-a[i]) for i in range(n)])
print(ans)

Solution (Python):
def GCD(a,b): 
  if a<b:
    a,b = b,a

  r = a % b
  
  while r!=0:
    a = b
    b = r
    r = a % b
 
  return b

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

T = list(map(int, input().split()))
for i in range(N):
  T[i] = abs(T[i] - X)

ans = T[0]
for i in range(1,N):
  ans = GCD(ans, T[i])
  
print(ans)

Solution (Python):
from functools import reduce
def gcd(a,b):
        while b:
            a,b=b,a%b
        return a
def solve(lis,x):
    ans=abs(lis[0]-x)
    lis=[abs(c-x) for c in lis]
    for x in lis:
        if x!=0:
            ans=gcd(ans,x)
    return ans 
n,x=map(int,input().split())
l=list(map(int,input().split()))
print(solve(l,x))

Solution (Python):

from fractions import gcd

N,X=map(int,raw_input().split())
x=map(int,raw_input().split())
y=[]
for i in xrange(N):
 y.append(abs(X-x[i]))
print reduce(gcd,y)

Solution (Python):
def gcd(a,b):
        while b:
            a,b=b,a%b
        return a
def solve(lis,x):
    if len(lis)==1:
        return abs(lis[0]-x)
    lis=[abs(c-x) for c in lis]
    ans=gcd(lis[0],lis[1])
    for x in lis[2:]:
        if x!=0:
            ans=gcd(ans,x)
    return ans 
n,x=map(int,input().split())
l=list(map(int,input().split()))
print(solve(l,x))

Solution (Python):
"""
C - Skip
Xを含めた与えられた数列をソートする
最小値を基準０にする
隣同士の差を取る
数列の最大公約数を求める
"""

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

numbers = [X]
for part in input().split():
    numbers.append(int(part))

numbers.sort()


min_num = min(numbers)
normal_numbers = []
for num in numbers:
    normal_numbers.append(num - min_num)


dist_numbers = []
for i in range(1, len(normal_numbers)):
    
    dist_temp = normal_numbers[i] - normal_numbers[i-1]
    if dist_temp not in dist_numbers:
        dist_numbers.append(dist_temp)


def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

def gcd_list(numbers):
    if len(numbers) == 1:
        return numbers[0]
    elif len(numbers) == 2: 
        return gcd(numbers[0], numbers[1])
    else:
        return gcd(numbers[0], gcd_list(numbers[1:]))

print(gcd_list(dist_numbers))

Solution (Python):
from functools import reduce

def euclid(a, b):
    if a < b:
        a, b = (b, a)

    while True:
        r = a % b
        if r == 0:
            break
        a, b = (b, r)

    return b


if __name__ == '__main__':
    n, x = tuple(map(int, input().split()))
    points = [int(x) for x in input().split()]
    if not x in points:
        points.append(x)

    buf = [abs(points[i + 1] - points[i]) for i in range(len(points) - 1)]
    print(reduce(lambda a,b: euclid(a, b), buf))

Solution (Python):
from functools import reduce

def euclid(a, b):
    if a < b:
        a, b = (b, a)

    while True:
        r = a % b
        if r == 0:
            break
        a, b = (b, r)

    return b


if __name__ == '__main__':
    n, x = tuple(map(int, input().split()))
    points = [int(x) for x in input().split()]

    buf = [abs(p - x) for p in points]
    print(reduce(lambda a,b: euclid(a, b), buf))

Solution (Python):
from fractions import gcd
from functools import reduce

N, X = map(int, input().split())
x    = map(int, input().split())

dist = map(lambda y: abs(y - X), x)

print(reduce(gcd, dist))

Solution (Python):
from fractions import gcd
from functools import reduce

N, X   = map(int, input().split())
x = list(map(int, input().split()))
assert len(x) == N

dist = map(lambda y: abs(y - X), x)

print(reduce(gcd, dist))

Solution (Python):
import numpy as np
import math
from functools import reduce

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

    return a

def multi_gcd(*numbers):
    return reduce(gcd, numbers)

N, X = map(int, input().split(' '))
city = np.array(list(map(int, input().split(' '))))

city -= X
print(abs(multi_gcd(*city)))

Solution (Python):
from fractions import gcd
from functools import reduce
_,X,*y=map(int,open(0).read().split());print(reduce(gcd,[abs(x-X)for x in y]))

Solution (Python):
from fractions import gcd
from functools import reduce
X=int(input().split()[1]);print(reduce(gcd,map(lambda x:abs(int(x)-X),input().split())))

Solution (Python):
from functools import reduce
def g(a,b):
  while b:a,b=b,a%b
  return a
X=int(input().split()[1]);print(reduce(g,map(lambda x:abs(int(x)-X),input().split())))

Solution (Python):
from functools import reduce
def g(a,b):
  while b:a,b=b,a%b
  return a
def f(x):return reduce(g,x)
X=int(input().split()[1]);print(f(map(lambda x:abs(int(x)-X),input().split())))

Solution (Python):
N, X = map(int, input().split())
x = list(map(lambda x: abs(int(x)-X), input().split()))

def gcd(x, y):
    if x > y:
        x, y = y, x
    while x > 0:
        x, y = y%x, x
    return y

ans = x[0]
for xx in x:
    ans = gcd(ans, xx)

print(ans)

Solution (Python):
from fractions import gcd
from functools import reduce
N,x0 = map(int,input().split())
print(abs(reduce(gcd, map(lambda s: int(s)-x0, input().split()))))

Solution (Python):
import fractions

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

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

dist_list = []
for city in city_list:
    dist_list.append(abs(city - x))

max_common_value = dist_list.pop(0)

for dist in dist_list:
    
    max_common_value = fractions.gcd(max_common_value, dist)

print(max_common_value)

Solution (Python):
from fractions import gcd
N, X = map(int, input().split())
x = list(map(int, input().split()))

ans = 0
for i in x:
    ans = gcd(ans, abs(i - X))
print(ans)

Solution (Python):
import numpy as np
N,X = list(map(int,input().split()))
x = np.array(list(map(int,input().split())))

Xar = np.array([X]*N)
d = abs(x-Xar)
def EA(a,b):
    if a%b ==0:
        return b
    else:
        return EA(b,a%b)
if len(x)==1:
    ans = d[0]
else:
    ans = EA(d[0],d[1])
    for i in range(N):
        ans = EA(ans,d[i])
print(ans)

Solution (Python):
from functools import reduce
from fractions import gcd
n, x = map(int, input().split())
y = [abs(int(v) - x) for v in input().split()]
g = y[0] if len(y) == 1 else reduce(gcd, y)
print(g)

Solution (Python):
def gcd(m, n):
    r = m % n
    return gcd(n, r) if r else n

N, X = map(int, input().split())
*P, = map(int, input().split())
g = abs(X - P[0])
for i in range(1, N):
    g = gcd(g, abs(X - P[i]))
print(g)

Solution (Python):
def gcd(p):
	ret = p[0]
	def f(s,t):
		return f(t,s%t) if t else s
	for d in p:
		ret = f(ret,d)
	return ret
n,x=map(int,input().split())
print(gcd(list(map(lambda t:abs(int(t)-x),input().split()))))

Solution (Python):
num_str=input().split()
num=list(map(int, num_str))
n=num[0]
x=num[1]
num2_str=input().split()
distance=list(map(int, num2_str))

first_distance=list(map(lambda y:abs(y-x),distance))
min_distance=min(first_distance)

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


if n==1:
    print(first_distance[0])
else:
    element = gcd(first_distance[0], first_distance[1])
    if n==2:print(element)
    else:
        for i in range(2,n):
            element=gcd(element,first_distance[i])
        print(element)

Solution (Python):

def gcd(x, y):
    if y > x:
        x, y = y, x
    if y == 0:
        return x
    return gcd(y, x % y)


N, X = map(int, input().split())
x = [abs(X-int(x)) for x in input().split()]
if N == 1:
    print(x[0])
else:
    GCD = gcd(x[0], x[1])
    for i in range(2, N):
        GCD = gcd(GCD, x[i])
    print(GCD)

Solution (Python):
from functools import reduce
from fractions import gcd
N, X = map(int, input().split())
x = [abs(X-int(i)) for i in input().split()]
print(reduce(gcd, x))

Solution (Python):
import fractions
n,x=map(int,input().split())
l=list(map(int,input().split()))
m=[]
for i in l:
  m.append(abs(i-x))
n=m.pop(0)
for j in m:
  n=fractions.gcd(n,j)
print(n)

Solution (Python):
from fractions import gcd
n,x=map(int,input().split())
l=list(map(int,input().split()))
m=[]
for i in l:
  m.append(abs(i-x))
n=m.pop(0)
for j in m:
  n=gcd(n,j)
print(n)

Solution (Python):
def gcd(a,b):
    while b:
        a, b = b, a % b
    return a
N,X = map(int,input().split())
x = [int(i) for i in input().split()]
ans = abs(X-x[0])
now = X
for i in x:
    ans = gcd(ans, abs(now-i))
    now = i

print(ans)

Solution (Python):
import fractions
n, start = [int(i) for i in input().split()]
x_list = [int(i) for i in input().split()]

x_list.sort()

current_gcd = 0
for i in range(0, n):
    gap = abs(start - x_list[i])
    current_gcd = fractions.gcd(current_gcd, gap)

print(current_gcd)

Solution (Python):

from fractions import gcd


N, X = map(int, input().split())
pos = [int(x.strip()) for x in input().split()]


tikai = [i - X for i in pos]
kyori = list(map(abs,tikai))

a = kyori[0]
for xi in kyori[1:]:
    a = gcd(a, xi)
print(a)

Solution (Python):
def gcd(a, b):
	if b == 0:
		return 1
	_max = max(a, b)
	_min = min(a, b)
	rest = _max % _min
	if rest == 0:
		return _min
	else:
		return gcd(_min, rest)

N, X = map(int, raw_input().split())
x = map(int, raw_input().split())
x.sort()
	
for i in range(N):
	if X < x[i]:
		x.insert(i, X)
		break
if len(x) == N:
	x.append(X)
diff = []
for i in range(N):
	d = abs(x[i] - x[i+1])
	diff.append(d)

res = diff[0]
for i in range(N - 1):
	res = gcd(res, diff[i + 1])
print res

Solution (Python):
n,x = map(int, input().split())
city = list(map(int, input().split()))

def gcd(x, y):
    if x > y:
        x,y = y,x
    return gcd(y%x, x) if x else y

city.append(x)
city.sort()

dist = []
for i in range(len(city)-1):
    dist.append(abs(city[i]-city[i+1]))

if len(dist) < 2:
    min_dist = dist[0]
else:
    min_dist = 0
    for i in range(len(dist)-1):
        if min_dist == 0:
            min_dist = gcd(dist[i], dist[i+1])
        else:
            min_dist = min(min_dist, gcd(dist[i], dist[i+1]))

print(min_dist)

Solution (Python):
N, X = map(int, input().split())
x_list = list(map(int, input().split()))

x_list.sort()
def gcd(a, b):
    if a >= b:
        return a if b == 0 else gcd(b, a % b)
    else:
        return gcd(b, a)


D = abs(X-x_list[0])
for i in range(0, N):
    D = gcd(D,  abs(x_list[i]-X))

print(D)

Solution (Python):
from fractions import gcd
from functools import reduce

N, X = map(int, input().split())
x = [abs(int(x) - X) for x in input().split()]

print(reduce(gcd, x))

Solution (Python):
N, X = map(int,input().split(" "))
x = map(int, input().split(" "))
d = [abs(i-X) for i in x]
d_min = min(d)
def func(d_min,d):
  for i in range(d_min+1,0,-1):
    a=True
    for k in d:
      if k%i == 0:
        continue
      else:
        a = False
        break
    if a:
      return i
print(func(d_min,d))

Solution (Python):

import numpy as np
from functools import reduce
import fractions

def main():
    N, X = map(int, input().split())
    x = np.absolute([int(i)-X for i in input().split()])
    if N == 1:
        print(x[0])
    else:
        print(reduce(fractions.gcd, x))


if __name__ == '__main__':
    main()

Solution (Python):
import fractions

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

x = [X] + list(map(int, input().split()))
x.sort()

dic = []

for i in range(len(x) - 1):
    tmp = x[i + 1] - x[i]
    if tmp not in dic:
        dic.append(tmp)

ans = max(dic)

for i in range(len(dic) - 1):
    ans = min(ans, fractions.gcd(dic[i], dic[i + 1]))

print(ans)

Solution (Python):
from functools import reduce
def gcd(a,b):
  while b>0:
    a,b=b,a%b
  return a

n,x=map(int,input().split())
*l,=map(int,input().split())
*y,=map(lambda a:abs(a-x),l)
print(reduce(gcd,y))

Solution (Python):

import numpy as np
from functools import reduce
import fractions

def main():
    N, X = map(int, input().split())
    x = np.absolute(np.asarray([int(i) for i in input().split()]) - X)
    if N == 1:
        print(x[0])
    else:
        print(reduce(fractions.gcd, x))


if __name__ == '__main__':
    main()

Solution (Python):
import fractions

n,x = [int(i) for i in input().split()]

lis = list(map(int,input().split()))
diffs = []
for i in range(n):
    diff = abs(lis[i]-x)
    diffs.append(diff)


if len(diffs) > 1:
    com = fractions.gcd(diffs[0],diffs[1])
    for i in range(len(diffs)-2):
        com = fractions.gcd(com, diffs[i+2])
else:
    com = diffs[0]

print(com)

Solution (Python):

import numpy as np
import fractions

def main():
    N, X = map(int, input().split())
    x = np.asarray(list(map(int, input().split())))
    x = np.absolute(x - X)
    if N > 1:
        l = None
        for i, n in enumerate(x):
            if i == 0:
                l = n
            else:
                l = fractions.gcd(l, n)
        print(l)
    else:
        print(x[0])


if __name__ == '__main__':
    main()

Solution (Python):
def gcd(x, y):
    if x < y:
        x, y = y, x
    r = x % y
    res = y if r == 0 else gcd(y, r) 
    return res

N, X = map(int, input().split())
x = list(map(int, input().split()))
x2 = [abs(i - X) for i in x]

g = x2[0]
for i in x2:
    g = gcd(g, i)
print(g)

Solution (Python):
import fractions
from functools import reduce
 
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)
 
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
 
N,X =[int(i) for i in input().split()]
c = [int(i) for i in input().split()]
 
for i in range(N):
    c[i] = abs(c[i] - X)
 
print(gcd_list(c))

Solution (Python):
N, X = map(int, input().split())
A = list(map(int, input().split()))
diff = [abs(a - X) for a in A]


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


while len(diff) > 1:
    a, b = diff.pop(), diff.pop()
    diff.append(gcd(a, b))

print(diff[0])

Solution (Python):
def c_skip(N, X, Pos):
    from fractions import gcd
    from functools import reduce
    
    ans = reduce(gcd, [abs(X - x) for x in Pos])
    return ans

N, X = [int(i) for i in input().split()]
Pos = [int(i) for i in input().split()]
print(c_skip(N, X, Pos))

Solution (Python):
import fractions
from functools import reduce

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

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


N,X =[int(i) for i in input().split()]
c = [int(i) for i in input().split()]

for i in range(N):
    c[i] = abs(c[i] - X)

print(gcd_list(c))

Solution (Python):

import fractions
from functools import reduce

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

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

absList =[0] * len(toshiList)

for i in range(0,len(toshiList)):
    absList[i] = abs( toshiList[i] - X)

ans = reduce(fractions.gcd,absList)
    
print(ans)

Solution (Python):
import fractions
from functools import reduce

N, X = map(int, input().split())
XL = map(int, input().split())

R = reduce(fractions.gcd, [abs(X - x) for x in XL])

print(R)

Solution (Python):
n , x = map(int,input().split())

field = [int(i) for i in input().split()]

diff = list(map(lambda a:abs(a-x),field))

def gcd(x,y):
    
    if x < y:
        x,y = y,x

    if x % y == 0:
        return y
    else:
        return gcd(y,x%y)

ans = diff[0]


for i in diff[1:]:
    ans = gcd(i,ans)

print(ans)

Solution (Python):
import fractions

n,x=map(int,input().split())
z=[]
y=[]
z=list(map(int, input().split()))

for i in range(n):
  y.append(abs(x-z[i]))

if n==1:
  print(y[0])
else:
  gcm=y[0]
  for i in range(n):
    gcm=fractions.gcd(gcm,y[i])
  print(gcm)

Solution (Python):
n,m = map(int,input().split())
aa = list(map(int,input().split()))
 
bb = [abs(a-m) for a in aa]


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

    
ans = bb[0]
if len(aa) == 1:
    print(abs(aa[0]-m))
else:
    for b in bb:
        ans = gcd(ans,b)
    print(ans)

Solution (Python):
import fractions
from functools import reduce

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

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

N,X = map(int,input().split())
x = list(map(int,input().split(" ")))


for i in range(N):
	x[i] = x[i]-X

print(abs(gcd_list(x)))

Solution (Python):
N,X = map(int,input().split())
Z=list(map(int,input().split()))

D=[]

for i in range(N):
    D.append(abs(X-Z[i]))
    
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)
res = D[0]

for j in range(1, N):
    res = gcd(res, D[j])

print(res)

Solution (Python):
from fractions import gcd
def fun():
    nx = input()
    N, X = nx.split(' ')
    N = int(N)
    X = int(X)
    cities = [int(c) for c in input().split(' ')]
    cities.append(X)
    x = sorted(cities)
    nx = x[1:]
    dist = [nn - x[i] for i, nn in enumerate(nx)]
    if N==1:
        print(dist[0])
        return
    min_gcd = 10000000000
    for i, d in enumerate(dist[:-1]):
        dp = dist[i+1]
        gc = gcd(d, dp)
        if gc < min_gcd:
            min_gcd = gc
    print(min_gcd)

fun()

Solution (Python):

import fractions
 
n,X = map(int, input().split())
x = list(map(int,input().split()))
x.append(X)
x.sort()
y=[]
 
i=0
while i < n:
    y.append(x[i+1]-x[i])
    i +=1
y.sort()
 
y=list(set(y))
m=len(y)
z=y[0]
i=0
while i < m:
    z=fractions.gcd(z,y[i])
    i+=1
 
print(z)

Solution (Python):
n,x=map(int,input().split())
pos=list(map(int,input().split()))
pos2=[abs(p-x) for p in pos]
def make_divisor_list(num):
    if num < 1:
        return []
    elif num == 1:
        return [1]
    else:
        divisor_list = []
        divisor_list.append(1)
        for i in range(2, num // 2 + 1):
            if num % i == 0:
                divisor_list.append(i)
        divisor_list.append(num)
 
        return divisor_list

if n==1: ans=pos2[0]
else:
    minpos= min(pos2)
    divs=make_divisor_list(minpos)[::-1]
    if divs[0]==1:ans=1
    else:
        for j in divs:
            if all(x%j==0 for x in pos2):
                ans=j
                break
print(ans)

Solution (Python):
import numpy as np
import fractions
from functools import reduce
N,X = map(int,input().rstrip().split())
x = []
x = list(map(int,input().rstrip().split()))
x.append(X)
x.sort()


mini = []
for i in range(len(x)-1):
	mini.append(x[i+1] - x[i])
print(reduce(fractions.gcd, mini))

Solution (Python):
n,m = map(int,input().split())
aa = list(map(int,input().split()))
 
bb = [abs(a-m) for a in aa]

def gcd(a,b):
    while b:
        a, b = b, a % b
    return a
    
if len(aa) == 1:
    print(abs(aa[0]-m))
else:
    while len(bb) > 1:
        a, b = bb.pop(), bb.pop()
        bb.append(gcd(a,b))
    print(bb[0])

Solution (Python):
import fractions
N,X = map(int,input().split())
x = list(map(int,input().split()))
 
ans = 0
for i in range(N):
    ans = fractions.gcd(ans,abs(x[i]-X))
print(ans)

Solution (Python):
def gcd3(x,y):
    if x>=y:
        if x%y==0:
            return y
        else:
            return gcd3(y,x%y)
    else:
        if y%x==0:
            return x
        else:
            return gcd3(x,y%x)
def gcd2(x4):
    if len(x4)>2:
        return gcd3(gcd2(x4[:len(x4)//2]),gcd2(x4[len(x4)//2:]))
    elif len(x4) ==2:
        return gcd3(x4[0],x4[1])
    else:
        return x4[0]
N, X = map(int,input().split())
x=[int(i) for i in input().split()]
x.append(X)
x3=[]
for i in range(len(x)-1):
    x3.append(abs(x[i+1]-x[i]))
print(gcd2(x3))

Solution (Python):
N,X=map(int,input().split())
x=sorted(map(lambda x:abs(int(x)-X),input().split()))
for i in range(x[0]+1)[::-1]:
    if x[0]%i:continue
    if sum(map(lambda x:x%i,x))==0:
        print(i)
        break

Solution (Python):
N,X=map(int,input().split())
x=sorted(map(lambda x:abs(int(x)-X),input().split()))
for i in range(x[0]+1)[::-1]:
    if x[0]%i:continue
    if sum(map(lambda x:x%i,x))==0:
        print(i)
        break

Solution (Python):
from fractions import gcd

n,m = map(int,input().split())
x = [abs(int(i)-m) for i in input().split()]

res = x[0]

for i in x:
    res = gcd(res,i)

print(res)

Solution (Python):

import fractions
import numpy as np
 
N,X = map(int, input().split())
x = list(map(int,input().split()))
x.append(X)
x.sort()
 
x=np.array(x)
 
y=x[1:]-x[:-1]
 
y.sort()
y=list(set(y))
z=y[0]
m=len(y)
i=0
while i < m:
    z=fractions.gcd(z,y[i])
    i+=1
 
print(z)

Solution (Python):
def gcd(a,b):
    if a < b:
        a,b = b,a
    if a % b == 0:
        return b
    else:
        return gcd(b,(a % b))
 
N,X=map(int,input().split())
inputcities=list(map(int, input().split()))
cities=[abs(inputcities[i]-X) for i in range(N)]
cities.sort()
D=cities[0]
for i in range(N):
  D=gcd(D,cities[i])
print(D)