AtCoder Beginner Contest 109 - Skip

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-----
3 3
1 7 11

-----Sample Output-----
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.

Difficulty: EASY

Starter code:

Solutions:
import math
(N, X) = map(int, input().split())
lsx = list(map(int, input().split()))
lsx.sort()
gcd = abs(lsx[0] - X)
for i in range(1, N):
	gcd = math.gcd(gcd, lsx[i] - lsx[i - 1])
print(gcd)


from functools import reduce
import math
(n, x) = map(int, input().split())
a = sorted(map(int, input().split()))
a = [i - x for i in a]
if len(a) == 1:
	print(abs(a[0]))
	return
if len(a) == 2:
	print(math.gcd(a[0], a[1]))
	return
l = []
for y in range(n - 1):
	l.append(a[y + 1] - a[y])
print(reduce(lambda x, y: math.gcd(x, y), l))


import fractions
(n, x) = list(map(int, input().split()))
l = list(map(int, input().split()))
l.append(x)
sl = sorted(l)
lis = [sl[i + 1] - sl[i] for i in range(n)]
ans = 0
for i in range(0, n):
	ans = fractions.gcd(ans, lis[i])
print(ans)


import math
from functools import reduce
(N, X) = list(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 = math.gcd(ans, x[i + 1] - x[i])
print(ans)


from math import gcd
from functools import reduce
(_, X) = map(int, input().split())
print(reduce(gcd, (abs(i - X) for i in set(map(int, input().split())))))


from math import gcd
(N, X) = map(int, input().split())
x = list(map(int, input().split()))
if N == 1:
	print(abs(X - x[0]))
else:
	l = []
	for i in range(N):
		l_ = abs(X - x[i])
		l.append(l_)
	ans = l[0]
	for i in range(1, len(l)):
		ans = gcd(ans, l[i])
	print(ans)


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


from fractions import gcd
(N, X) = map(int, input().split())
x = [abs(int(x) - X) for x in input().split()]
a = x[0]
for xi in x[1:]:
	a = gcd(a, xi)
print(a)


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


import math
(N, X) = list(map(int, input().split()))
x = list(map(int, input().split()))
arr = [0] * N
for i in range(N):
	arr[i] = abs(x[i] - X)
ans = arr[0]
for i in range(1, N):
	ans = math.gcd(ans, arr[i])
print(ans)


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


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


import functools

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

def gcd(nums):
	if len(nums) == 1:
		return nums[0]
	return functools.reduce(euclid, nums)
(n, k) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a.append(k)
a.sort()
sa = []
for i in range(1, n + 1):
	sa.append(a[i] - a[i - 1])
print(gcd(sa))


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


from fractions import gcd
(n, m) = map(int, input().split())
x = [abs(int(i) - m) for i in input().split()]
res = x[0]
for i in x:
	res = gcd(res, i)
print(res)


import math
(n, s) = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
for i in a:
	ans = math.gcd(ans, abs(i - s))
print(ans)


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


import math, sys
(N, X) = map(int, input().split())
x = list(map(int, input().split()))
Distance = [abs(X - x[i]) for i in range(N)]
if N == 1:
	print(abs(X - x[0]))
	return
ans = 0
for i in range(N):
	ans = math.gcd(ans, Distance[i])
print(ans)


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


f = lambda : map(int, input().split())
(n, x) = f()
d = [abs(i - x) for i in f()]
from math import *
a = d.pop()
for i in d:
	a = gcd(a, i)
print(a)


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


(N, X) = map(int, input().split())
x = [abs(int(i) - X) for i in input().split()]
import fractions as math
ans = x[0]
for j in range(1, N):
	ans = math.gcd(ans, x[j])
print(ans)


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


(n, x) = map(int, input().split())
X = tuple(map(lambda k: abs(int(k) - x), input().split()))
from math import gcd
from functools import reduce
ans = reduce(gcd, X)
print(ans)


import math
(N, X) = map(int, input().split())
x = list(map(int, input().split()))
x.append(X)
x.sort()
d = []
if N == 1:
	print(x[1] - x[0])
	return
for i in range(N):
	d.append(x[i + 1] - x[i])
gc = math.gcd(d[0], d[1])
for i in range(N):
	gc = math.gcd(d[i], gc)
print(gc)


def make_divisors(n):
	(lower_divisors, upper_divisors) = ([], [])
	i = 1
	while i * i <= n:
		if n % i == 0:
			lower_divisors.append(i)
			if i != n // i:
				upper_divisors.append(n // i)
		i += 1
	return lower_divisors + upper_divisors[::-1]
a = [int(s) for s in input().split()]
N = a[0]
st = a[1]
mini = int(-1)
b = [int(s) for s in input().split()]
for i in range(N):
	if abs(b[i] - st) < mini or mini == -1:
		mini = abs(b[i] - st)
yakulist = make_divisors(mini)
gyakulist = sorted(yakulist, reverse=True)
kazu = len(gyakulist)
flag = int(0)
for i in range(kazu):
	for j in range(N):
		if abs(b[j] - st) % gyakulist[i] != 0:
			flag = 1
		else:
			pass
	if flag == 0:
		print(gyakulist[i])
		break
	else:
		flag = 0


import math
(n, x) = map(int, input().split())
l = list(map(int, input().split()))
d = abs(l[0] - x)
for m in l:
	d2 = math.gcd(d, abs(m - x))
	d = min(d, d2)
print(d)


from fractions import *
from functools import *
(n, x, *a) = map(int, open(0).read().split())
b = [abs(x - i) for i in a]
print(reduce(gcd, b))


import sys, math
(n, x) = map(int, sys.stdin.readline().split())
xl = [*map(int, sys.stdin.readline().split())]
yl = [abs(x - i) for i in xl]
d = yl[0]
for i in range(n):
	d = math.gcd(d, yl[i])
print(d)


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


(N, X) = map(int, input().split())
List = list(map(int, input().split()))
abs_List = [abs(List[i] - X) for i in range(N)]
import math
from functools import reduce

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

def gcd_list(numbers):
	return reduce(math.gcd, numbers)
print(gcd(*abs_List))


(n, x) = list(map(int, input().split()))
pos = list(map(int, input().split()))
diff_pos = [abs(s - x) for s in pos]
min_diff = min(diff_pos)
ans = 0

def main():
	for i in range(min_diff, 0, -1):
		for n in diff_pos:
			if n % i != 0:
				break
			if n == diff_pos[-1]:
				return i
print(main())


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


from fractions import gcd
(n, x) = [int(x) for x in input().split()]
vs = [abs(int(y) - x) for y in input().split()]
g = 0
for v in vs:
	g = gcd(g, v)
print(g)


from math import gcd
(n, x) = map(int, input().split())
X = list(map(int, input().split()))
X.append(x)
X.sort()
g = X[1] - X[0]
for i in range(n):
	g = gcd(g, X[i + 1] - X[i])
print(g)


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


def gcd(x, y):
	if y == 0:
		return x
	else:
		return gcd(y, x % y)
(n, x) = map(int, input().split())
xxx = list(map(lambda xn: abs(int(xn) - x), input().split()))
ans = xxx[0]
for i in range(1, n):
	ans = gcd(ans, xxx[i])
print(ans)


import sys
import math
input = sys.stdin.readline
(N, X) = map(int, input().split())
A = list(map(int, input().split()))
gcd = abs(X - A[0])
for a_i in A:
	gcd = math.gcd(gcd, abs(X - a_i))
print(gcd)


from math import gcd
(N, X) = map(int, input().split())
L = list(map(lambda x: int(x) - X, input().split()))
a = L[0]
for b in L:
	a = gcd(a, b)
print(a)


from math import gcd
(n, x) = map(int, input().split())
x = list(map(lambda xi: abs(int(xi) - x), input().split()))
g = x[0]
for xi in x:
	g = gcd(g, xi)
print(g)


f = lambda : [*map(int, input().split())]
(n, x) = f()
l = f()
d = [l[i + 1] - l[i] for i in range(n - 1)]
a = abs(x - l[0])
from math import *
for i in d:
	a = gcd(a, i)
print(a)


import math
(N, X) = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
x.append(X)
x.sort()
xdst = [x[i + 1] - x[i] for i in range(N)]
ans = 10 ** 10
if len(xdst) == 1:
	print(xdst[0])
	return
for i in range(N - 1):
	ans = min(math.gcd(xdst[i], xdst[i + 1]), ans)
print(ans)


import fractions
(N, X) = [int(s) for s in input().split()]
ls = [int(s) - X for s in input().split()]
a = 0
for e in ls:
	a = fractions.gcd(a, e)
print(abs(a))


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


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


(N, X) = map(int, input().split())
(*C,) = map(int, input().split())
t = [abs(c - X) for c in C]
import math
from functools import reduce
print(reduce(math.gcd, t))


import math
from functools import reduce
(N, X) = map(int, input().split())
x = list(map(int, input().split()))
x.append(X)
x = [y - X for y in x]
print(reduce(math.gcd, x))


import math
from functools import reduce

def gcd(*numbers):
	return reduce(math.gcd, numbers)
(n, x) = map(int, input().split())
xx = list(map(int, input().split()))
a = [abs(x - i) for i in xx]
print(gcd(*a))


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

def mapt(fn, *args):
	return list(map(fn, *args))

def Input():
	return mapt(int, input().split(' '))

def main():
	(N, X) = Input()
	x = Input()
	if N == 1:
		print(abs(x[0] - X))
		return
	x.append(X)
	x.sort()
	data = [abs(x[i] - x[i + 1]) for i in range(N)]
	ans = data[0]
	for i in range(1, N):
		ans = gcd(data[i], ans)
	print(ans)
main()


import math
from functools import reduce

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

def gcd_list(numbers):
	return reduce(math.gcd, numbers)
(n, X) = map(int, input().split())
x = list(map(int, input().split()))
for i in range(n):
	x[i] = x[i] - X
print(abs(gcd_list(x)))


import math
(N, X) = map(int, input().split())
xl = [abs(x - X) for x in map(int, input().split())]
ans = xl[0]
for x in xl[1:]:
	ans = math.gcd(ans, x)
print(ans)


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


from fractions import *
(n, *a) = map(int, open(0).read().split())
a.sort()
b = [i - j for (i, j) in zip(a[1:], a)]
c = b[0]
for i in b:
	c = gcd(i, c)
print(c)


import math
from functools import reduce

def gcd_list(numbers):
	return reduce(math.gcd, numbers)
(N, X) = list(map(int, input().split()))
x = sorted(list(list(map(int, input().split()))))
y = [abs(i - X) for i in x]
print(gcd_list(y))


from fractions import gcd
(N, X) = map(int, input().split())
x = list(map(int, input().split()))
ans = max(x) - X
for a in x:
	ans = gcd(ans, abs(a - X))
print(ans)


(n, x) = list(map(int, input().split()))
xi = list(map(int, input().split()))
xi.sort()
diff = []
for i in range(n):
	diff.append(abs(xi[i] - x))
import numpy
print(numpy.gcd.reduce(diff))


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


from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement
from functools import reduce

def gcd_list(numbers):
	return reduce(gcd, numbers)
(N, X) = [int(_) for _ in input().split()]
x = [int(_) for _ in input().split()]
if N != 1:
	ret = []
	x.append(X)
	now = x[0]
	for i in x[1:]:
		ret += [i - now]
		now = i
	ret = sorted(ret)
	print(gcd_list(ret))
else:
	print(abs(x[0] - X))


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


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


from functools import reduce
from math import gcd
(n, x) = map(int, input().split())
print(reduce(gcd, (abs(ai - x) for ai in map(int, input().split()))))


from functools import reduce
from fractions import gcd
(n, x) = map(int, input().split())
X = [abs(int(num) - x) for num in input().split()]
print(reduce(gcd, X))


import math
(n, a) = map(int, input().split())
x = list(map(int, input().split())) + [a]
x.sort()
if n == 1:
	print(abs(x[0] - x[1]))
	return
res = x[1] - x[0]
for i in range(1, n):
	res = math.gcd(res, x[i + 1] - x[i])
print(res)


import math
(n, x) = map(int, input().split())
xl = list(map(int, input().split()))
dis = []
ans = 0
for i in range(n):
	dis.append(abs(x - xl[i]))
for i in range(n):
	ans = math.gcd(ans, dis[i])
print(ans)


from functools import reduce
from math import gcd
(N, X) = map(int, input().split())
a = list(map(int, input().split()))
print(reduce(gcd, (abs(a[i] - X) for i in range(N))))


import math
(n, x) = map(int, input().split())
num_list = list(map(int, input().split()))
res = 0
for i in num_list:
	res = math.gcd(res, abs(i - x))
print(res)


import sys
MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.141592653589793

def read_str():
	return sys.stdin.readline().strip()

def read_int():
	return int(sys.stdin.readline().strip())

def read_ints():
	return map(int, sys.stdin.readline().strip().split())

def read_ints2(x):
	return map(lambda num: int(num) - x, sys.stdin.readline().strip().split())

def read_str_list():
	return list(sys.stdin.readline().strip().split())

def read_int_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def GCD(a: int, b: int) -> int:
	return b if a % b == 0 else GCD(b, a % b)

def LCM(a: int, b: int) -> int:
	return a * b // GCD(a, b)

def Main():
	(n, x) = read_ints()
	d = read_int_list()
	ans = abs(x - d[0])
	for i in range(1, n):
		ans = GCD(ans, abs(x - d[i]))
	print(ans)

def __starting_point():
	Main()
__starting_point()


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


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


def gcd(a, b):
	while a != 0 and b != 0:
		if a > b:
			c = a
			a = b
			b = c
		b %= a
	return max(a, b)
(n, x) = map(int, input().split())
d = sorted(list(map(lambda a: abs(a - x), list(map(int, input().split())))))
now = d[0]
for i in d[1:]:
	now = gcd(now, i)
print(now)


from functools import reduce
from fractions import gcd
X = int(input().split()[1])
x = [abs(int(x) - X) for x in input().split()]
print(reduce(gcd, x))


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

def solve(N, X, x):
	x_abs = [abs(X - xi) for xi in x]
	ans = x_abs[0]
	for xi in x_abs[1:]:
		ans = gcd(ans, xi)
	print(ans)

def __starting_point():
	(N, X) = list(map(int, input().split()))
	x = [int(i) for i in input().split()]
	solve(N, X, x)
__starting_point()


(n, x) = map(int, input().split())
A = list(map(int, input().split()))
from fractions import gcd
g = abs(A[0] - x)
for a in A:
	g = gcd(g, abs(a - x))
print(g)


import functools
import math
(N, X) = [int(i) for i in input().split()]
x_list = [abs(int(i) - X) for i in input().split()]
D = functools.reduce(lambda acc, x: math.gcd(acc, x), x_list, 0)
print(D)


from fractions import gcd
(N, X) = map(int, input().split())
xs = list(map(int, input().split()))
xs = [abs(x - X) for x in xs]
s = xs[0]
for x in xs[1:]:
	s = gcd(s, x)
print(s)


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

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

def solve(x_list):
	ans = 0
	for x in x_list:
		ans = gcd(ans, x)
	return ans
(N, X) = map(int, input().split())
x_list = list((abs(int(x) - X) for x in input().split()))
print(solve(x_list))


def resolve():
	from math import gcd
	(_, X) = [int(i) for i in input().split()]
	xx = [int(i) for i in input().split()]
	ans = abs(X - xx[0])
	for x in xx:
		ans = gcd(ans, abs(X - x))
	print(ans)

def __starting_point():
	resolve()
__starting_point()


f = lambda : map(int, input().split())
(_, x) = f()
m = [abs(i - x) for i in f()]
from fractions import gcd
a = m.pop()
for i in m:
	a = gcd(a, i)
print(a)


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


import functools
import math
(N, X) = [int(i) for i in input().split()]
x_list = [int(i) for i in input().split()]
x_list.append(X)
num_list = sorted(x_list)
tmp = [abs(x[0] - x[1]) for x in zip(num_list[:-1], num_list[1:])]
D = functools.reduce(lambda acc, x: math.gcd(acc, x), tmp, 0)
print(D)


def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a
(n, x) = map(int, input().split())
a = [abs(i - x) for i in list(map(int, input().split()))]
x = a[-1]
for i in a[:-1]:
	x = gcd(x, i)
print(x)


import fractions
(n, X) = map(int, input().split())
(*x,) = map(int, input().split())
ans = abs(x[0] - X)
for _x in x:
	ans = fractions.gcd(ans, abs(_x - X))
print(ans)


from math import gcd
(n, x0) = list(map(int, input().split()))
x = [abs(_x - x0) for _x in list(map(int, input().split()))]
x.sort()
ans = x[0]
for i in range(n):
	ans = gcd(ans, x[i])
print(ans)


import math
(n, x) = map(int, input().split())
X = list(map(int, input().split()))
ans = []
for xx in X:
	ans.append(abs(x - xx))
a = ans[0]
for aa in ans:
	a = math.gcd(aa, a)
print(a)


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


from math import gcd
(n, x) = map(int, input().split())
a = [int(i) - x for i in list(map(int, input().split()))]
now = a[0]
for i in a:
	now = gcd(now, i)
print(now)


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


from functools import reduce
from fractions import gcd
(n, x) = map(int, input().split())
a = list(map(lambda i: abs(i - x), map(int, input().split())))
print(reduce(gcd, a))


import math
from functools import reduce

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

def gcd_list(numbers):
	return reduce(math.gcd, numbers)
(n, x) = map(int, input().split())
a = list(map(int, input().split()))
a.append(x)
a.sort()
d = set()
for i in range(n):
	d.add(a[i + 1] - a[i])
d = list(d)
ans = gcd_list(d)
print(ans)


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


from fractions import gcd
(n, d) = map(int, input().split())
x = sorted(list(map(int, input().split())) + [d])
r = x[1] - x[0]
print(min((gcd(x[i + 1] - x[i], r) for i in range(n))))


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


import sys
import math
input = sys.stdin.readline

def main():
	(N, X) = map(int, input().split())
	x = list(map(int, input().split()))
	x.append(X)
	ans = abs(x[0] - X)
	for i in range(N):
		ans = math.gcd(ans, abs(x[i] - x[i + 1]))
	print(ans)

def __starting_point():
	main()
__starting_point()


(n, x) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
for i in range(n):
	a[i] = abs(a[i] - x)

def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x
res = a[0]
for i in range(n):
	res = gcd(res, a[i])
print(res)


from math import *
(N, x) = map(int, input().split())
(*X,) = map(int, input().split())
ans = abs(X[0] - x)
now = X[0]
for i in X[1:]:
	ans = gcd(ans, abs(i - now))
	now = i
print(ans)


from fractions import gcd
(N, X) = map(int, input().split())
P = map(int, input().split())
ans = 0
for p in P:
	ans = gcd(ans, abs(p - X))
print(ans)


(N, X) = map(int, input().split())
x = list(map(int, input().split()))
x.append(X)
from math import gcd
g = x[1] - x[0]
for i in range(N):
	g = gcd(g, x[i + 1] - x[i])
print(abs(g))


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


import math

def gcd_list(nums):
	gcd = nums[0]
	for i in range(1, len(nums)):
		gcd = math.gcd(gcd, nums[i])
	return gcd
(N, X) = map(int, input().split())
x = list(map(int, input().split()))
x = [abs(i - X) for i in x]
print(gcd_list(x))


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


(n, x) = map(int, input().split())
xlist = list(map(int, input().split()))
ylist = []
for i in range(n):
	ylist.append(xlist[i] - x)
import math
ans = ylist[0]
for i in range(n):
	ans = math.gcd(ans, ylist[i])
print(ans)


(n, x) = map(int, input().split())
al = list(map(int, input().split()))
import math
temp = abs(x - al[0])
for i in range(1, n):
	y = al[i] - al[i - 1]
	temp = math.gcd(temp, y)
print(temp)


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


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


import math
from functools import reduce

def gcd(numbers):
	return reduce(math.gcd, numbers)
a = list(map(int, input().split()))
b = list(map(int, input().split()))
b.append(a[1])
c = sorted(b)
d = []
for i in range(a[0]):
	d.append(c[i + 1] - c[i])
print(gcd(d))


import math
(n, x) = map(int, input().split())
a = list(map(int, input().split()))
g = 0
for y in a:
	g = math.gcd(g, abs(y - x))
print(g)


import math
(n, x) = map(int, input().split())
xi = list(map(int, input().split()))
xi = list(map(lambda z: abs(z - x), xi))
g = xi[0]
for i in range(1, n):
	g = math.gcd(g, xi[i])
print(g)


import math
(N, X) = map(int, input().split())
cities = list(map(lambda x: int(x) - X, input().split()))
res = abs(cities[0])
for i in range(1, N):
	res = math.gcd(res, cities[i])
print(res)


import math
(N, X) = map(int, input().split())
xs = list(map(int, input().split()))
dist = []
for i in range(N):
	dist.append(abs(xs[i] - X))
ans = dist[0]
for d in dist[1:]:
	ans = math.gcd(ans, d)
print(ans)


import fractions

def gcdlist(a):
	ans = a[0]
	for i in range(1, len(a)):
		ans = fractions.gcd(ans, a[i])
	return ans
(n, y) = list(map(int, input().split()))
x = list(map(int, input().split()))
x.append(y)
if y == 1:
	print(abs(x[0] - 1))
	return
l = []
for i in range(n):
	l.append(abs(x[i + 1] - x[i]))
print(gcdlist(l))


from fractions import gcd
(n, x) = map(int, input().split())
lis = list(map(int, input().split()))
g = abs(x - lis[0])
for i in lis[1:]:
	g = gcd(abs(x - i), g)
print(g)


import fractions
(a, b) = map(int, input().split())
x = list(map(int, input().split()))
m = abs(x[0] - b)
for i in range(a):
	m = fractions.gcd(m, abs(x[i] - b))
print(m)


(n, x) = map(int, input().split())
L = list(map(int, input().split()))
L.append(x)
L.sort()
D = []
for i in range(n):
	d = L[i + 1] - L[i]
	D.append(d)
import math
ans = D[0]
for i in range(1, n):
	ans = math.gcd(ans, D[i])
print(ans)


from fractions import gcd
from functools import reduce
(n, x) = map(int, input().split())
num = [abs(int(i) - x) for i in input().split() if abs(int(i) - x) != 0]
print(reduce(gcd, num))


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)


from math import gcd
(n, x) = list(map(int, input().split()))
ls = sorted(list(map(int, input().split())))
if x == 1:
	print(abs(x - ls[0]))
	return
distant = []
for i in range(n):
	diff = abs(ls[i] - x)
	distant.append(diff)
distant.sort()
a = distant[0]
for i in distant:
	g = gcd(a, i)
	a = g
print(g)


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)


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


from functools import reduce

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


import math
from functools import reduce

def gcd(list):
	return reduce(math.gcd, list)
(n, x) = map(int, input().split())
a = map(lambda b: abs(int(b) - x), input().split())
print(gcd(a))


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


from fractions import gcd
(N, X) = map(int, input().split())
xs = list(map(int, input().split()))
g = X - xs[0]
for (a, b) in zip(xs, xs[1:]):
	g = gcd(g, a - b)
print(abs(g))


import math
(n, m) = map(int, input().split())
x = [int(x) for x in input().split()]
mi = min(x)
l = [abs(x[i] - x[i + 1]) for i in range(n - 1)]
ans = abs(mi - m)
for i in l:
	ans = math.gcd(ans, i)
print(ans)


import fractions
(n, st) = map(int, input().split())
(*x,) = map(int, input().split())
e = abs(x[0] - st)
for i in range(1, n):
	e = fractions.gcd(e, abs(x[i] - st))
print(e)


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)


from functools import reduce
from math import gcd
(n, x) = map(int, input().split())
L = [abs(x - int(i)) for i in input().split()]
print(reduce(gcd, L))


import math
(N, X) = map(int, input().split())
x = list(map(int, input().split()))
ls = []
for i in range(N):
	ls.append(abs(x[i] - X))
now = ls[0]
for i in range(1, N):
	now = math.gcd(ls[i], now)
print(now)


(n, x) = map(int, input().split())
a = list(map(int, input().split()))
a.append(x)
a = sorted(a)
diff_list = [0] * n
for i in range(1, n + 1):
	diff_list[i - 1] = a[i] - a[i - 1]
g = diff_list[0]
import math
for i in range(1, n):
	g = math.gcd(g, diff_list[i])
print(g)


import math
(n, x) = map(int, input().split())
l = [abs(x - i) for i in list(map(int, input().split()))]
r = 0
for i in range(len(l)):
	r = math.gcd(r, l[i])
print(r)


import fractions
(N, X) = map(int, input().split())
(*x,) = [int(v) - X for v in input().split()]
chk = 0
for v in x:
	chk = fractions.gcd(chk, v)
print(abs(chk))


from fractions import *
(_, X, *x) = map(int, open(0).read().split())
(s, *x) = [abs(X - t) for t in x]
for t in x:
	s = gcd(s, t)
print(s)


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


def main():
	import math
	import sys
	pin = sys.stdin.readline
	pout = sys.stdout.write
	perr = sys.stderr.write
	(N, X) = map(int, pin().split())
	x = list(map(int, pin().split()))
	m = abs(x[0] - X)
	for i in range(1, N):
		m = math.gcd(abs(x[i] - X), m)
	print(m)
	return
main()


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


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


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


from fractions import gcd
(N, X) = map(int, input().split())
P = list((abs(int(x) - X) for x in input().split()))
v = P[0]
for x in P[1:]:
	v = gcd(v, x)
print(v)


import math
from functools import reduce
(n, x) = map(int, input().split())
X = sorted(list(map(int, input().split())) + [x])
print(reduce(math.gcd, [X[i + 1] - X[i] for i in range(n)]))


import math
from math import gcd, pi, sqrt
INF = float('inf')
import sys
sys.setrecursionlimit(10 ** 6)
import itertools
from collections import Counter, deque

def i_input():
	return int(input())

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

def i_list():
	return list(i_map())

def i_row(N):
	return [i_input() for _ in range(N)]

def i_row_list(N):
	return [i_list() for _ in range(N)]

def s_input():
	return input()

def s_map():
	return input().split()

def s_list():
	return list(s_map())

def s_row(N):
	return [s_input for _ in range(N)]

def s_row_str(N):
	return [s_list() for _ in range(N)]

def s_row_list(N):
	return [list(s_input()) for _ in range(N)]
import string

def main():
	(N, X) = i_map()
	x = i_list()
	l = []
	for i in x:
		l.append(abs(X - i))
	ans = l[0]
	for k in l[1:]:
		ans = gcd(ans, k)
	print(ans)

def __starting_point():
	main()
__starting_point()


import math
from functools import reduce
from sys import setrecursionlimit
setrecursionlimit(10 ** 6)

def gcd(*numbers):
	return reduce(math.gcd, numbers)
(n, x) = map(int, input().split())
xl = list(map(int, input().split()))
xl = list(map(lambda y: abs(y - x), xl))
ans = -1
if len(xl) == 1:
	ans = xl[0]
else:
	ans = gcd(*xl)
print(ans)


(N, X) = map(int, input().split())
x = list(map(int, input().split()))
x = sorted([abs(i - X) for i in x])
y = x[0]
for i in range(1, N):
	z = x[i]
	(y, z) = (max(y, z), min(y, z))
	while z != 0:
		(y, z) = (z, y % z)
print(y)


from math import gcd
(n, X) = map(int, input().split())
xlst = list(map(int, input().split()))
ans = X - xlst[0]
for x in xlst:
	ans = gcd(ans, X - x)
print(ans)


import math
from functools import reduce

def gcd_list(numbers):
	return reduce(math.gcd, numbers)
(N, X) = map(int, input().split())
x_list = [X] + list(map(int, input().split()))
x_list.sort()
dist = [0] * (N + 1)
for i in range(N):
	dist[i] += x_list[i + 1] - x_list[i]
ans = gcd_list(dist)
print(ans)


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


from functools import reduce
from math import gcd
(n, X, *x) = map(int, open(0).read().split())
x = [abs(i - X) for i in x]
print(reduce(gcd, x))


import fractions
import functools
(n, x) = [int(_) for _ in input().split()]
c = [abs(x - int(_)) for _ in input().split()]
print(functools.reduce(fractions.gcd, c))


(n, x) = map(int, input().split())
li = list(input().split())
li = [abs(int(a) - x) for a in li]

def gcd(a, b):
	while a % b != 0:
		(a, b) = (b, a % b)
	return b
from functools import reduce
a = reduce(gcd, li)
print(a)


import fractions
(n, x) = [int(i) for i in input().split()]
z = [abs(x - int(i)) for i in input().split()]
ans = z[n - 1]
for i in range(n - 1):
	ans = fractions.gcd(z[i], ans)
print(ans)


from functools import reduce
from fractions import gcd
(N, X) = list(map(int, input().split()))
x = list(map(int, input().split()))
res = list((abs(i - X) for i in x))
print(reduce(gcd, res))


from math import gcd
(n, x) = map(int, input().split())
m = [x] + list(map(int, input().split()))
m.sort()
if n == 1:
	print(m[1] - m[0])
else:
	res = gcd(m[1] - m[0], m[2] - m[1])
	for i in range(1, n - 1):
		a = m[i + 1] - m[i]
		b = m[i + 2] - m[i + 1]
		if res >= gcd(a, b):
			if res % gcd(a, b) == 0:
				res = gcd(a, b)
			else:
				res = gcd(res, gcd(a, b))
		elif gcd(a, b) % res != 0:
			res = gcd(res, gcd(a, b))
	print(res)


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


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)


import bisect
import math
(N, X) = map(int, input().split())
x = list(map(int, input().split()))
x = sorted(x, reverse=False)
bisect.insort_left(x, X)
d_lis = []
for i in range(len(x) - 1):
	d = x[i + 1] - x[i]
	d_lis.append(d)
d_lis = sorted(d_lis, reverse=False)
ans = d_lis[0]
for j in range(1, len(d_lis)):
	ans = math.gcd(ans, d_lis[j])
print(ans)


from fractions import gcd
(n, x) = map(int, input().split())
p = list(map(lambda s: abs(s - x), list(map(int, input().split()))))
g = p[0]
for i in p:
	g = gcd(g, i)
print(g)


from fractions import gcd
(n, x) = map(int, input().split())
a = sorted(list(map(int, input().split())) + [x])
c = 0
for i in range(n):
	c = gcd(c, a[i + 1] - a[i])
print(c)


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


import math
(N, X) = map(int, input().split())
x = list(map(int, input().split()))
y = [abs(x[i] - X) for i in range(N)]
if N == 1:
	print(y[0])
	return
ans = math.gcd(y[0], y[1])
for i in range(2, N):
	ans = min(ans, math.gcd(y[i], ans))
print(ans)


import fractions
(N, X) = map(int, input().split())
y = list(map(int, input().split()))
z = abs(X - y[0])
for i in range(1, N):
	z = fractions.gcd(z, abs(X - y[i]))
print(z)


import math
(N, X) = map(int, input().split())
xs = list(map(int, input().split()))
diffs = []
g = abs(X - xs[0])
for i in range(1, N):
	g = math.gcd(g, abs(X - xs[i]))
print(g)


from fractions import gcd
(n, X) = map(int, input().split())
x = list(map(int, input().split()))
m = max(X - x[0], x[0] - X)
for i in range(n):
	m = gcd(m, max(X - x[i], x[i] - X))
print(m)


from fractions import gcd
from functools import reduce
(n, *x) = map(int, open(0).read().split())
x.sort()
d = [x[i + 1] - x[i] for i in range(n)]
print(reduce(gcd, d))


def l():
	return list(map(int, input().split()))
(N, X) = l()
x = l()
for i in range(N):
	x[i] = abs(x[i] - X)
mini = min(x)
lst = []
for i in range(1, int(mini ** 0.5) + 1):
	if mini % i == 0:
		lst.append(i)
		lst.append(mini // i)
lst.sort()
lst = lst[::-1]
for i in lst:
	flag = True
	for j in x:
		if j % i != 0:
			flag = False
	if flag:
		break
print(i)


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


import math
from functools import reduce

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

def main():
	(n, X) = list(map(int, input().split()))
	x = list(map(int, input().split()))
	x.append(X)
	x.sort()
	x_dist = [x[i + 1] - x[i] for i in range(len(x) - 1)]
	print(gcd(*x_dist))

def __starting_point():
	main()
__starting_point()


(n, x, *l) = map(int, open(0).read().split())
from math import *
a = 0
for i in l:
	a = gcd(a, abs(i - x))
print(a)


from math import gcd
(N, X) = list(map(int, input().split()))
x = list(map(int, input().split()))
dis = []
for i in range(N):
	dis.append(abs(X - x[i]))
res = 0
for i in range(N):
	res = gcd(res, dis[i])
print(res)


from fractions import gcd
(N, X) = map(int, input().split())
src = list(map(int, input().split()))
g = abs(X - src[0])
for x in src[1:]:
	g = gcd(g, abs(X - x))
print(g)


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)


import fractions as f
(n, x) = map(int, input().split())
A = list(map(int, input().split()))
a = [abs(x - aa) for aa in A]
for i in range(1, n):
	a[i] = f.gcd(a[i], a[i - 1])
print(a[n - 1])


import numpy as np
(n, X) = map(int, input().split())
x = list(map(int, input().split()))
x.append(X)
x = sorted(x)
dis = []
for i in range(n):
	dis.append(x[i + 1] - x[i])
print(np.gcd.reduce(dis))


import functools
import fractions
(n, x) = map(int, input().split())
X = list(map(lambda i: abs(int(i) - x), input().split()))
gcd = functools.reduce(fractions.gcd, X)
print(gcd)


import math

def main():
	(n, x) = map(int, input().split())
	x_lst = list(map(int, input().split()))
	x_lst.sort()
	if n == 1:
		minimum = abs(x_lst[0] - x)
	elif n == 2:
		minimum = abs(x_lst[1] - x_lst[0])
		lst = [abs(x_lst[1] - x), abs(x_lst[0] - x)]
		lst.sort()
		lst.reverse()
		for i in range(2):
			if minimum % lst[i] == 0:
				minimum = lst[i]
				break
	else:
		lst1 = []
		for i in range(n):
			if i != n - 1:
				lst1.append(abs(x_lst[i + 1] - x_lst[i]))
		minimum = math.gcd(lst1[0], lst1[1])
		for i in range(n - 1):
			if i != n - 2:
				minimum = min(minimum, math.gcd(lst1[i], lst1[i + 1]))
		lst2 = []
		for i in range(n):
			lst2.append(abs(x_lst[i] - x))
		lst2.sort()
		lst2.reverse()
		for i in range(n):
			if minimum % lst2[i] == 0:
				minimum = lst2[i]
				break
	print(minimum)

def __starting_point():
	main()
__starting_point()


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


from fractions import gcd
(n, a) = map(int, input().split())
b = list(map(int, input().split())) + [a]
b.sort()
s = b[1] - b[0]
for i in range(n):
	s = gcd(b[i + 1] - b[i], s)
print(s)


import sys
import math
from functools import reduce
(n, k) = map(int, input().split())
x = list(map(int, input().split()))
l = []
for i in x:
	b = abs(i - k)
	l.append(b)

def gcd_list(numbers):
	return reduce(math.gcd, numbers)
ans = gcd_list(l)
print(ans)


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


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


import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
input = sys.stdin.readline

def RD():
	return input().rstrip()

def F():
	return float(input().rstrip())

def I():
	return int(input().rstrip())

def MI():
	return map(int, input().split())

def MF():
	return map(float, input().split())

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

def TI():
	return tuple(map(int, input().split()))

def LF():
	return list(map(float, input().split()))

def Init(H, W, num):
	return [[num for i in range(W)] for j in range(H)]

def main():
	(N, X) = MI()
	L = LI()
	L = [abs(i - X) for i in L]
	ans = L[0]
	for i in L:
		ans = math.gcd(ans, i)
	print(ans)

def __starting_point():
	main()
__starting_point()


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


import math
from functools import reduce
(n, x) = map(int, input().split())
a = list(map(int, input().split()))
a.append(x)
b = []
for i in range(len(a) - 1):
	b.append(abs(a[i] - a[i - 1]))

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


from math import gcd

def readinput():
	(n, x) = list(map(int, input().split()))
	xx = list(map(int, input().split()))
	return (n, x, xx)

def main(n, x, xx):
	y = [0] * len(xx)
	for i in range(len(xx)):
		y[i] = abs(xx[i] - x)
	if len(y) == 1:
		ans = y[0]
	else:
		ans = gcd(y[0], y[1])
		for i in range(2, n):
			ans = gcd(ans, y[i])
	return ans

def __starting_point():
	(n, x, xx) = readinput()
	ans = main(n, x, xx)
	print(ans)
__starting_point()


(n, x0) = map(int, input().split())
x = list(map(int, input().split()))
x = {abs(xi - x0) for xi in x}
while x:
	d = min(x)
	x = {xi % d for xi in x if xi % d}
print(d)


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)


import math
(N, X) = map(int, input().split())
L = list(map(int, input().split()))
L.append(X)
L = sorted(L)
m = L[1] - L[0]
for i in range(N):
	m = math.gcd(m, L[i + 1] - L[i])
print(m)


import math
import functools
(N, X) = list(map(int, input().split()))
A = [abs(X - int(i)) for i in input().split()]
print(functools.reduce(math.gcd, A))


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


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


import math
(N, X) = map(int, input().split())
x = list(map(int, input().split()))
absx = [abs(X - xx) for xx in x]
absx.sort()
divx0 = []
for i in range(math.ceil(math.sqrt(absx[0])), 0, -1):
	if absx[0] % i == 0:
		divx0.append(i)
t = []
for x in divx0:
	t.append(x)
	t.append(absx[0] // x)
divx0 = t
divx0.sort(reverse=True)
for dx0 in divx0:
	isok = True
	for xx in absx:
		if xx % dx0 != 0:
			isok = False
			break
	if isok:
		print(dx0)
		return


(N, X) = list(map(int, input().split()))
import math
a = list(map(int, input().split()))
a.append(X)
a.sort()
S = []
for i in range(N):
	S.append(a[i + 1] - a[i])
ans = S[0]
for j in range(1, N):
	ans = math.gcd(ans, S[j])
print(ans)


import math
(N, A) = map(int, input().split())
X = list(map(int, input().split()))
L = [abs(x - A) for x in X]
S = L[0]
for i in range(1, N):
	S = math.gcd(S, L[i])
print(S)


(n, x) = map(int, input().split())
xlist = list(map(int, input().split()))
if n == 1:
	print(abs(xlist[0] - x))
	return
ylist = []
for i in range(n):
	ylist.append(abs(xlist[i] - x))
from functools import reduce
from math import gcd
print(reduce(gcd, ylist))


import sys
import math
sys.setrecursionlimit(10 ** 8)
ini = lambda : int(sys.stdin.readline())
inl = lambda : [int(x) for x in sys.stdin.readline().split()]
ins = lambda : sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print('\x1b[33m', *a, '\x1b[0m', **dict(file=sys.stderr, **kw))

def solve():
	(n, start) = inl()
	X = inl()
	g = None
	for x in X:
		d = abs(x - start)
		if g is None:
			g = d
		else:
			g = math.gcd(g, d)
	return g
print(solve())


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


import math
from functools import reduce
(N, A) = map(int, input().split())
X = list(map(int, input().split()))
L = [abs(x - A) for x in X]
print(reduce(math.gcd, L))