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):
    while b:
        a, b = b, a % b
    return a

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

print(ans)

Solution (Python):
import fractions
from functools import reduce

def main():

    N,X= map(int,input().split())
    targetList = list(map(int,input().split()))
    targetList.append(X)
    targetList.sort()
    diffList = []

    if N > 2:
        for i in range(N-1):
            diffList.append(targetList[i+1] - targetList[i])

    elif N==2:
        for i in targetList:
            diffList.append(i)
    else:
        print(abs(targetList[0]-targetList[1]))
        exit()

    print(reduce(fractions.gcd,diffList))

        
    
if __name__== "__main__":
    main()

Solution (Python):

import fractions
n,x = map(int,input().split())
lst = [int(i) for i in input().split()]
distance = [x-lst[0]]
for i in range(1,n):
    distance.append(lst[i]-lst[i-1])
d = distance[0]
for i in range(n):
    d = fractions.gcd(d,distance[i])
print(abs(d))

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


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

Solution (Python):
import sys, fractions
input = sys.stdin.readline
n,x = map(int,input().split())
a = tuple(map(int,input().split()))
b = [0] * n
c = abs(a[0] - x)
for i in range(1,n):
  c = fractions.gcd(c,abs(a[i]-x))
print(c)

Solution (Python):
from fractions import*
n,x,*l=map(int,open(0).read().split())
g=abs(l[0]-x)
for a,b in zip([x]+l,l):
	g=gcd(g,abs(b-a))
print(g)

Solution (Python):
import fractions

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

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

if N == 1:
    print(x[0])
    exit()

ans = fractions.gcd(x[0],x[1])

if N == 2:
    print(ans)
    exit()
    
for i in range(N-2):
    ans = fractions.gcd(ans,x[i+2])
    
print(ans)

Solution (Python):
words = lambda t : list(map(t, input().split()))
n,x = words(int)
xs = words(int)

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

ys = list(map(lambda y: abs(y-x), xs))
g = ys[0]
for y in ys:
    g = gcd(g,y)

print(g)

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

Solution (Python):
import fractions
from functools import reduce
N,X=map(int,input().split())
li=list(map(int,input().split()))
li2=[X]*N
a=[abs(x-y) for x,y in zip(li2,li)]
def gcd(*n):
    return reduce(fractions.gcd, n)
print(gcd(*a))

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

Solution (Python):
import fractions

n, x = map(int, input().split())
X = list(map(int, input().split()))
X = [X[i] - x for i in range(n)]
ans = X[0]
for i in range(n - 1):
    ans = fractions.gcd(ans, X[i + 1])
print(abs(ans))

Solution (Python):
import fractions
from functools import reduce

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

N, X = map(int, input().split())
x = list(map(int, input().split()))
X_x = [0] * N
for i in range(N):
    X_x[i] = max(X-x[i], x[i]-X)
 
ans = gcd(*X_x)
print(ans)

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

n = [abs(x-i) for i in a]

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

ans = n[0]
for c in n[1:]:
  ans = gcd(ans, c)

print(ans)

Solution (Python):
import fractions
from functools import reduce
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
N,X=map(int,input().split())
x = list(map(int,input().split()))
x.append(X)
x.sort()
n=len(x)-1
d=[0]*n
for i in range(n):
  d[i]=x[i+1]-x[i]
print(gcd_list(d))

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

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

l = abs(X - L[0])
L.sort()
if N > 1:
    D = [L[i] - L[i-1] for i in range(1, N)]
    for i in range(N-1):
        l = gcd(l, D[i])

print(l)

Solution (Python):




def LCM(num1, num2):
    m = max(num1, num2)
    n = min(num1, num2)
    r = m % n
    while(r != 0):
        m = n
        n = r
        r = m % n
    return n


N, x = map(int, input().split())
D = 1

if (N == 1):
    tmp = int(input())
    print(abs(x - tmp))
else:
    tmp = input()
    list = []
    list = tmp.split()
    for i in range(N):
        list[i] = abs(x - int(list[i]))
    D = list[0]
    for i in range(N):
        D = LCM(D, list[i])
    print(D)

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

Solution (Python):
def gcd(x,y):
    while y:
        x,y = y , x % y 
    return x

def gcd2(array):
    t = array[0]
    for i in array:
        t = gcd(t,i)
    return t

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

dif=[abs(a-b)  for a,b in zip([X]+x,x)]
print(gcd2(dif))

Solution (Python):
N,X = map(int,input().split())
x = list(map(int,input().split()))
def GCD(x,y):
    while y!=0:
        x,y = y,x%y
    return x
ans = 0
for i in range(N):
    ans = GCD(ans,abs(x[i]-X))
print(ans)

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')


def A():
    a, b = LI()
    if (a * b) % 2:
        print("Yes")
    else:
        print("No")
    return


def B():
    n = II()
    w = SR(n)
    d = []
    for i in w:
        d.append("".join(i))
    if len(set(d)) != n:
        print("No")
        return
    for i in range(n - 1):
        if w[i][-1] != w[i + 1][0]:
            print("No")
            return
    print("Yes")
    return


def C():
    def gcd(a, b):
        a, b = max(a, b), min(a, b)
        while b:
            a, b = b, a % b
        return a
    n, x = LI()
    xn = LI()+[x]
    xn.sort()
    ans = xn[1] - xn[0]
    for i in range(1, n):
        ans = gcd(ans, xn[i + 1] - xn[i])
    print(ans)
    return


def D():
    return


if __name__ == '__main__':
    C()

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


a, b = map(int, input().split())
c = list(map(int, input().split()))
c.append(b)
d = 0
for i in range(len(c)):
    d = g_c_d(d, abs((c[i] - c[i-1])))
print(d)

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

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

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

x.insert(0,X)
diff = []
for i in range(len(x)-1):
	diff.append(abs(x[i+1]-x[i]))

ans = diff[0]
for i in range(1,len(diff)):
	ans = fractions.gcd(ans,diff[i])
    
print(ans)

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


def main():
    _, y = map(int, input().split())
    x = map(int, input().split())
    x = [xx - y for xx in x]
    ans = reduce(lambda x, y: gcd(x, abs(y)), x, 0)
    print(ans)


main()

Solution (Python):


import sys

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

tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))
n=hoge[0]
x=hoge[1]

tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))

res = abs(x-hoge[0])
for i in range(1,n):
	res=gcd(res, abs(hoge[i]-hoge[i-1]))
print(res)

Solution (Python):
import sys
import fractions

sys.setrecursionlimit(10**9)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def LIST(): return [int(x) for x in input().split()]
MOD = 10**9 + 7

N, X = LIST()

x = LIST()

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

ans = dx[0]
for i in range(1, N):
    ans = fractions.gcd(ans, dx[i])

print(ans)

Solution (Python):
import sys
import fractions

sys.setrecursionlimit(10**9)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def LIST(): return [int(x) for x in input().split()]
MOD = 10**9 + 7

N, X = LIST()

x = LIST()

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

def gcd_all(n):
    if len(n) == 1:
        return n[0]

    tail = n.pop(-1)
    return fractions.gcd(tail, gcd_all(n))

print(gcd_all(dx))

Solution (Python):
import sys
sys.setrecursionlimit((2**31)-1)
from fractions import gcd
from collections import deque
n,X = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
x.append(X)
x = sorted(x)
k = x[0]
x = deque([i-k for i in x])
x.popleft()

def gcdn():
    if len(x)==1:
        return
    p=x.pop()
    q=x.pop()
    x.append(gcd(p,q))
    gcdn()

gcdn()
print(x[0])

Solution (Python):
import fractions

def main29():
    data = input().split()
    nx = []
    for i in range(2):
        nx.append(int(data[i]))
    data2 = input().split()
    zahyo = []
    for i in range(nx[0]):
        kari = int(data2[i])
        kari = int(abs(nx[1]-kari))
        zahyo.append(kari)
    result = zahyo[0]
    if nx[0] == 1:
        print(zahyo[0])
        return
    for i in range(1,nx[0],1):
        result = fractions.gcd(result,zahyo[i])
    print(result)

if __name__ == "__main__":
    main29()

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


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

x = map(lambda x_i: abs(X - x_i), x)
ans = reduce(gcd, x)
print(ans)

Solution (Python):
import numpy as np
n, x = map(int, input().split())
ans = 1
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
def check(n, li):
    for i in li:
        if i != 0:
            if abs(i) % n != 0:
                return False
    return True
li = list(map(int, input().split()))
li.append(x)
li = list(set(li))
li.sort()
start_index = li.index(x)
li = np.array(li)
if start_index == len(li)-1:
    n = li[start_index] - li[start_index - 1]
    n_div = make_divisors(n)
    for i in n_div[::-1]:
        if check(i, li-x) and i > ans:
            ans = i
            break
        
elif start_index == 0:
    n = li[start_index+1] - li[start_index]
    n_div = make_divisors(n)
    for i in n_div[::-1]:
        if check(i, li-x) and i > ans:
            ans = i
            break
else:
    n = li[start_index] - li[start_index - 1]
    n_div = make_divisors(n)
    for i in n_div[::-1]:
        if check(i, li-x) and i > ans:
            ans = i
            break
    n = li[start_index+1] - li[start_index]
    n_div = make_divisors(n)
    
    for i in n_div[::-1]:
        if check(i, li-x) and i > ans:
            ans = i
        if ans > i:
            break

print(ans)

Solution (Python):
import fractions
from functools import reduce

n, x0 = map(int,input().split())
xn = list(map(int,input().split()))
xn = [abs(x - x0) for x in xn]
d = reduce(fractions.gcd, xn)
print(d)

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


a, b = map(int, input().split())
c = list(map(int, input().split()))
c.append(b)
c.sort()
d = 0
for i in range(1, a + 1):
    d = g_c_d(c[i] - c[i-1], d)
print(d)

Solution (Python):
import fractions
from functools import reduce

n, x = map(int, input().split())
xl = list(map(int, input().split()))
xl.append(x)
xl.sort()
xldiv = []
for i in range(n):
    xldiv.append(xl[i + 1] - xl[i])

print(reduce(fractions.gcd, xldiv))

Solution (Python):
import fractions
n,x=map(int, input().split())
c=list(map(int, input().split()))
c.append(x)
c.sort()
v=[]
r=[0]
for i in range(n):
    v.append(c[i+1]-c[i])
for i in range(n):
    z=fractions.gcd(r[-1],v[i])
    r.append(z)
print(r[-1])

Solution (Python):
import fractions
from functools import reduce

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

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

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

Solution (Python):

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


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


def gcds(l):
    if len(l) == 1:
        return l[0]
    elif len(l) == 2:
        return gcd(l[0], l[1])
    else:
        n = len(l) // 2
        L = l[:n]
        R = l[n:]
        return gcd(gcds(L), gcds(R))


def lcms(l):
	if len(l) == 1:
		return l[0]
	elif len(l) == 2:
		return lcm(l[0], l[1])
	else:
		n = len(l) // 2
		L = l[:n]
		R = l[n:]
		return lcm(lcms(L), lcms(R))
      
n, X = (int(i) for i in input().split())  
x = [int(i) for i in input().split()] 
x.append(X)
mm = min(x)
x.remove(mm)

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

print(gcds(x))

Solution (Python):
import fractions
N,X=map(int,input().split())
listX=list(map(int,input().split()))
listX+=[X]
listX.sort()
MIN=10**9
gcd=listX[1]-listX[0]
for i in range(N):
  a=listX[i+1]-listX[i]
  gcd=fractions.gcd(a,gcd)
print(gcd)

Solution (Python):
N,X = map(int, input().split())
List = [int(x) for x in input().split()]
 
import math
List.append(X)
List.sort()
 
distance = []
for i in range(N):
    distance.append(List[i+1]-List[i])
 
d_min = min(distance)
 
num_list = []
 
c = 1
while c <= math.sqrt(d_min):
    if d_min%c == 0:
        num_list.append(c)
    c += 1
 
num_list2 = [0]*len(num_list)
for i in range(len(num_list)):
    num_list2[len(num_list)-i-1] = int(d_min/num_list[i])
 
num_list = num_list + num_list2

num_list.append(d_min)

j = len(num_list)-1

while j >= 0:
    c2 = 0
    for k in range(len(distance)):
        if distance[k]%num_list[j] == 0:
            c2 += 1
    if c2 == len(distance):
        ans = num_list[j]
        j = 0
    j -= 1
 
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 = list(map(int, input().split()))
x = [abs(X - e) for e in x]

res = x[0]
for e in x[1:]:
    res = gcd(res, e)
print(res)

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

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

ans = abs(A[0]-X)
for a in A:
    ans = gcd(ans, abs(a-X))


print(ans)

Solution (Python):
import fractions
N,X = map(int,input().split())
x = list(map(int,input().split()))
ag = 0
for c in x:
    if ag==0:ag=abs(c-X)
    else:ag=fractions.gcd(ag,abs(c-X))
print(ag)

Solution (Python):
import fractions

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])


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

Solution (Python):
import fractions

N, X = map(int, input().split())
cities = list(map(int, input().split()))
gcds = abs(cities[0]-X)
for city in cities[1:]:
  gcds = fractions.gcd(gcds, abs(city-X))
print(gcds)

Solution (Python):
from fractions import gcd

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

A.sort()

D = [A[i+1]-A[i] for i in range(N)]

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

print(ans)

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

N, X = map(int, input().split())
x = list(map(int, input().split()))
dist = list(map(lambda v: abs(v-X), x))
ans = dist[0]
for i in range(1, N):
	ans = euc(ans, dist[i])
print(ans)

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

import fractions as frc

x.append(s)
al=sorted(x)

ds=[0]*n
for i in range(n):
	ds[i]=al[i+1]-al[i]

if n>1:
	gc=[0]*(n-1)
	for i in range(n-1):
		gc[i]=frc.gcd(ds[i],ds[i+1]) 
    
if n==1:
	res=ds[0]
else:
	res=min(gc)

print(res)

Solution (Python):
import fractions
N, X = [int(x) for x in input().split()]
x_list = [abs(int(x)-X) for x in input().split()]
tmp = x_list[0]
for x in x_list[1:]:
    tmp = fractions.gcd(tmp, x)
print(tmp)

Solution (Python):
import sys
from fractions import gcd
from itertools import groupby as gb
from itertools import permutations as perm
from itertools import combinations as comb
from collections import Counter as C
from collections import defaultdict as dd
sys.setrecursionlimit(10**5)
def y(f):
    if f:
        print('Yes')
    else:
        print('No')
def Y(f):
    if f:
        print('YES')
    else:
        print('NO')

n,x = map(int,input().split())
a = list(map(int,input().split()))
p = []
for i in a:
    p.append(abs(i - x))
g = p[0]
for i in p:
    g = gcd(i, g)
print(g)

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

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

num = abs(X - x[0])
for i in range(1, n):
    num = gcd(num, abs(X - x[i]))
print(num)

Solution (Python):
N, X = list(map(int, input().split()))
P = [abs(int(c)-X) for c in input().split() if int(c)-X !=0 ]

for i in range(len(P)-1):
    a, b = P[i], P[i+1]
    if a>b: a,b = b,a
    while a>0:
        a, b = b%a, a
    P[i+1]=b

print(P[-1])

Solution (Python):
n, x =  map(int, input().split())
dat = list(map(int, input().split()))
dat.append(x)
dat.sort()
dist = []
cur = dat[0]
for i in range(1, len( dat)):
    dist.append(dat[i] - cur)
    cur = dat[i]


res = 0
import fractions
for i in range(len(dist)):
    res = fractions.gcd(res, dist[i])

print(res)

Solution (Python):
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N, S = list(map(int, sys.stdin.readline().split()))
X = list(map(int, sys.stdin.readline().split()))

X = np.array(X + [S])
X -= X.min()

print(reduce(gcd, X))

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

N,X=map(int,input().split())
A=list(map(int,input().split()))
B=[]

if N==1:
    print(abs(A[0]-X))
    exit(0)
for i in range(N):
    B.append(abs(X-A[i]))

a=gcd(B[0],B[1])
for i in range(2,N):
    a=gcd(a,B[i])
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()]
numbers = [abs(i - X) for i in x]

answer = numbers[0]
for i in numbers:
  answer = gcd(answer, i)
print(answer)

Solution (Python):


import fractions
from functools import reduce

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

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

print(abs(gcd_list(x)))

Solution (Python):



import sys
sys.setrecursionlimit(100000000)

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

s = list(map(lambda x:abs(x-X),x))
def gcd(x,y):
    if y == 0:
        return x
    else:
        return gcd(y,x % y)

if n > 1:
    ans = gcd(s[0],s[1])
    for i in range(2,n):
        ans = gcd(ans,s[i])
    print(ans)
else:
    print(s[0])

Solution (Python):
from functools import reduce
N, X = map(int, raw_input().split())
cities = map(int, raw_input().split())
absolutes = [abs(X-c) for c in cities]

def gcd(a, b):
    if b > a:
        a, b = b, a
    if b == 0:
        return a
    return gcd(b, a%b)
print reduce(gcd, absolutes)

Solution (Python):



import sys
from fractions import gcd

input = sys.stdin.readline

def main():
    N, X = map(int, input().split())
    x = [int(e) for e in input().split()]
    x.sort()

    if N == 1:
        print(abs(x[0] - X))
        return

    m = []
    for i in range(N-1):
        if x[i] < X and X < x[i+1]:
            m.append(x[i+1] - X)
            m.append(X - x[i])
        else:
            m.append(x[i+1]-x[i])
    
    n = m[0]
    for i in m:
        n = gcd(n, i)
    print(n)

main()

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

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


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

x = tuple(map(lambda a: a - X, x))

xl = map(lambda b: -b, filter(lambda a: a < 0, x))
xr = filter(lambda a: a >= 0, x)

g = 0
for xx in xl:
    g = gcd(g, xx)
for xx in xr:
    g = gcd(g, xx)
print(g)

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


a, b = map(int, input().split())
c = list(map(int, input().split()))
c.append(b)
c.sort()
d = -1
for i in range(1, len(c)):
    if i == 1:
        d = c[i] - c[i-1]
    else:
        d = c_gcd(c[i] - c[i-1], d)
print(d)

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()))

ans = x[0] - X

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

print(abs(ans))

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

gcd = abs(x[0]-X)
for i in range(N-1):
    gcd = fractions.gcd(gcd, abs(x[i + 1]-X))

print(gcd)

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

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

y = lst[0]
for x in lst[1:]:
    y = gcd(max(x, y), min(x, y))
print(y)

Solution (Python):
import functools
import fractions

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

gcd = functools.reduce(fractions.gcd, xnum)
print(abs(gcd))

Solution (Python):
n,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
b=[a[i+1]-a[i]for i in range(n-1)]
b.insert(0,abs(a[0]-x))

def search_common_divisor(x,y):
    if x<y:
        x,y=y,x
    while y!=0:
        x,y=y,x%y
    return x

def search_list_common_divisor(*numbers):
    b=[search_common_divisor(numbers[0],numbers[1])]
    for i in numbers:
        b.append(search_common_divisor(b[-1],i))
    return b[-1]


if n!=1:
    print(search_list_common_divisor(*b))
else:
    print(b[0])

Solution (Python):
n,x=map(int,input().split())
lx=sorted(list(map(lambda y:abs(y-x),list(map(int,input().split())))),reverse=True)

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

a=lx[0]
for i in range(1,n):
	a=gcd(a,lx[i])

print(a)

Solution (Python):
import fractions

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

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

g = dist[0]

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

print(g)

Solution (Python):
import functools
import fractions

def resolve():
	n,x=map(int,input().split())
	x_list=list(map(int,input().split()))
	x_list.append(x)
	x_list.sort()
	a=[abs(x_list[i]-x_list[i+1]) for i in range(n)]
	print(functools.reduce(fractions.gcd,a))
resolve()

Solution (Python):
from fractions import gcd


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


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

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


def gcd_arg(lst):
    return reduce(gcd, lst)


N, X = map(int, input().split())
lst_x = list(map(int, input().split())) + [X]
lst_x.sort()
lst_diff = [lst_x[i] - lst_x[i-1] for i in range(1, N+1)]
ans = gcd_arg(lst_diff)
print(ans)

Solution (Python):
N,X = map(int,input().split())
x = list(map(int,input().split())) + [X]
x.sort()
def gcd(x,y):
    if y==0:
        return x
    else:
        return gcd(y,x%y)
ans = x[1]-x[0]
for i in range(N):
    b = x[i+1]-x[i]
    ans = gcd(max(ans,b),min(ans,b))
print(ans)

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

n,x = map(int,input().split())
xa = list(map(int,input().split()))
diff=[]
for i in range(n):
    diff.append(abs(xa[i]-x))
y=diff[0]    
for i in range(1,n):
    y=gcd(y,diff[i])
print(y)

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

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

from functools import reduce

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

List.append(X)
List = sorted(List)

diff = [List[i+1]-List[i] for i in range(N)]

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

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

Solution (Python):
import fractions
n,x = map(int, input().split())
ls = list(map(int, input().split()))
a = []
for i in ls:
    a.append(abs(i - x))
ans = a[0]
for i in range(n-1):
    ans = fractions.gcd(ans, a[i+1])
print(ans)

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

N, A = map(int, input().split())
X = [int(i) for i in input().split()]
X.append(A)
X.sort()

dX = [0]*(N)

for i in range(N):
  dX[i] = X[i+1] - X[i]
Xgcd = [0]*(N)
Xgcd[0] = dX[0]
  
for i in range(N-1):
  Xgcd[i+1] = fractions.gcd(Xgcd[i], dX[i+1])
print(Xgcd[-1])

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 = [int(i) for i in input().split()]
point = list(map(int, input().split()))
dif = []

if(len(point) == 1):
  ans = abs(point[0] - x)
else:
  gcd_now = abs(point[0] - x)
  for i in range(len(point) - 1):
    dif.append(abs(point[i+1] - point[i]))
    gcd_now = gcd(gcd_now, dif[i])
  ans = gcd_now
print(ans)

Solution (Python):
n, X = list(map(int, input().split()))
x = list(map(int, input().split()))
x.append(X)
x.sort()
s = [0 for i in range(n)]
for i in range(n):
  s[i] = x[i+1]-x[i]

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

ans = s[0]
for i in range(n):
  ans = gcd(ans, s[i])
print(ans)

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

Solution (Python):
def gcd(x, y):

   while(y):
       x, y = y, x % y

   return x

n,x = map(int,input().split())
a = list(map(int,input().split()))
k = []
for i in range(len(a)):
    k.append(abs(a[i]-x))
g = 0
for i in range(len(k)):
    g = gcd(g,k[i])
print(g)

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

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

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

x_lis = sorted(x_lis)

x_diff = [0] * (N)

for i in range(N):
    x_diff[i] = x_lis[i + 1] - x_lis[i]

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

print(gcd_list(x_diff))

Solution (Python):

import sys
sys.setrecursionlimit(4100000)

a, b = [int(i) for i in input().split()]
c = [b-int(i) for i in input().split()]
import fractions
if a >= 2:
  temp = fractions.gcd(c[1],c[0])
  for i in range(2,a):
      temp = fractions.gcd(temp,c[i])
  print(abs(temp))
else:
  print(abs(c[0]))

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

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

N,X =  map(int,input().split())
para = [i for i in map(int,input().split())] + [X]
para.sort(reverse=True)
dif = []
for i in range(N):
    dif.append(para[i] - para[i+1])
dif.sort()
for i in range(N):
    if i == 0 :
        val = dif[i]
        continue
    val = gcd(max(dif[i],val),min(dif[i],val))

print(val)

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

n,x = map(int,input().split())
x_list = list(map(int,input().split()))
x_new = [abs(i-x) for i in x_list]
if n == 1:
    print(x_new[0])
    exit()
ans = x_new[0]
for i in range(n-1):
    ans = gcd(ans,x_new[i+1])
print(ans)

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

N, X = map(int, input().split())
result = 0
for x in map(int, input().split()):
    result = gcd(result, abs(x - X))
print(result)

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())) + [X]
D = [0] * N

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

if N == 1:
    print(D[0])
    exit()

ans = gcd(D[0], D[1])
for j in range(2, N):
    ans = gcd(ans, D[j])

print(ans)