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):
N,X=map(int,input().split())
x=list(map(int,input().split()))
x=[abs(i-X) for i in x]

def gcm(a,b):
    if a<b:a,b=b,a
    c=a%b
    while c>0:
        a,b=b,c
        c=a%b
    return b

D=x[0]
for i in range(N):
       D=gcm(D,x[i])
print(D)

Solution (Python):
def gcd(A, B):
    while B != 0:
        A, B = B, A%B
    return A
N, X = map(int, input().split())
x = [abs(int(i) - X) for i in input().split()] 
y = x[0]
for i in range(N):
    if x[i] % y == 0:
        continue
    y = gcd(y, x[i])
print(y)

Solution (Python):
def gcd(A, B):
    if A%B == 0:
        return B
    else:
        return gcd(B, A%B)
N, X = map(int, input().split())
x = [abs(int(i) - X) for i in input().split()] 
if N == 1:
    print(x[0])
    exit()
gcd_x = []
for i in range(N-1):
    gcd_x.append(gcd(x[i], x[i+1]))
print(min(gcd_x))

Solution (Python):
import fractions
import functools

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

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

l = []
for i in range(n):
    l.append(abs(xi[i] - x))

ans = functools.reduce(fractions.gcd, l)

print(ans)

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

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

A.append(X)
sortedA = sorted(A)
B = [sortedA[i+1] - sortedA[i] for i in range(len(sortedA)-1)]

ans = reduce(gcd, B)
print(ans)

Solution (Python):

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

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

def GCD(lis):
    g = lis[0]
    for i in range(1,len(lis)):
        g = gcd( g , lis[i] )
    return g

maxD = GCD(distance)
print(maxD)

Solution (Python):

import sys

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

residual = [abs(x - X) for x in x_list]

def gcd(a,b):
    if(b==0):
        return a
    else:
        return gcd(b, a%b)
        
max_ = 0
for i in range(len(residual)):
    if(N==1):
        print(residual[0])
        break
    
    if(i == 0):
        max_ = gcd(residual[i], residual[i+1])
    elif(i == N-1):
        print(max_)
    else:
        max_ = gcd(residual[i], max_)

Solution (Python):
import fractions

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

min_distance = abs(x[0] - X)
for i in x: min_distance = fractions.gcd(abs(i - X), min_distance)

print(min_distance)

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

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

dx = [abs(X - v) for v in x]
ans = dx[0]
for b in dx[1:]:
    ans = gcd(ans, b)
print(ans)

Solution (Python):
import fractions
from functools import reduce

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

city_num, ori = list(map(int, input().split()))
cityies = list(map(int, input().split()))
stan = cityies[0]
difference = [abs(ori-stan)]

if len(cityies) > 1:
    for city in cityies[1:]:
        diff = abs(city - stan)
        difference.append(diff)

max_num = gcd(difference)
print(max_num)

Solution (Python):
from functools import *
N, X = list(map(int, input().split(" ")))
xs = list(map(int, input().split(" ")))
xs = list(map(lambda x: X-x if X>x else x-X, xs))
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b) 
r = reduce(gcd, xs)
print(r)

Solution (Python):
N,X = map(int,input().split())
list = [int(x) for x in input().split()]
list_dist = sorted([abs(x - X) for x in list])

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

ans = list_dist[0]

for x in list_dist[1:]:
    ans = gcd(ans,x)

print(ans)

Solution (Python):
from fractions import gcd
from functools import reduce
N, X = list(map(int, input().split()))
lst = list(map(lambda x: abs(int(x)-X), input().split()))
print(reduce(gcd, lst))

Solution (Python):
import fractions
from functools import reduce

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

a = input()
N = int(a.split(" ")[0])
X = int(a.split(" ")[1])

place = list(map(int,input().split(" ")))

b = []
place.append(X)
place.sort()
for i in range(len(place)-1):
    b.append(int(place[i+1]) - int(place[i]))
print(gcd_list(b))

Solution (Python):
from fractions import gcd 
n,x=map(int,input().split())
s=list(map(int,input().split()))
b=s[0]
t=abs(b-x)
for i in range(1,n):
    t=gcd(t,abs(s[i]-x))   
print(t)

Solution (Python):


from fractions import gcd
from functools import reduce

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

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

d = reduce(gcd, dist_list)

print(d)

Solution (Python):


from fractions import gcd 

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

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

if n == 1:
    d = dist_list[0]
else:
    d = gcd(dist_list[1], dist_list[0])
    for i in range(n-2):
        d = gcd(d, dist_list[i+1])

print(d)

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

n,x = map(int, input().split())
list_x = list((map(int, input().split())))
list_x.append(x)
list_x.sort()
list_dist = []
for i in range(0,n):
    list_dist.append(list_x[i+1] - list_x[i])
gcd1 = list_dist[0]
for i in range(1,n):
    gcd1 = gcd(gcd1, list_dist[i])
print(gcd1)

Solution (Python):


from functools import reduce
from fractions import gcd


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

"""
出発地点Xは決まっている
一番近いところと、一番遠いところを考えたとき、最大公約数を求めればいいのでは？
これが全部の公約数になってないといけないかな？

まず、一番近いところを決める
この約数を求める
一番大きいやつに決定する
"""



x.append(X)

sa = [abs(x[i+1]-x[i]) for i in range(N)]

answer = reduce(gcd, sa)

print(answer)

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

n,x_ = map(int, input().split())
x = list(map(int, input().split()))
x.append(x_)
sa = [abs(x[i+1]-x[i]) for i in range(n)]
d = reduce(gcd,sa)
print(d)

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

n,x_ = map(int, input().split())
x = list(map(int, input().split()))
x.append(x_)
sa = [abs(x[i+1]-x[i]) for i in range(n)]
d = reduce(lambda a,b:gcd(a,b),sa)
print(d)

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

n,x_ = map(int, input().split())
x = list(map(int, input().split()))
x.append(x_)
x.sort()
sa = [x[i+1]-x[i] for i in range(n)]
d = reduce(lambda a,b:gcd(a,b),sa)
print(d)

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

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

def func(x,n):
    x.sort()
    y = [abs(x[i+1]-x[i]) for i in range(n-1)]
    kotae = reduce(lambda a,b:gcd(a,b),y)
    print(kotae)

if x_ in x:
    func(x,n)
else:
    x.append(x_)
    func(x,n+1)

Solution (Python):
import fractions
from functools import reduce

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

gratest_common_facter = reduce(fractions.gcd, distance)
print(gratest_common_facter)

Solution (Python):


from fractions import gcd
from functools import reduce






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

nanka = [abs(X - c) for c in CITY]
print(reduce(lambda x, y: gcd(x, y), nanka))

Solution (Python):
N,X=map(int,input().split())
x=list(map(int,input().split()))
absx=[]
for i in range(len(x)):
    absx.append(abs(x[i]-X))
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

from functools import reduce

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

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

xarr.append(x)

xarr.sort()

arr2 = []
for i in range(len(xarr)-1):
	arr2.append(xarr[i+1]-xarr[i])

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

gc = 0

if len(arr2) > 1:
	gc = gcb(arr2[0],arr2[1])
	for y in range(len(arr2)-1):
		gc = gcb(gc,arr2[y+1])
else:
	gc = arr2[0]
	
print(gc)

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

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

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

D = x[0]

for i in range(0,N):
    D = gcd(D,x[i])

D = abs(D)
print(D)

Solution (Python):

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

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

ans = abs(x[0]-X)
for xi in x:
    ans = gcd(ans, abs(xi-X))
    
print(ans)

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

def main():
    N,X = (int(i) for i in input().split())
    x=list(map(int,input().split()))

    gcd_l = []
    

    for i in range(0,N):
        gcd_l.append(abs(X-x[i]))
    if N==1:
        ans = gcd_l[0]
    else:
        a = [gcd_l[0],gcd_l[1]]
        ans = gcd(max(a),min(a))
        for n in range(2,len(gcd_l)):
            a = [ans,gcd_l[n]]
            ans = gcd(max(a),min(a))
    print(ans)

main()

Solution (Python):


import sys

def solve(bigN, bigX, xs):
    ys = [abs(x - bigX) for x in xs]
    g = ys[0]
    for y in ys[1:]:
        g = gcd(y, g)
    return g

def gcd(a, b):
    '''The greatest common divisor of a and b.'''
    while b > 0:
        (a, b) = (b, a % b)
    return a

def readQuestion():
    [line1, line2] = list(sys.stdin)
    [bigN, bigX] = [int(s) for s in line1.split(' ')]
    xs           = [int(s) for s in line2.split(' ')]
    return (bigN, bigX, xs)

def main():
    bigN, bigX, xs = readQuestion()
    answer = solve(bigN, bigX, xs)
    print(answer)
    
if __name__ == '__main__':
    main()

Solution (Python):


import sys

def solve(bigN, bigX, xs):
    ys = [abs(x - bigX) for x in xs]
    g = ys[0]
    for y in ys[1:]:
        g = gcd(g, y)
    return g

def gcd(a, b):
    '''The greatest common divisor of a and b'''
    if b < a:
        (a, b) = (b, a)
    while True:
        x = a % b
        if x == 0:
            return b
        (a, b) = (b, x)

def readQuestion():
    [line1, line2] = list(sys.stdin)
    [bigN, bigX] = [int(s) for s in line1.split(' ')]
    xs           = [int(s) for s in line2.split(' ')]
    return (bigN, bigX, xs)

def main():
    bigN, bigX, xs = readQuestion()
    answer = solve(bigN, bigX, xs)
    print(answer)
    
if __name__ == '__main__':
    main()

Solution (Python):
import fractions
from functools import reduce
def func():
    n,x0 = map(int,input().split())
    x = [int(i) for i in input().split()]
    x.append(x0)
    x.sort()
    x.reverse()
    
    l = []
    before = 0
    before = None
    for xi in x:
        if before == None:
            before = xi
            continue
        l.append(xi-before)
        before = xi
    
    print(abs(reduce(fractions.gcd,l)))
func()

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

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

def gcd(a,b):
    n = max(a,b)
    m = min(a,b)
    if n%m==0:
        return m
    else:
        return gcd(m,n%m)


c.sort()
ans = c[1]-c[0]

for i in range(n-1):
    ans = gcd(ans,c[i+2]-c[i+1])

print(ans)

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

n, x = list(map(int, input().split()))
list = list(map(int, input().split()))
list = [abs(i - x) for i in list]
min = min(list)
for num in list:
    min = gcd(min, num)
print(min)

Solution (Python):
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
    while x[i] != 0:
        y, x[i] = x[i], y % x[i]
print(y)

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())
xs = list(map(int, input().split()))
xs.append(X)
xs.sort()
D = xs[1] - xs[0]
for i in range(N):
    d = xs[i+1] - xs[i]
    D = gcd(d, D)
    if D == 1:
        print(1)
        break
else:
    print(D)

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

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

Solution (Python):
n, place = [int(x) for x in input().split(' ')]
city_address = sorted([abs(int(x) - place) for x in input().split(' ')], reverse=True)
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

answer = city_address[0]
for address in city_address:
	answer = gcd(answer, address)

print(answer)

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

Solution (Python):
n, x = map(int, input().split())
x_list = [int(i) for i in input().split()]

diff_list = [max(x, x_list[i])-min(x, x_list[i]) for i in range(n)]

def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    while y > 0:
        x, y = y, x%y
    return x

def multi_gcd(a):
    z = 0
    for i in a:
        z = gcd(i, z)
    return z
  
if __name__ == "__main__":
  ans = multi_gcd(diff_list)
  print(ans)

Solution (Python):
c, d = (int(i) for i in input().split())  
a = [int(i) for i in input().split()]
b = a.copy()
 
k = 0
for i in a:
    b[k] = abs(i - d)
    k += 1
 
m = min(b) 
 
def dec():
 
    i = m
    while i > 0:
        if m% i == 0: 
            k = 0
            for j in b:
                if j%i ==0:
                    k +=1
                if k==len(b):
                    return i
                
            if i == m:
                i -= i//2
                
        i -=1
 
 
 
 
                
print(dec())

Solution (Python):
import fractions

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

Solution (Python):

def euclid(a,b):
    if b == 0:
        return a 
    else:
        return euclid(b,a%b)
n,x = map(int,input().split())
cit = list(map(lambda i:int(i)-x,input().split()))

d = cit[0]

for i in range(n-1):
    d = euclid(d,cit[i+1])
    if d == 1:
        break
print(abs(d))

Solution (Python):
n,x = map(int, input().split())
l = [ abs(i - x) for i in list(map(int, input().split()))]
l.sort(reverse=True)
l = list(set(l))
if len(l) == 1:ans = l[0]
else:
  while len(l) != 1:
    l.sort(reverse=True)
    l.append(0)
    l = [ l[i] - l[i+1] for i in range(len(l) - 1)]
    l = list(set(l))
    for i in l:
      if i % min(l) != 0:break
    else:
      l[0] = min(l)
      break
  ans = l[0]
print(ans)

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


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

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


ans = ds[0]
for d in ds[1:]:
    ans = gcd(ans, d)


print(ans)

Solution (Python):
n,k=map(int,input().split())
t=[]
s=list(map(int,input().split()))
for i in s:
    t.append(abs(i-k))
from fractions import gcd
from functools import reduce
print(reduce(gcd,t))

Solution (Python):
from functools import reduce
import fractions
N, X = [int(i) for i in input().split()]
x = [int(x) for x in input().split()]
x.append(X)
x.sort()

distance = []
for i,xe in enumerate(x):
    if i is not 0:
        distance.append(xe - x[i-1])

print(reduce(fractions.gcd, distance))

Solution (Python):
def gcd(numbers):
    _min = numbers[0]
    tmp = sorted([_n % _min for _n in numbers])
    return _min if tmp[-1] == 0 else gcd(sorted([_t if _t > 0 else _min for _t in tmp]))


def solve(string):
    ins = string.split("\n")
    n, x = map(int, ins[0].split(" "))
    xs = list(map(int, ins[1].split(" ")))
    xs.append(x)
    xs = sorted(xs)
    diff = [_n - _p for _p, _n in zip(xs, xs[1:])]
    return str(gcd(diff))


if __name__ == '__main__':
    tmp = [input(), input()]
    print(solve('\n'.join(tmp)))

Solution (Python):
a=input().split()
b=input().split()
N=int(a[0])
X=int(a[1])
Xm=[abs(int(i)-X) for i in b]
def f(x,y):
    if y > x:
        x,y = y,x
    else:
        pass
    while x%y!=0:
        z = x%y
        x = y
        y = z
    return y
if len(Xm) ==1:
    print(Xm[0])
else:
    c = f(Xm[0],Xm[1])
    for i in range(len(Xm)-2):
        c=f(c,Xm[i+2])
    print(c)

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


def allgcd(d):
    if len(d) == 1:
        return d
    ret_gcd = d[0]
    for i in d:
        ret_gcd = gcd(ret_gcd, i)
    return ret_gcd


def maxNumVisitCity(N, X, x):
    if len(x) == 1:
        return abs(x[0] - X)

    d = []
    for i in x:
        d.append(abs(i - X))
    return allgcd(d)


def main():
    N, X = map(int, input().split())
    x = list(map(int, input().split()))
    print(maxNumVisitCity(N, X, x))


if __name__ == '__main__':
    main()

Solution (Python):


import functools

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

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

dist = [abs(x[i] - X) for i in range(N)]
D = functools.reduce(gcd, dist)

print(D)

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

for i in range(len(city)):
	sub.append(abs(x - city[i]))

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


if len(sub) == 1:
	print(sub[0])
elif len(sub) == 2:
	print(gcd(sub[0],sub[1]))
else:
	p = gcd(sub[0], sub[1])
	for i in range(2,len(sub)):
		p = gcd(p,sub[i])
	print(p)

Solution (Python):
from functools import reduce

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

a_x = sorted([abs(a - x) for a in a_s])

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

x = reduce(gcd, a_x)
print(x)

Solution (Python):
import functools as ft
 
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)
 
def gcd_list(numbers):
    return ft.reduce(gcd,numbers)
 
N, X = map(int, input().split(" "))
Xi = [int(a) for a in input().split()]
 
def MinusX(Xi_):
    return abs(Xi_-X)
 
def main(Xi):
    Xi = map(MinusX,Xi)
    output = gcd_list(Xi)
    print(output)
 
if __name__ == "__main__":
    main(Xi)

Solution (Python):
import functools as ft

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

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

N, X = map(int, input().split(" "))
Xi = [int(a) for a in input().split()]

def MinusX(Xi_):
    return abs(Xi_-X)

def main(Xi):
    Xi = map(MinusX,Xi)
    output = gcd_list(Xi)
    print(output)

if __name__ == "__main__":
    main(Xi)

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

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

dist = [abs(X - x) for x in xi]
print(reduce(gcd, dist))

Solution (Python):
from sys import stdin


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

    if b > 0:
        return EuclideanAlgorithm(b, a % b)
    else:
        return a


N, X = [int(a) for a in stdin.readline().rstrip().split()]
x = [int(a) for a in stdin.readline().rstrip().split()]

if len(x) == 1:
    print(abs(X - x[0]))
else:
    for i in range(len(x)):
        x[i] = abs(X - x[i])

    ans = EuclideanAlgorithm(x[0], x[1])
    for i in range(2, len(x)):
        ans = EuclideanAlgorithm(ans, x[i])

    print(ans)

Solution (Python):
from functools import reduce

def gcd(a, b):

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

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

N, X = map(int, input().split(" "))
Xi = [int(a) for a in input().split()]

def minusX(a):
    return abs(a-X)

Xi = map(minusX, Xi)

d = gcd_list(Xi)
print (d)

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

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

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

N, X = tuple(map(int, input().split(" ")))
Xs = [X] + list(map(int, input().split(" ")))
Xs = map(abs, np.diff(Xs))
r = gcd_list(Xs)
print(r)

Solution (Python):
import math
from collections import defaultdict


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


def main():
    N, X = [int(a) for a in input().split()]
    Xs = [int(a) for a in input().split()]

    xs = sorted(Xs)
    a = [abs(k - X) for k in xs]

    res = a[0]
    for k in a[1:]:
        res = gcd(res, k)
    print(res)


if __name__ == '__main__':
    main()

Solution (Python):
from functools import reduce

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


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

print(gcd_list(delta_x))

Solution (Python):
import numpy as np
from fractions import gcd
from functools import reduce
n,x = map(int, input().split())
xs = np.asarray(list(map(int, input().split())))
diff = np.abs(xs-x)
print(reduce(gcd, diff))

Solution (Python):
n, x =  map(int, input().split())
xi = map(int, input().strip().split())
c = [x] * n
xi = [x - y for (x,y) in zip(xi,c)]
def gcd(a, b):
  if b == 0: return a
  return gcd(b, a % b)
d0 = xi[0]
for i in range(n-1):
    d = gcd(xi[i+1],d0)
    d0 = d
if len(xi) == 1:
  d = xi[0]
print(abs(d))

Solution (Python):
from fractions import gcd
N,X=map(int,input().split())
A=[abs(int(i)-X) for i in input().split()]
ma=A[0]
for a in A:
    ma=gcd(ma,a)
print(ma)

Solution (Python):
import numpy as np

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

N, X = map(int, input().split())
towns = list(map(int, input().split()))
towns.insert(0, X)

diff_towns = np.abs(np.diff(towns))
if len(diff_towns) == 1:
    cand = diff_towns[0]
else:
    cand = gcd(diff_towns[0], diff_towns[1])
    for i in range(2,len(diff_towns)):
        cand = gcd(cand, diff_towns[i])    

print(cand)

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

    return a

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



if N == 1:
    print(abs(cities[0]))
else:
    ans = gcd(cities[0],cities[1])

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

    print(abs(ans))

Solution (Python):
import fractions
n, fx = map(int, input().split())
x = list(map(int, input().split()))
x.append(fx)
x.sort()

ans = x[1]-x[0]
for i in range(2, len(x)):
  v = x[i]-x[i-1]
  ans = fractions.gcd(ans, v)

print(ans)

Solution (Python):



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


a, b = map(int, raw_input().split())
c = map(int, raw_input().split())

c = [abs(c[i]-b) for i in range(a)] 


g = c[0]
for z in c:
    g = gcd(g,z)
print g

Solution (Python):
import fractions

n, x = map(int, input().split())
num = list(map(int,input().split()))
d = abs(num[0]-x)
for nn in num:
	d=fractions.gcd(d, abs(nn-x))
print(d)

Solution (Python):
import fractions

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

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

t = abs(x[0] - X)
for a in x:
    t = fractions.gcd(t, abs(a - X))
print(t)

Solution (Python):
def gcd(a, b):
    if a > b:
        a, b = b, a
    while a:
        a, b = b%a, a
    return b
N,x1 = map(int, input().split())
xs = list(map(int, input().split()))
xs.append(x1)
xs.sort()
margin = [y-x for y,x in zip(xs[1:],xs[:-1])]
m = margin[0]
for x in margin[1:]:
    m = gcd(m,x)
print(m)

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

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

Solution (Python):
import fractions
N, X = map(int, input().split())
x = map(int, input().split())
r = abs(next(x) - X)
for i in x:
    r = fractions.gcd(r, abs(i - X))
print(r)

Solution (Python):
import fractions
N, X = map(int, input().split())
x = map(int, input().split())
r = abs(next(x)-X)
for i in x:
    r = fractions.gcd(r, abs(i-X))
print(r)

Solution (Python):
from fractions import gcd
from functools import reduce
n, x = map(int, input().split())
input_list = list(map(int, input().split()))
x_list = list()
for i in input_list:
  x_list.append(abs(x - i))
  x = i
  
print(reduce(gcd, x_list))

Solution (Python):
from fractions import gcd
from functools import reduce
n, x = map(int, input().split())
input_list = list(map(int, input().split()))
x_list = list()
for i in input_list:
  x_list.append(abs(x - i))
  x = i
  
print(reduce(gcd, x_list))

Solution (Python):
import sys
input = sys.stdin.readline
import math

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

d = [abs(X-x[i]) for i in range(N)]
oppai = d[0]

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


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

print(oppai)

Solution (Python):
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)
n, x = map(int, raw_input().split())
d = map(int, raw_input().split())
g = abs(x - d[0])
for z in d:
    g = gcd(g, abs(z - x))
print g

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

x = list(map(int, input().split()))
minx = min(min(x), x0)

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

gcdx = x0 - minx
for xx in x:
    gcdx = gcd(gcdx, xx-minx)

print(gcdx)

Solution (Python):


N, X = map(int,input().split())
R = input().split()
for i in range(len(R)):
    R[i] = int(R[i])
def real(n):
    if n >= 0:
        return n 
    else:
        return -1*n 
moto = []
for i in R:
    moto.append(real(i-X))
ans = min(moto)
for i in moto:
    if i % ans != 0:
        ans = i % ans
print(ans)

Solution (Python):
import fractions
import traceback
n,x=map(int,input().split())
citys=list(map(int, input().split()))
mod_citys=citys
for i in range(len(mod_citys)):
    mod_citys[i]-=x
    if(mod_citys[i]<0):
        mod_citys[i] *= -1
if(len(mod_citys)==1):
    print(mod_citys[0])
elif(len(mod_citys)==2):
    print(fractions.gcd(mod_citys[0],mod_citys[1]))
else:
    mod_citys = sorted(mod_citys, reverse=False)
    spmin = 9999999999999
    pod = 0
    for i in range(len(mod_citys)):
        try:
            pod=fractions.gcd(mod_citys[i],mod_citys[i+1])
            if(pod<spmin):
                spmin=pod
        except:
            pass
    print(spmin)

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

import numpy as np
n, x = map(int, input().split())
a = np.abs(np.array(list(map(int, input().split())))-x)

if(a.shape[0] == 1):
	r = a[0]
else:
	r = gcd(a[0], a[1])
	for i in range(n-2):
		r = gcd(r, a[i+2])
print(r)

Solution (Python):
import fractions
from functools import reduce

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

for i in range(len(a)):
	a[i] = abs(a[i] - x)

print(reduce(fractions.gcd, a))

Solution (Python):
from functools import reduce

def lcm(a, b):
  if b > a:
    a, b = b, a
  
  while b != 0:
    a, b = b, a % b
  
  return a

city_num, start = map(int, input().split())

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

for i in range(len(cities)):
  cities[i] = abs(start - cities[i])

cities.sort()
  
a = reduce(lcm, cities)  

print(a)

Solution (Python):
def lcm(a, b):
  if b > a:
    a, b = b, a
  
  while b != 0:
    a, b = b, a % b
  
  return a

city_num, start = map(int, input().split())

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

for i in range(len(cities)):
  cities[i] = abs(start - cities[i])

cities.sort()

a = cities[0]
for num in cities[1:]:
  a = lcm(a, num)
  
print(a)

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

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

def gcd_l(*numbers):
	ret = numbers[0]
	for n in numbers[1:]:
		ret = gcd(ret, n)
	return ret

xi = map(lambda y:abs(y-x), xi)
print(gcd_l(*xi))

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

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

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

ans = gcd(abs(inp[1]-p[0]), abs(inp[1]-p[0]))
for i in range(len(p)):
    ans = gcd(ans, abs(inp[1]-p[i]))

print(ans)

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

Solution (Python):
n, x = map(int, input().split())
c = list(map(int, input().split()))
c = set([abs(x-c[i]) for i in range(n)])
l = min(c)
for i in range(l+1, 0, -1):
    if l % i == 0:
        d = True
        for item in c:
            if item % i != 0:
                d = False
        if d:
            print(i)
            break

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

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

y = [abs(y_i-x) for y_i in y]
m = y[0]
for y_i in y[1:]:
	m = gcd(m, y_i)
print(m)

Solution (Python):
import sys
n,x = map(int, input().split())
a = list(map(int, input().split()))
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

if len(a)==1:
  print(abs(x-a[0]))
  sys.exit()

g = gcd(abs(x-a[0]), abs(x-a[1]))
for i in range(2,n):
  g = gcd(g, abs(x-a[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())
A = [int(i) for i in input().split()]


def aho(x):
  return x - X


B = list(map(aho, A))

C = gcd_list(B)

print(abs(C))

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

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

lis=[abs(j-X) for j in x]

print(reduce(gcd,lis))