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):
from fractions import gcd
n,x=map(int,input().split())
a=list(map(int,input().split()))
if n==1:
    print(abs(x-a[0]))
    exit()

for i in range(n-1):
    if i==0:
        D=gcd(abs(x-a[i]),abs(x-a[i+1]))
    else:
        D=min(D,gcd(abs(x-a[i]),abs(x-a[i+1])))
    if D==1:
        break
print(D)

Solution (Python):
from fractions import gcd
N,X = map(int,input().split())
x = list(map(int,input().split()))
x.append(X)
x.sort()
m = x[1]-x[0]

for i in range(1,N+1):
    n = x[i]-x[i-1]
    v = gcd(m,n)
    m = v

print(m)

Solution (Python):
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 make_codivisors(n):
    divisors = []
    n0divisors = make_divisors(n[0])
    n0len = len(n0divisors)
    for i in n0divisors:
        for j in range(1, len(n)):
            if n[j] % i != 0:
                break
            if j == len(n)-1:
                divisors.append(i)
            
    
    return max(divisors)


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



if len(b) >= 2:
  print(make_codivisors(b))
else:
  print(b[0])

Solution (Python):
import fractions
from functools import reduce

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

n, x = map(int, input().split())
X = list(map(int, input().split()))
X.append(x)
X.sort()
Y = [b - a for a, b in zip(X, X[1:])]

print(gcd_list(Y))

Solution (Python):
import numpy as np
import fractions
n,x = map(int,input().split())
a = list(map(int,input().split()))
a.append(x)
a.sort()
d = np.diff(a)
if n>1:
    gcd = fractions.gcd(d[0],d[1])
    if n>3:
        for i in range(2,n-1):
            gcd = fractions.gcd(gcd,d[i])
    print(gcd)
else:
    print(d[0])

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()))
d = []

for i in range(N):
    d.append(abs(x[i] - X))

ans = gcd_list(d)
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()
skyks = l[1]-l[0]
for i in range(1,n):
    y = l[i+1]-l[i]
    skyks = gcd(skyks,y)
print(skyks)

Solution (Python):
from fractions import gcd
n,X=map(int,input().split())
x=list(map(int,input().split()))
x.append(X)
x.sort()
tmp=x[1]-x[0]
for i in range(1,n):
    a=x[i+1]-x[i]
    tt=gcd(tmp,a)
    tmp=tt
print(tmp)

Solution (Python):
import sys
from fractions import gcd
def input(): return sys.stdin.readline().strip()


def main():
    N, X = map(int, input().split())
    x = list(map(int, input().split()))
    dist = [abs(X - y) for y in x]
    D = dist[0]
    for d in dist:
        D = gcd(D, d)
    print(D)

if __name__ == "__main__":
    main()

Solution (Python):
import functools
import numpy as np

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


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


if n > 1:
    if abs(x[0]-X) == 0:
        ans = euclid(abs(x[1]-X), abs(x[2]-X))
    elif abs(x[1]-X) == 0:
        ans = euclid(abs(x[0]-X), abs(x[2]-X))
    else:
        ans = euclid(abs(x[0]-X), abs(x[1]-X))

    for xi in x[2:]:
        ans = euclid(ans, abs(xi-X))
        if ans == 1:
            break

else:
    ans = abs(x[0] - X)

print(ans)

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

d = 10**9
for i in range(N):
    newd = abs(X-L[i])
    if newd<d:
        d = newd
        ind = i

near = L[ind]
Y = []
for i in range(N):
    if i!=ind:
        Y.append(abs(near-L[i]))
Y.append(d)

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

Solution (Python):
import fractions
from functools import reduce

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

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

X.append(s)
X.sort()

Y = [(X[i] - X[i - 1]) for i in range(1, n + 1)]

print(gcd_list(Y))

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


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

ans = y[0]
for i in y:
    ans = gcd(i, ans)
print(ans)

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

X.append(x)
X = sorted(X)

import fractions
ans = X[1] - X[0]

for i in range(n-1):
    ans = fractions.gcd(ans,X[i+2]-X[i+1])
    
print(ans)

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

Solution (Python):
import fractions
n, x = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
  a[i] -= x

y = a[0]
for i in range(1, n):
  y = fractions.gcd(y, a[i])
print(abs(y))

Solution (Python):
def gcd(a, b):
	"""Compute the greatest common divisor of a and b"""
	while b > 0:
		a, b = b, a % b
	return a

def resolve():
	n, x = map(int, input().split())
	pos = list(map(int, input().split()))
	diff = [0]*n
	for i in range(n):
		diff[i] = abs(x - pos[i])
	ans = diff[0]
	for i in range(1, n):
		ans = gcd(ans, diff[i])
	print(ans)
resolve()

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

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

Solution (Python):
import fractions

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

l = list(map(int, input().split()))
l.append(x)
l = sorted(l)
ld = list()
for i in range(n):
    ld.append(l[i+1]-l[i])

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

print(a)

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

DIST = [abs(X-x) for x in XS]

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

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

lst = []
for n in xlst:
    difference = abs(X - n)
    lst.append(difference)

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

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

Solution (Python):
import fractions
def gcd(x, y):
    gcd=fractions.gcd(x, y)
    return gcd

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

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

else:
    for i in range(n):
        a[i]=abs(x-a[i])
    
    ans=gcd(a[0], a[1])

    for i in range(2, n):
        ans=gcd(ans, a[i])
    
    print(ans)

Solution (Python):
from fractions import gcd


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

if len(x) == 1:
    print(abs(X - x[0]))
else:
    k = [
        abs(X - p)
        if i == 0
        else
        abs(p - x[i - 1])
        for i, p in enumerate(x)
    ]
    D = gcd(k[0], k[1])
    for n in range(2, N):
        D = gcd(D, k[n])
    
    print(D)

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


def list_gcd(arr):
    if len(arr) == 1:
        return arr[0]

    ans = gcd(arr[0], arr[1])
    for i in range(2, len(arr)):
        ans = gcd(ans, arr[i])
    return ans


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

print(list_gcd(steps))

Solution (Python):
n,x = map(int,input().split())
a = list(map(int,input().split()))
a.append(x)
a.sort()
f = min([a[i+1]-a[i] for i in range(n)])
ans = f
for i in range(n):
    if (a[i+1] - a[i])%f:
        ans = min(ans,(a[i+1] - a[i])%f)
print(ans)

Solution (Python):
from fractions import gcd

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

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

Solution (Python):
n,X = map(int,input().split())
l =  list(map(int,input().split()))
l.sort(reverse = True)
ans = 10**10
yakusuu = []
count= 0
if n == 1:
  print(abs(l[0]-X))
  exit()
  
for i in l:
  ans = min(ans,abs(i-X))
  if i-X < 0:
    break

for i in range(1,ans+1):
  if ans%i == 0:
    yakusuu.append(i)

yakusuu.reverse()

for i in yakusuu:
  for j in range(n-1):
    if (l[j]-l[j+1])%i != 0:
      break
    elif (l[j]-l[j+1])%i == 0:
      count += 1
      if count == len(l) - 1:
        print(i)
        exit()

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

Solution (Python):
import functools
n, x = map(int,input().split())
place = list(map(int,input().split()))
place.append(x)
place.sort()
if n == 1:
    print(place[1] - place[0])
    exit()

k = []
for i in range(1, n+1):
    k.append(place[i] - place[i-1])

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

def gcd(nums):
    return functools.reduce(euclid, nums)

print(gcd(k))

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

Solution (Python):
import fractions

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

gcd = 0

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

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

n, X = map(int, sys.stdin.buffer.readline().split())
x = list(map(int, sys.stdin.buffer.readline().split()))
ans = abs(X - x[0])
for i in x[1:]:
    tmp = abs(X - i)
    if tmp % ans:
        ans = gcd(tmp, ans)
print(ans)

Solution (Python):
N, X = map(int, input().split())
*x, = map(int, input().split())
y = [abs(X-x_i) for x_i in x]
def gcd(a,b):
    if a < b:
        a, b = b, a
    while b:
        a, b = b, a%b
    return a
ans = y[0]
for i in range(1,N):
    ans = gcd(ans, y[i])
print(ans)

Solution (Python):
import fractions
from functools import reduce

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

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

x.append(x0)
x.sort()
dis=[]
for i in range(1,n+1):
    dis.append(x[i]-x[i-1])

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

print(gcd(dis))

Solution (Python):
import fractions
n,x = map(int,input().split())
X = list(map(int,input().split()))
X = list(map(lambda a:abs(a-x),X))

for i in range(n):
    if i == 0:
        now = X[i]
    else:
        now = fractions.gcd(X[i], now)

print(now)

Solution (Python):
import fractions

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

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

x.append(X)

x.sort()

dis = []

for i in range(1, n+1):
    dis.append(x[i] - x[i-1])

for i in range(n):
    if i == 0:
        now = dis[i]
    else:
        now = fractions.gcd(dis[i], now)

print(now)

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

ans=abs(a[0]-x)
for i in range(1,n):
    ans=fractions.gcd(abs(a[i]-x),ans)
print(ans)

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

Solution (Python):





def gcd(n, m):
    while True:
        n, m = m, n % m
        if m == 0:
            return n


def main():
    N, X = map(int, input().split())
    x = list(map(int, input().split()))
    x = [val-X if val >= X else X-val for val in x]
    x = sorted(x)

    
    
    
    

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

    return ans


print(main())

Solution (Python):






import sys
input = sys.stdin.readline

import math

import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache






MOD = 10**9+7
INF = float('inf')






def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]


def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()


def DD(arg): return defaultdict(arg)



def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr


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)
  return divisors


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


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


def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count


def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))


def int_log(n, a):
  count = 0
  while n>=a:
    n = n//a
    count += 1
  if a**count == n:
    return count
  else:
    return count+1





N,X = IL()
x = IL()
x.append(X)
x.sort()
D = []
for i in range(N):
  D.append(x[i+1]-x[i]) 
ans = D[0]
for d in D:
  ans = gcd(ans,d)
P(ans)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,x=map(int, input().split())
    l=list(map(int,input().split()))
    ll=[]
    for i in l:
        ll.append(abs(x-i))
    from functools import reduce
    from fractions import gcd
    print(reduce(gcd,ll))
resolve()

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

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

from fractions import gcd 

def gcds(List): 
  if len(List) == 1:
    return List[0]
  ans = gcd(List[0], List[1])
  for i in range(2, len(List)):
    ans = gcd(ans, List[i])
  return ans

print(gcds(lst))

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

Solution (Python):
n,x=map(int,input().split())
p=sorted(list(map(int,input().split())))
def gcd(a,b):
  if a<b:
    a,b=b,a
  while a%b>0:
    a,b=b,a%b
  return b
ans=abs(x-p[0])
for i in range(1,n):
  ans=gcd(ans,p[i]-p[i-1])
  
print(ans)

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

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

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

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

l=[abs(i - X) for i in x]
ans=l[0]

if len(l) == 1:
    print(ans)
    exit()
    
for i in range(1,len(l)):
    ans = gcd(ans,l[i])
    
print(ans)

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

Solution (Python):
import sys, fractions

N, X = map(int, input().split())
x = list(map(int, sys.stdin.readline().rsplit()))

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

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

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

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

print(res)

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

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

Solution (Python):
n,X = map(int,input().split())
x = list(map(int,input().split()))
b = [0]*n
for i in range(n):
    b[i] = x[i] - X
from fractions import gcd
ans = b[0]
for i in range(1, n):
    ans = gcd(ans, b[i])
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())
a = list(map(int,input().split()))
a = [abs(a[i]-x) for i in range(n)]
ans = 0
print(gcd(*a))

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

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

x_ = [abs(X - i) for i in x]
x_.sort(reverse=True)
D = x_[0]
for i in range(1, N):
  D = gcd(D, x_[i])
print(D)

Solution (Python):
import numpy as np


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


_, X = map(int, input().split())
x = np.array(list(map(int, input().split())))

X = np.array([X])

x = np.concatenate([x, X])
x.sort(0)
x = np.abs(np.diff(x))

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

print(ans)

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

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

x2 = x.copy() + [X]
x2 = sorted(x2)
diffs = []
for i in range(1, len(x2)):
    diffs.append(x2[i] - x2[i - 1])
if len(diffs) == 1:
    print(diffs[0])
else:
    diffs_gcd = gcd(diffs[0], diffs[1])
    for i in range(2, len(diffs)):
        diffs_gcd = gcd(diffs_gcd, diffs[i])
    print(diffs_gcd)

Solution (Python):
N, X = map(int, input().split())
xlist = sorted(list(map(int, input().split()))+ [X])

import fractions
from functools import reduce


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


def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
sbn = [xlist[i+1] - xlist[i] for i in range(N)]
print(gcd_list(sbn))

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

Solution (Python):
from fractions import gcd

n,x = map(int,input().split())
x_list = list(map(int,input().split()))
hoge = set()
for y in x_list:
  hoge.add(abs(x-y))
ans = abs(x_list[0]-x)
for num in hoge:
  ans = gcd(num,ans)
print(ans)

Solution (Python):
from fractions import gcd

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

S = []
for i in range(N):
    S.append(abs(a-X[i]))

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

print(ans)

Solution (Python):
import fractions

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

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

print(ans)

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


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


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

print(ans)

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

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18


n, start = Is()
X = LI()
m = min(X+[start])
ans = reduce(gcd, [x-m for x in X+[start]])
print(ans)

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

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

x=[]
for _ in input().split():
    x.append(int(_))

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

if len(dist)>1:
    D=gcd(dist[0],dist[1])
    for i in range(len(dist)):
        D=gcd(D,dist[i])
else:
    D=dist[0]

print(D)

Solution (Python):
import fractions
a,b= list(map(int, input().split()))
i= list(map(int, input().split()))

ans=0
l=[]
for j in range(a):
    l.append(abs(b-i[j]))
for k in range(0,a):
    if k==0:
        ans=l[0]
    else:
        ans=fractions.gcd(ans,l[k])
print(ans)

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

x.append(start)
x.sort()

distance = []
for i in range(n):
    dis = abs(x[i+1] - x[i])
    distance.append(dis)
if len(distance) == 1:
    D = distance[0]
else:
    D = gcd(distance[0], distance[1])
    for i in range(2, n):
        D = gcd(D, distance[i])
print(D)

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

Solution (Python):
import fractions,itertools
N,S = [int(hoge) for hoge in input().split()]
X = [int(hoge) - S for hoge in input().split()]
print(abs(list(itertools.accumulate(X,func = fractions.gcd))[-1]))

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

N, X = map(int, input().split(' '))
distances = [abs(p - X) for p in map(int, input().split(' '))]
print(reduce(gcd, distances))

Solution (Python):
def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a

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

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


x_input.append(x)
x_li = sorted(x_input)

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

g = cost_li.pop(0)
for c in cost_li:
    g = math.gcd(g,c)

print(g)

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

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

n, x = map(int, input().split())
a = [abs(int(A) - x) for A in input().split()]
a.sort()
print(reduce(gcd, a))

Solution (Python):


import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))

from fractions import gcd
import math
def resolve():
    A,B=pin()
    X=lispin()
    temp=abs(B-X[0])
    for x in X:
        temp=gcd(temp,abs(B-x))
    print(temp)
    

resolve()

Solution (Python):
from fractions import gcd  


def main():
    N, X = list(map(int, input().split(' ')))
    x_list = list(map(lambda x: abs(int(x) - X), input().split(' ')))
    ans = x_list[0]
    for x in x_list[1:]:
        ans = gcd(ans, x)
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import fractions

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

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

Solution (Python):
"""
マスターオブ整数
"""
import fractions

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

dist = [abs(i - X) for i in cities]
division = dist[0]
for i in dist[1:]:
    division = fractions.gcd(division, i)

print(division)

Solution (Python):
import fractions
import sys
import bisect
import heapq  

inf = 10 ** 15
mod = 10 ** 9 + 7
n,x = map(int, input().split())
a = list(map(int, input().split()))
ans = abs(a[0]-x)
for i in range(n):
    ans = fractions.gcd(ans, abs(a[i]-x))
print(ans)

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

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

def solve():
    n, x = map(int, input().split())
    l = list(map(int, input().split()))

    ans = []
    for i in l:
        ans.append(abs(x-i))

    return gcd_list(ans)
    

print(solve())

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

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

import fractions
d = fractions.gcd(y[0], y[1])
for xi in y:
    d = fractions.gcd(d, xi)
print(abs(d))

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




'''
A=[]
B=[]
for i in range():
    a,b = map(int, input().split())
    x=
    A.append(a)
    B.append(b)'''

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

def yakusuu(n):
    
    
    yakusuu_list = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            yakusuu_list.append(i)
            if i != n // i:
                yakusuu_list.append(n//i)
    return yakusuu_list

slis=yakusuu(min(sa))
slis.sort()

for item in slis:
    cnt=0
    for i in range(n):
        if sa[i]%item==0:
            cnt+=1
    if cnt==len(x):
        maxx=item
print(maxx)

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7


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

n,x=MI()
lis=LI()
for i in range(n):
    lis[i]=abs(lis[i]-x)
if n==1:
    print(lis[0])
    sys.exit()
a=lis[0]
b=lis[1]
for i in range(2,n):
    a=gcd(a,b)
    b=lis[i]
print(gcd(a,b))

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

Solution (Python):
import sys
from fractions import gcd

input = sys.stdin.readline


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

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

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import sys
from fractions import gcd

input = sys.stdin.readline


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

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

    print(ans)


if __name__ == "__main__":
    main()

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

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