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, raw_input().split())
lis = sorted(map(int, raw_input().split()))
def gcd(a, b):
    if a == 0:
        return b
    return gcd(b%a,a)
if n == 1:
    val = abs(lis[0]-x)
    print val
    exit()
val = 0

for i in xrange(n):
    lis[i] -= x
    val = gcd(abs(lis[i]), val)
print val

Solution (Python):
import functools
import fractions
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = []
d = []
co = 0
for i in range(a[0]):
	c.append(abs(b[i]-a[1]))
	if b[i]-a[1] > 0 and co == 0:
		c.insert(i,0)
		co += 1
if co == 0:
	c.append(0)

for i in range(len(c)-1):
	d.append(abs(c[i+1]-c[i]))
print(functools.reduce(fractions.gcd, d))

Solution (Python):


import sys

input = sys.stdin.readline
n, x = map(int, input().split())
a = input().split()
b = list(map(int, a))
b.append(x)
b.sort()
if len(b) == 2:
    print(b[1] - b[0])
    exit(0)
c = [abs(a - x) for a in b]


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


ans = c[0]
for i in range(len(c)):
    ans = gcd(c[i], ans)
print(ans)

Solution (Python):
import fractions
n, x = map(int, input().split())
xl = [int(_) for _ in input().split()]
for i in range(n):
    if x > xl[i]:
        xl[i] = x - xl[i]
    else:
        xl[i] = xl[i] - x

x_gcd = xl[0]
if n > 1:
    for i in range(1, n):
        x_gcd = fractions.gcd(x_gcd, xl[i])
print(x_gcd)

Solution (Python):
from functools import reduce
N,X=map(int,input().split())
x=list(map(int,input().split()))
L=x+[X]
if N==1:
	print(abs(X-x[0]))
else:
	LL=[abs(L[i+1]-L[i]) for i in range(N)]
	def gcd(a,b):
		while b>0:
			a,b=b,a%b
		return a
	print(reduce(gcd,LL))

Solution (Python):
list1 = list(map(int, input().split()))
n = list1[0]
x = list1[1]
list2 = list(map(int, input().split()))
list2.append(x)
list2.sort()

list3 = []
list4 = []
length = len(list2)
index =1
while index < length:
    list3.append(list2[index]-list2[index-1])
    index+=1

list3.sort()
mimN = list3[0]
ans =0
index2 =mimN
if len(list3) ==1:
    print(mimN)
else:
    flag2 =0
    for number in list3:
       if number%mimN !=0:
           flag2 =1
    if flag2 ==0:
        print(mimN)
    else:
        while index2>=1:
            flag=0
            for number in list3:
                if number%index2 ==0:
                    flag =1
                else:
                    flag =0
                    break
            if flag ==1:
                ans = index2
                break
            else:
                index2-=1       
        print(ans)

Solution (Python):
from functools import reduce

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

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

sa = [0] * n
for i in range(n):
    sa[i] = abs(start - x[i])

print(reduce(gcd, sa))

Solution (Python):
import functools
import fractions
N,X = map(int,input().split())
x = list(map(int,input().split()))
x.append(X)
x.sort()
l = [x[i+1]-x[i] for i in range(N)]
gcd = functools.reduce(fractions.gcd,l)
print(gcd)

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

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

def get_res(cities):
    if len(cities) == 2:
        return cities[1] - cities[0]
    else:
        gcds = []
        for i in range(len(cities) - 2):
            c1 = cities[i]
            c2 = cities[i + 1]
            c3 = cities[i + 2]
            gcds.append(gcd(c2 - c1, c3 - c2))
        return min(gcds)

print(get_res(cities))

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())
x = input().split()
for i in range(N):
    x[i] = int(x[i])

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

print(D)

Solution (Python):
from functools import reduce

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

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


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

for i in range(len(x)):
    y = abs(int(x[i]) - X)
    Y.append(y)
    
D = gcd_l(Y)

print(D)

Solution (Python):
import math

def is_common(dists, factor):
    count = 0





    for dist in dists:
        if dist % factor != 0:
            return False
    
    return True

def divide_to_prime_factors(num):
    factor = 1
    factors = []

    while factor <= math.sqrt(num):
        if num % factor == 0:
            factors.append(factor)
            if factor * factor != num:
                factors.append(int(num / factor))

        factor += 1

    return factors

n_and_x = input().split(" ")
city_num = int(n_and_x[0])
start = int(n_and_x[1])

city_places = [int(n) for n in input().split(" ")]

city_distances = []
for place in city_places:
    city_distances.append(abs(place - start))

dist_factors = reversed(sorted(divide_to_prime_factors(city_distances[0])))

step = 1
for fact in dist_factors:
    if is_common(city_distances[1:], fact):
        step = fact
        break













print(step)

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

def gcdlist(l):
    if len(l) == 2:
        return gcd(l[0], l[1])
    f = l.pop()
    s = l.pop()
    m = gcd(f, s)
    l.append(m)
    return gcdlist(l)


def main():
    n, x = map(int, input().split())
    a = [int(v) for v in input().split(' ')]
    a.append(x)
    a.sort()
    dis = [x2 - x1 for x1, x2 in zip(a, a[1:])]
    max_ = 0
    for i in range(n):
        if len(dis) == 1:
            max_ = dis[0]
            break
        try:
            max_ = gcdlist(dis)
        except:
            max_ = 1
    print(max_)

if __name__ == '__main__':
    main()

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

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

def gcd(la, lb):
    if la < lb:
        tmp = a
        la = lb
        lb = tmp

    r = la % lb

    while r != 0:
        la = lb
        lb = r
        r = la % lb

    return lb

ans = 1000000001
for i in range(n):
    v = abs(x - a[i])

    if v < ans:
        ans = v

    g = gcd(v, ans)
    if g < ans:
        ans = g

print(ans)

Solution (Python):
import functools
import math
import fractions
n, x = map(int, input().split())
xx = list(map(int, input().split()))  
xx.append(x)
xx.sort()
diff = []  
d = 0
if len(xx) > 2:
    for i in range(1, len(xx)):
        diff.append(abs(xx[i - 1] - xx[i]))
    d = functools.reduce(fractions.gcd, diff)
else:
    d = abs(xx[0] - xx[1])
print(d)

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

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

Solution (Python):
import math as mh
import fractions as fr
from functools import reduce

n, p = (int(_) for _ in input().split())
x = list(int(_) for _ in input().split())
x.append(p)
x.sort()

dx = []
for i in range(1,len(x)):
    dx.append(x[i] - x[i-1])

exgcd = reduce(fr.gcd, dx)
print(exgcd)

Solution (Python):
n,x = map(int,input().split())
a = list(map(int,input().split()))
a.append(x)
a.sort()
d = [1000000000]
e = []
flg = False
for i in range(len(a)-1):
  t = a[1+i] - a[i]
  e.append(t)
  if(t < d[0]):
    d.insert(0,t)
  if(t == 1):
    flg = True
    break
if(flg):
  print(1)
else:
  d.sort()
  l = len(d)
  ans = 1
  for i in range(l):
    u = list(map(lambda x: x% d[l - 1 - i],e))
    if(u.count(0) == n):
      ans = d[l-1-i]
      break
  if(ans == 1):
    k = d[0]
    f = []
    j = 2
    while True:
      s = int(k/j)
      if(k % j == 0):
        f.insert(0,s)
      if(s < 1):
        break
      j += 1
    q = len(f)
    for i in range(q):
      u = list(map(lambda x: x% f[q - 1 - i],e))
      if(u.count(0) == n):
        ans = f[q-1-i]
        break

  print(ans)

Solution (Python):



def main():
    from fractions import gcd
    from functools import reduce

    n, large_x = map(int, input().split())
    x = sorted(list(map(lambda x: int(x) - large_x, input().split())) + [0])

    diff = [0 for _ in range(n + 1)]

    for i in range(1, n + 1):
        diff[i] = x[i] - x[i - 1]

    ans = reduce(gcd, diff)

    print(ans)


if __name__ == '__main__':
    main()

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

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

def gcd(a, b):
    """Calculate the Greatest Common Divisor of a and b.

    Unless b==0, the result will have the same sign as b (so that when
    b is divided by it, the result comes out positive).
    """
    while b:
        a, b = b, a%b
    return a

def solve():
    x.append(X)

    sorted_x = sorted(x)
    sorted_aaa = []

    aaa = []

    for (i, item) in enumerate(sorted_x):
        if i == 0:
            continue
        aaa.append(int(sorted_x[i] - sorted_x[i - 1]))

    sorted_aaa = sorted(aaa)
    res = 100000000
    
    for (k, elm) in enumerate(sorted_aaa):
        if len(sorted_aaa) == 1:
            res = sorted_aaa[k]
            break
        if k == 0:
            continue
        g = gcd(sorted_aaa[k - 1], sorted_aaa[k])
        if g < res:
            res = g
    print(res)


if __name__ == '__main__':
    solve()

Solution (Python):
l = input().split(" ")
n = int(l[0])
x = int(l[1])
l = input().split(" ")
for i in range(n):
    l[i] = int(l[i])
for i in range(n):
    l[i] = l[i]- x
l.append(0)
l = sorted(l, reverse=True)
ll = []
for i in range(n):
    ll.append(l[i]-l[i+1])
ll = sorted(list(set(ll)),reverse = True)
def gcd( x, y ):
    while y != 0:
        x, y = y, x%y
    return x
for i in range(len(ll)-1):
   ll[i+1] = gcd(ll[i],ll[i+1])
print(ll[-1])

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

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

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

for i in range(len(x)-1):
    li.append(max(abs(x[i]-x[i+1]), (abs(x[i+1]-x[i]))))
temp=abs(min(x))
li.append(temp)


if f:
    a=li[0]
    for i in range(len(li)-1):
        a=gcd(a, li[i+1])
    print(a)

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

N, X  = (int(i) for i in input().split())
x = (int(i) for i in input().split())
x = list(x)
x.append(X)

x = sorted(x)

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

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())
xlist =[X]
xlist.extend(list(map(int, input().split())))
dlist =[]
for i in range(N):
    dlist.append(abs(xlist[i+1]-xlist[i]))
g = max(dlist)
for d in dlist:
    g = gcd(g, d)
print(g)

Solution (Python):
import fractions
from functools import reduce

N, X = map(int, input().split())
if N == 1:
    x = abs(X - int(input()))
    print(x)
else:
    x = list(map(int, input().split()))
    x = list(map(lambda i: abs(X - i), x))
    print(reduce(fractions.gcd, x))

Solution (Python):
def g(a,b):x=max([a,b]);y=min([a,b]);return g(y,x%y) if x%y else y
N,X=map(int,input().split());p=[abs(int(i)-X) for i in input().split()];ans=p[0]
for i in range(1,N):ans=g(ans,p[i])
print(ans)

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

city = [abs(int(x) - X) for x in input().split(' ')]
max_fact = city[0]

for x in city:
    while x!=0:
        x %= max_fact
        if x > 0:
            tmp = max_fact
            max_fact = x
            x = tmp
    if max_fact==1:
        break

print(max_fact)

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

if x in x_list:
    pass
else:
    x_list.append(x)
    x_list.sort()

min_diff = 99999999999
for i in range(len(x_list) - 1):
    diff = x_list[i + 1] - x_list[i]
    if min_diff > diff:
        min_diff = diff


x_diff = [xx - x_list[0] for xx in x_list]

for i in range(1, min_diff):
    if min_diff % i != 0:  
        continue
    xx = min_diff // i
    is_divided = [j for j in x_diff if j % xx != 0]
    if len(is_divided) == 0:
        print(xx)
        exit()
print(1)

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

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

kouho=[abs(l[i]-x) for i in range(n)]

ans=kouho[0]

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

Solution (Python):


from fractions import gcd
from functools import reduce

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

i = input().split(' ')
N = int(i[0])
X = int(i[1])
xs = list(map(lambda x: int(x), input().split(' ')))
ds = list(map(lambda x: abs(X-x), xs))


l = gcd_list(ds)
print(l)

Solution (Python):
n,x = map(int,input().split())
x_list = list(map(int,input().split()))
x_list.append(x)
x_list = sorted(x_list)
a = []
for i in range(n):
    b = x_list[i+1]-x_list[i]
    a.append(b)
import math
from functools import reduce
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
ans = reduce(gcd, a)
print(int(ans))

Solution (Python):

import fractions as math
N, X = map(int, input().split())
x = list(map(int, input().split()))
x.append(X)
x.sort()
diff = [x[i] - x[i-1] for i in range(1,len(x))]
gcf = diff[0]
for d in diff:
    gcf = math.gcd(gcf, d)
print(gcf)

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

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

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

distances = []
for city in cities:
    distances.append(abs(city - x))

result = distances[0]

for d in distances:
  result = gcd(result, d)

print(result)

Solution (Python):
import numpy as np

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

n, X = map(int, input().split())
if n==1:
    x = int(input())
    print(abs(x-X))
    quit()    
else:
    x = list(map(int, input().split()))

    a = np.ones(n)*X
    b = np.abs(x - a)
    c = b[1]
    for i in range(n-1):
        c = gcd(c, b[i])
    print(int(c))

Solution (Python):
import fractions

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

xx = []

for i in range(n):
    xx.append(abs(x[i]-X))

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

Solution (Python):
from fractions import gcd
N , X = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
y = [abs(x[i]-X) for i in range(N)]
res = y[0]
for i in range(1,N):
    res = gcd(res,y[i])
print(res)

Solution (Python):
headData=[int(n) for n in input().split()]
cityNum=headData[0]
pos_x=int(headData[1])
cityList=[int(n) for n in input().split()]
allList=[]
allList.append(pos_x)
for n in cityList:
    allList.append(n)

allList=sorted(allList)

diffList=[]

for n in range(len(allList)-1):
    diffList.append(allList[n+1]-allList[n])

answer = min(diffList)

while True:
    isAnswer = True
    for n in diffList:
        if n % answer != 0:
            isAnswer = False
            break
    if isAnswer:
        print(answer)
        break
    else:
        answer = answer-1

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

Solution (Python):
N,X=map(int,input().split())
x=list(map(int,input().split()))
ans=0
amari=0
big=0
small=0
for i in range(N):
	x[i] = abs(x[i]-X)
if N==1:
	print(x[0])
else:
	ans=x[0]
	for j in range(1,N,1):
		if x[j]>=ans:
			big=x[j]
			small=ans
		else:
			big=ans
			small=x[j]
		while big%small != 0:
			amari=big%small
			big=small
			small=amari
		ans=small
	print(ans)

Solution (Python):
import functools
import fractions
 
n,x = map(int,input().split())
cities = list(map(int,input().split()))
if n == 1:
    ans = abs(cities[0] - x)
    print(ans)
else:
    cities.append(x)
    cities.sort()
    dist = []
    for i in range(1,len(cities)):
        dist.append(cities[i] - cities[i-1])
    ans = functools.reduce(fractions.gcd, dist)
    print(ans)

Solution (Python):
N,X=map(int,input().split())
A=list(map(int,input().split()))
B=[]
for i in range(N):
    B.append(abs(A[i]-X))


a=B[0]

for j in range(1,N):
    b=B[j]
    if b<a:
        a,b=b,a
    while b!=0:
        a,b=b,a%b
print(a)

Solution (Python):
N,X = map(int,input().split())
u = list(map(int,input().split()))
def gcd_list(numbers):
    gct = numbers[0]
    for i in range(len(numbers)-1):
        r = numbers[i+1] % gct
        while r != 0:
            ka = r
            r = gct
            gct = ka
            r = r % gct
    return gct
u.append(X)
u.sort()
sa = []
for i in range(len(u)-1):
    sa.append(u[i+1]-u[i])
if len(sa) > 1:
    print(gcd_list(sa))
else:
    print(sa[0])

Solution (Python):
N,X = map(int,input().split())
towns = list(map(int,input().split()))
towns.append(X)
towns.sort()
town_diff = [0]*(len(towns)-1)
for i in range(len(towns)-1):
    town_diff[i] = towns[i+1]-towns[i]
town_diff.sort()
if(len(town_diff) == 1):
    gcd = town_diff[0]
elif(len(town_diff) == 2):
    a = town_diff[0]
    b = town_diff[1]
    while(True):
            t = b%a
            if(t == 0):
                gcd = a
                break
            b = a
            a = t
else:
    a = town_diff[0]
    b = town_diff[1]
    for i in range(len(town_diff)-2):
        while(True):
            t = b%a
            if(t == 0):
                gcd = a
                break
            b = a
            a = t
        a = gcd
        b = town_diff[i+2]
print(gcd)

Solution (Python):
import fractions
n,m=map(int,input().split())
tosi = list(map(int,input().split()))
for i in range(n):
    tosi[i]=abs(m-tosi[i])
answer=min(tosi)
while max(tosi)!=0:
    for i in range(n):
        if tosi[i]%answer==0:
            tosi[i]=0
        else:
            answer=fractions.gcd(answer,tosi[i])
print(answer)

Solution (Python):
import fractions

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

a = list(map(int, input().split()))
a = list(map(lambda x: abs(x-start),a))
a.sort()
D = a[0]

for i in range(1,len(a)):
  diff = a[i] - a[i-1]
  D = fractions.gcd(diff, D)

  if D == 1:
    print('1')
    exit()

print(D)

Solution (Python):
import numpy as np

N,X = map(int,(input().split()))
city_list = list(map(int,(input().split())))
city_list.append(X)
i = 0



def gcd(p,q):
	while q > 0:
		p,q = q, p%q
	return p
  


city_diff = np.diff(sorted(city_list))

if N == 1:
	gcd_val = city_diff[0]
elif N == 2:
	gcd_val = gcd(city_diff[0],city_diff[1])
else:
	gcd_val = gcd(city_diff[0],city_diff[1])
	for i in range(i+2,N):
		gcd_val = gcd(gcd_val,city_diff[i])

print(gcd_val)

Solution (Python):
from fractions import gcd

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

m = abs(A[0]-x)

for a in A:
    m = gcd(m, abs(a-x))

print(m)

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

def gcd_list(l):
    
    if len(l) == 1:
        return l[0]
    temp = [gcd(l[0],l[1])]
    n = 0
    while(n<len(l)-2):
        
        temp.append( gcd(temp[n], l[n+2]) )
        n = n+1
    
    return(temp[len(temp)-1])

n, start = map(int, input().split(" "))
li = list(map(int, input().split(" ")))
diff = min(li) - start
if(len(li) == 1):
    print(abs(diff))
else:
    li.append(start)
    diff = min(li) - start
    for i in range(len(li)):
        li[i] = li[i] - start - diff
    
    print(gcd_list(li))

Solution (Python):

from functools import reduce

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

    return reduce(gcd, numbers)


input_list1 = list(map(int, input().split()))
input_list2 = list(map(int, input().split()))


N = input_list1[0]
X = input_list1[1]





input_list2.append(X)
input_list2.sort()



ans_list = []
for i, target in enumerate(input_list2):
    if i == N:
        break
    aa = input_list2[i + 1] - input_list2[i]
    
    ans_list.append(aa)


ans_list = set(ans_list)


if len(ans_list) > 1:
    print(gcd_list(ans_list))
else:
    print(min(ans_list))

Solution (Python):
N,X=(int(i) for i in input().split())
x = [int(i) for i in input().split()]
x.append(X)
x.sort()
b=[]
for i in range(N):
    c=x[i+1]-x[i]
    b.append(c)

def zako(m,n):
    s=max(m,n)
    t=min(m,n)
    while s%t!=0:
        ss =s%t
        s=t
        t=ss
    else:
        return t
dodo=b[0]
for j in range(N-1):
    bobo = zako(b[j+1],dodo)
    dodo = bobo
print(dodo)

Solution (Python):
import sys
from functools import reduce

import numpy


def main():
    lines = [list(map(int, x.strip().split())) for x in sys.stdin.readlines()]
    N, X = lines[0]
    location = sorted(lines[1] + [X])
    if len(location) == 1:
        print(location[0] - X)
    else:
        location = numpy.array(location)
        sub = location[1:] - location[:-1]
        result = reduce(gcd, sub)
        print(result)


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


if __name__ == '__main__':
    main()

Solution (Python):
from fractions import gcd
N, X = map(int, input().split())
kotae = list(map(int, input().split()))
kotae.append(X)
kotae.sort()
t = kotae[1]-kotae[0]
for i in range(len(kotae)-1):
    t = gcd(t, abs(kotae[i + 1] - kotae[i]))
print(t)

Solution (Python):



def solve_gcd_from_list(number_list):
    if len(number_list) == 1:
        return number_list[0]

    if len(number_list) == 2:
        return solve_gcd(number_list[0], number_list[1])
    mid = len(number_list) // 2
    return solve_gcd(solve_gcd_from_list(number_list[:mid]), solve_gcd_from_list(number_list[mid:]))


def solve_gcd(number1, number2):
    if number1 == number2:
        return number1

    if number1 < number2:
        number1, number2 = number2, number1

    if number1 % number2 == 0:
        return number2

    return solve_gcd(number2, number1 % number2)


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

    cities.append(X)
    cities.sort()

    distance_list = []

    for i in range(N):
        distance_list.append(cities[i+1]-cities[i])

    if len(distance_list) == 1:
        D = distance_list[0]
    else:
        D = solve_gcd_from_list(distance_list)
    print(D)

Solution (Python):
def gcd(m,n):
    x=max(m,n)
    y=min(m,n)
    if x%y==0:
        return y
    else:
        while x%y!=0:
            z=x%y
            x=y
            y=z
        else:
            return z


N,X=map(int,input().split())
x_list=list(map(int,input().split()))
x_list.append(X)
x_list.sort()
y_list=[]
for i in range(N):
    y_list.append(x_list[i+1]-x_list[i])
z_list=list(set(y_list))
if len(z_list)==1:
    print(z_list[0])

else:
    for i in range(len(z_list)-1):
        z_list[i+1]=gcd(z_list[i],z_list[i+1])
    print(z_list[-1])

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

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

saList=[]
for i in range(len(xList)):
  saList.append(abs(x-xList[i]))

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

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()))
ans = 0
for i in range(n):
    ans = gcd(abs(xlist[i]-x),ans)
print(ans)

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


def spaceinput():
    return list(map(int,input().split(" ")))


def _gcd(*numbers):
    return reduce(math.gcd, numbers)




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


def gcd_n(numbers):
  '''Returns GCD of given n numbers.
  Argument: numbers - List of given numbers
  '''
  return reduce(lambda x, y: gcd(x, y), numbers)



N,X=spaceinput()

x=spaceinput()

x.append(X)
x=sorted(x)
d=[]
for i,xx in enumerate(x[:-1]):
    d.append(x[i+1]-x[i])




print(gcd_n(d))

Solution (Python):


import numpy as np
from functools import reduce

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

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

y = np.asarray(list(map(int,input().split())))
y -= x
y = map(abs,y)

print(reduce(gcd, y))

Solution (Python):
def GCU(m,n):
    if not n:
        return m
    else:
        return GCU(n, m%n)

a,b=map(int,input().split())
l=list(map(int,input().split()))
l.append(b)
l.sort()
ll=[]
for i in range(len(l)-1):
    ll.append(l[i+1]-l[i])
ll.sort()
s=ll[0]
for i in ll:
    s=GCU(s,i)
print(s)

Solution (Python):
n, x = map(int, input().split())
xl = [int(_) for _ in input().split()]
for i in range(n):
    if x > xl[i]:
        xl[i] = x - xl[i]
    else:
        xl[i] = xl[i] - x


def gcd(a, b):
    if a < b:
        x_a = b
        x_b = a
    else:
        x_a = a
        x_b = b
    while(1):
        if x_a < x_b:
            tmp = x_a
            x_a = x_b
            x_b = tmp
        x_a %= x_b
        if x_a == 0:
            break
    return x_b

    
x_gcd = xl[0]
if n > 1:
    for i in range(1, n):
        x_gcd = gcd(x_gcd, xl[i])
print(x_gcd)

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

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

for i in range(n):
    city[i] = abs(city[i]-x)

ans = city[0]
for num in city:
    ans = gcd(ans, num)

print(ans)

Solution (Python):
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()))
x_d=[0]*N
x_d[0]=abs(X-x[0])
for i in range(N-1):
	x_d[i+1]=abs(x[i+1]-x[i])
	
temp=x_d[0]
least=temp
for i in range(N-1):
	if x_d[i+1] > temp:
		temp=gcd(x_d[i+1],temp)
	else:
		temp=gcd(temp, x_d[i+1])
		
	if temp < least:
		least=temp
		
print(least)

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

kakunin=10**10

if N==1:
    if X<S[0]:
        print(S[0]-X)
        exit()
    else:
        print(X-S[0])
        exit()

for i in range(N):
    S[i]=S[i]-X
    if abs(S[i])<kakunin:
        kakunin=abs(S[i])
        
ans=1
okflag=True
for i in range(2,kakunin+1):
    okflag=True
    for j in range(N):
        if S[j]%i!=0:
            okflag=False
           
            break
    if okflag==True:
        ans=i
print(ans)

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)
    

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

xs = [int(i) for i in input().split()]
ls = [abs(i-x) for i in xs]


print(gcd_list(ls))

Solution (Python):
N, X = list(map(int, input().split()))
A = list(map(int, input().split()))
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
for i in range(N):
    A[i] = abs(A[i] - X)
g = A[0]
for i in range(1, N):
    g = gcd(g, A[i])
print(g)

Solution (Python):
def euclid(a,b):
	c=0
	if (a-b)<0:
		c=a
		a=b
		b=c
	r=-1
	while r!=0:
		r=a%b
		a=b
		b=r
	return a

N,X=map(int,input().split())
x=list(map(int,input().split()))
for i in range(N):
	x[i]=x[i]-X
	if x[i]<0:
		x[i]=x[i]*(-1)
D=x[0]
d=x[0]
for j in range(N-1):
	D=euclid(d,x[j+1])
	d=D
print(D)

Solution (Python):

import math

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

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



GCF = x[1] - x[0]
x_min = x[0]
for i, xi in enumerate(x):
    if i == 0: continue
    GCF = gcf2(GCF, (xi - x_min))

print(GCF)

Solution (Python):
import sys

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

x.append(X)
x.sort()

d = []
for i in range(N):
    d.append(x[i + 1] - x[i]) 

d.sort()

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

D = d[0]
for i in range(len(d) - 1):
    D = gcd(d[i + 1], D)



print(D)

Solution (Python):
n,X = map(int,input().split())
x =list(map(int,input().split()))
x.append(X)
x.sort()
a = []
for i in range(n):
  a.append(x[i+1]-x[i])
  
h = min(a)
gcd = 1
for i in range(h,0,-1):
  if h%i == 0:
    if all(a[j]%i == 0 for j in range(n)):
      gcd = i
      break
      
print(gcd)

Solution (Python):
import math

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

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

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



an=X[0]



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


def lcm(a,b):
    return a*b//gcd(a,b)





for i in range(n):
    an=gcd(an,X[i])

    

print(an)

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

xl.append(x)
xl.sort()

onesam = 0

if len(xl) == 1:
    print(abs(xl[0] - x))
    exit()

for i in range(len(xl)-1):
    one_sa = xl[i+1] - xl[i]
    if onesam == 0:
        onesam = abs(one_sa)
    else:
        short,big = min(onesam,one_sa),max(onesam,one_sa)
        if big % short == 0:
            onesam = short
            continue
        else:
            while big % short != 0:
                short = short -1




            onesam = short
            
print(onesam)

Solution (Python):




"""








"""
from fractions import gcd
from functools import reduce
def input_nlines_multi():
    initial_pos = int(input().split(" ")[1])
    poses = [int(i) for i in input().split(" ")]

    return [initial_pos, poses]

def get_each_GCD(initial_pos, poses):
    """
    >>> get_each_GCD(3, [1,7,11])
    2
    >>> get_each_GCD(81, [33,105,57])
    24
    >>> get_each_GCD(1, [1000])
    999
    """
    target_nums = [abs(p - initial_pos) for p in poses]

    return reduce(gcd, target_nums)

if __name__ == '__main__':
    
    
    print(get_each_GCD(*input_nlines_multi()))

Solution (Python):
import math
import fractions
from functools import reduce
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

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


x.append(x_s)
y = sorted(x)


print(gcd_list([i - y[0] for i in y][1:]))

Solution (Python):

from functools import reduce

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

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

if N == 1:
    print(abs(x[0] - X))
else:
    x.append(X)
    x.sort()
    x = [n - x[0] for n in x]
    D = reduce(gcd, x)
    print(D)