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

import sys
import copy
import collections
from bisect import bisect_left

def gcd(a, b):
	if a > b:
		a, b = b, a
		
	while a > 0:
		a, b = b % a, a
	return b
	
def main():
	N, X = map(int, input().split(" "))
	L = input().split(" ")
	L = [int(s) for s in L]
	
	if N == 1:
		print(abs(L[0]-X))
		sys.exit()
	
	L.sort()
	tmp = bisect_left(L, X)
	
	max1 = 2000000001
	if tmp < len(L):
		max1 = L[tmp]
	
	min1 = 2000000001
	if tmp != 0:
		min1 = L[tmp-1]
	
	seed = 0
	mark = -1
	if abs(max1-X) < abs(X-min1):
		seed = abs(max1-X)
		mark = tmp
	else:
		seed = abs(X-min1)
		mark = tmp-1
	
	ans = 2000000001
	for i, val in enumerate(L):
		if i == mark:
			continue
		tmp = abs(L[i] - L[mark])
		ans_tmp = gcd(tmp, seed)
		if ans > ans_tmp:
			ans = ans_tmp
	
	print(ans)
		
	
if __name__ == "__main__":
	main()

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

xdef = [abs(x[i]-X) for i in range(N)]
def gcd(m,n):
  x = max(m,n)
  y = min(m,n)
  if x%y == 0:
    return y
  else:
    while x%y != 0:
      z = x%y
      x = y
      y = z
    else:
      return z

if N == 1:
  print(xdef[0])
else:
  tmp = gcd(xdef[0], xdef[1])
  for i in range(1,N):
    tmp = gcd(tmp,xdef[i])
  print(tmp)

Solution (Python):
tmp=input().split(" ")
n = int(tmp[0])
initialPoint = int(tmp[1])

points= [ abs(int(s)-initialPoint) for s in input().split(" ") ]

def gcd(m, n):
    
    tmp = max(m,n)
    n = min(m,n)
    m = tmp
    
    if n == 0:
        return m
    
    return gcd(n, m % n)

if n == 1:
    print(points[0])
    exit()

now=gcd(points[0], points[1])
for i in range(2, len(points)):
    now = gcd(now, points[i])

print(now)

Solution (Python):



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


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

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

print(sa[-1])

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

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

def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)
        
if len(x) < 2:
    print(x[0])
else:
    D = gcd(x[0], x[1])
    for i in range(2, N):
        D = gcd(D, x[i])

    print(D)

Solution (Python):
import fractions
from functools import reduce
from sys import stdin
N, X = [int(_) for _ in stdin.readline().rstrip().split()]
xs = [int(_) for _ in stdin.readline().rstrip().split()]
xs.sort()
diff = [xs[i] - xs[i-1] if i > 0 else abs(xs[i]-X) for i in range(N)]
gcd = reduce(fractions.gcd, diff)
print(gcd)

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 = list(map(lambda arg: abs(arg - X), x))

g = x[0]
for xx in x[1:]:
    g = gcd(g, xx)
print(g)

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 = sorted(x)
x = list(map(lambda arg: abs(arg - X), x))

g = x[0]
for xx in x:
    g = gcd(g, xx)
print(g)

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

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)
diff = [x[i+1] - x[i] for i in range(N)]
if len(diff) == 1:
    print(diff[0])
    exit()
ans = gcd(diff[0], diff[1])
for i in range(2, N):
    ans = gcd(ans, diff[i])
print(ans)

Solution (Python):

import sys
import fractions


def solve(N: int, X: int, x: "List[int]"):
    x.sort()
    gMax = None
    last = None
    begin = 0
    if abs(X - x[0]) > 0:
        last = abs(X-x[0])
        gMax = last
    else:
        begin = 1
        last = x[1]-x[0]
        gMax = last
    for i in range(begin, N-1):
        next = x[i+1] - x[i]
        gMax = fractions.gcd(gMax, next)
    print(gMax)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    X = int(next(tokens))  
    x = [int(next(tokens)) for _ in range(N)]  
    solve(N, X, x)


if __name__ == '__main__':
    main()

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

N,A = map(int,input().split())
X = sorted(map(int,input().split()))
Y = []
for x in X:
    Y.append(abs(A-x))
ans = max(Y)
for y in Y:
    ans = gcd(y,ans)
print(ans)

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

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

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

inpl = lambda: list(map(int,input().split()))
N, X = inpl()
x = inpl()
y = [ p - X for p in x ]
print(abs(gcd_list(y)))

Solution (Python):
def main():
	N, X = map(int, input().split())
	x = list(map(int, input().split()))
	x.append(X)
	x.sort()
	diff = [0]*N
	for i in range(N):
		diff[i] = x[i+1] - x[i]

	def gcd(a, b):
		if (b == 0):
			return a
		else:
			return gcd(b, a%b)
	ans = diff[0]
	for c in diff[1:]:
		ans = gcd(ans, c)

	print(ans)


if __name__ == '__main__':
    main()

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

dist = [abs(X - x[i]) for i in range(N)]
print(gcd(dist))

Solution (Python):
n, x = map(int, input().split())
xlist = [int(n) for n in input().split()]
dis_list = [abs(x - y) for y in xlist]
dis_list = sorted(dis_list)

def gojo(num1, num2):

	if num2 == 0:
		return num1
	else:
		return gojo(num2, num1 % num2)
if n == 1:
	print(dis_list[0])
else:
	gcd = gojo(dis_list[1], dis_list[0])
	for i in range(1, n):
		gcd = gojo(dis_list[i], gcd)
	print(gcd)

Solution (Python):
import fractions
import sys

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

gcd = d_min
for i in dif:
    tmp = fractions.gcd(gcd, i)
    if tmp == 1:
        print(1)
        sys.exit()
    else:
        gcd = tmp

print(gcd)

Solution (Python):
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()))))

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

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

x.append(X)
x.sort()

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

now = x[1] - x[0]

for i in range(1, N):
    distance = x[i+1] - x[i]
    now = gcd(now, distance)
    if now == 1:
        break
print(now)

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

Solution (Python):
import fractions
from functools import reduce

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

xi.append(X)
xi.sort()

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

ans = reduce(fractions.gcd, diffs)
print(ans)

Solution (Python):
from fractions import gcd

from math import sqrt

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

Solution (Python):
import math

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


N,X = map(int,input().split())
x = input().split()
xls = []
 
for n in range(0,N):
    xls.append(int(x[n]))
 
xls.append(X)
xls.sort(reverse = True)
 
tousa = []
 
for n in range(0,N):
    tousa.append(xls[n]-xls[n+1])
 
if len(tousa) == 1:
    print(tousa[0])
    exit()
gcdd = gcd(tousa[0],tousa[1])
 
for n in range(0,N):
    gcdd = gcd(gcdd,tousa[n])
    
print(gcdd)

Solution (Python):
import fractions
N,X=map(int,input().split(' '))
towns=list(map(int,input().split(' ')))
dists=[ abs(X-town) for town in towns ]
if N==1:
	print(dists[0])
else:
	ans=-1
	for i in range(N-1):
		if ans==-1:
			ans=fractions.gcd(dists[i],dists[i+1])
		else:
			ans=fractions.gcd(ans,dists[i])
	print(ans)

Solution (Python):
import sys

def egcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return a


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


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

print(ans)

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

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

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

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

Solution (Python):


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

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

length = []

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

ans = length[0]

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

print(ans)

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

Solution (Python):
from fractions import gcd

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

D = None
for x in xs:
    x = abs(x - X)
    if D is None:
        D = x
    else:
        D = gcd(D, x)

print(D)

Solution (Python):
from functools import reduce


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


def _gcd(*n):
    return reduce(gcd, n)


N, X = map(int, input().split())
x = list(map(int, input().split()))
x = sorted(x + [X])
diff = [x[i+1] - x[i] for i in range(N)]
print(_gcd(*diff))

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

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

for i in range(N):
  tmp = abs(X-all_x[i])
  if(i == 0):
    ans = tmp
  else:
    ans = gcd(ans,tmp)
print(ans)

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


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


N, X = map(int, input().split())
x = [int(_) for _ in input().split()]
GCD = abs(X-x[0])

for i in x:
    GCD = gcd(GCD, abs(X-i))

print(GCD)

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(lambda x: abs(int(x) - X), input().split()))

ans = x[0]
for i in range(N):
    if x[i]%ans == 0:
        continue
    ans = gcd(ans, x[i])

print(ans)

Solution (Python):
from functools import reduce

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

def gcd(*numbers):
    return reduce(gcd_two, numbers)


INF = 10**9


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

d_list = [abs(X-i) for i in x_list]
print(gcd(*d_list))

Solution (Python):
import fractions

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

d_ = list(set([x_[i+1]-x_[i] for i in range(N)]))

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

Solution (Python):
import fractions
from functools import reduce

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

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

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

x.append(X)
x.sort()

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

print(gcd(*dist))

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

import fractions
from functools import reduce

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

print(gcd_list(d))

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

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

print(gcd(x))

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

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

if len(diff) >= 2:
    gcd_val = diff[0]
    for i in diff[1:]:
        gcd_val = gcd(gcd_val,i)
    print(gcd_val)
else:
    print(diff[0])

Solution (Python):

from functools import reduce
def gcd(a, b):
    if b == 0:
        return max(a, b)
    else:
        return gcd(b, a%b)

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

Solution (Python):

from functools import reduce
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
N, X = map(int, input().split())
x = list(map(int, input().split()))
x = [abs(X - x[i]) for i in range(N)]
it = iter(x)
value = x[0]
for i in it:
    value = gcd(value, i)
print(value)

Solution (Python):

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

Solution (Python):
import sys
import math
import fractions
from functools import reduce
from collections import Counter
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]  
def LF(): return [float(x) for x in sys.stdin.readline().split()]  
def LS(): return sys.stdin.readline().split()  
def MI(): return map(int, sys.stdin.readline().split())  
def II(): return int(sys.stdin.readline())  
def IS(): return input()  
def P(x): return print(x)
def C(x): return Counter(x)
def GCD_LIST(numbers):
    return reduce(fractions.gcd, numbers)


N, X = MI()
x = LI()
diff = [abs(X - i) for i in x]
print(GCD_LIST(diff))

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

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

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

print(D)

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

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

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

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


gcd_val = diff[0]
for i in diff[1:]:
    gcd_val = gcd(i,gcd_val)

print(gcd_val)

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

import sys
input = sys.stdin.readline
N, S = map(int, input().split())
X = list(map(int, input().split()))
if N > 1:
    D = gcd(abs(X[0] - S), abs(X[1] - S))
    for x in X[2:]:
        D = gcd(abs(S - x), D)
    print(D)
else:
    print(abs(S - X[0]))

Solution (Python):
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator

from fractions import gcd


inf = float('inf')



N, X = 0, 0
C = []


def set_inputs():
    global N, X, C
    N, X = get_li()
    C = get_li()
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    ans = reduce(gcd, filter(lambda x: x != 0, map(lambda x: abs(x-X), C)))
    print(ans)
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types):
    if len(types) == 1:
        return [types[0](input()) for _ in range(n)]
    return zip(*(
        [t(x) for t, x in zip(types, input().split())]
        for _ in range(n)
    ))


if __name__ == '__main__':
    main()

Solution (Python):
from functools import reduce
import fractions

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

distance = [abs(X-xn[i]) for i in range(N)]
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
print(gcd_list(distance))

Solution (Python):
import fractions as f
from functools import reduce
def gcd(nums):
    return reduce(f.gcd,nums)

N,X = [int(a) for a in input().split()]
x = [abs(int(a)-X) for a in input().split()]
print(gcd(x))

Solution (Python):
n,x=map(int,input().split())
X=list(map(int,input().split()))
for i in range(n):
  X[i]=abs(X[i]-x)
def gcd(p,q):
  if q==0:
    return p
  else:
    return gcd(q,p%q)
stack=X[0]
for i in range(n-1):
  stack=gcd(stack,X[i+1])
print(stack)

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

x = [abs(X-xx) for xx in x]

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

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

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

def gcd(x):
    if len(x) == 1:
        return x[0]
    m = min(x)
    return gcd([m]+[y%m for y in x if (y%m)>0])

print(gcd(x))

Solution (Python):
import fractions

N,X = (int(x) for x in input().split())
x = [int(p) for p in input().split()]
x.append(X)
x.sort()
D = x[1] - x[0]

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

print(D)

Solution (Python):
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)
N,X = map(int,input().split())
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)

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.append(X)
x.sort()
x = [x[i]-x[0] for i in range(n+1)]
del x[0]
g = x[0]
for i in range(1, n):
    g = gcd(g,x[i])
print(g)

Solution (Python):
import sys

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

def make_divisor_list(num):
    if num < 1:
        return []
    elif num == 1:
        return [1]
    else:
        divisor_list = []
        divisor_list.append(1)
        for i in range(2, num // 2 + 1):
            if num % i == 0:
                divisor_list.append(i)
        divisor_list.append(num)

        return divisor_list
      
distance = [0] * N
diffs = [0] * (N-1)
for i in range(len(x)):
  distance[i] = abs(x[i] - X)
  if i > 0:
    diffs[i-1] = x[i] - x[i-1]

if N == 1:
  print(distance[0])
  sys.exit()
else:
  nearest = min(min(distance), min(diffs))

divisor = make_divisor_list(nearest)

for item in divisor[::-1]:
  for d in distance:
    if d%item != 0:
      break
    print(item)
    sys.exit()

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

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

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

Solution (Python):
import functools

def gcd(x,y):
    big = max(x,y)
    small = min(x,y)
    while small > 0:
        big, small = small, big % small

    return big

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

diffs = [abs(X - x) for x in xs]

print(functools.reduce(gcd,diffs))

Solution (Python):

import sys


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


def solve(N: int, X: int, x: "List[int]"):
    y = [abs(item-X) for item in x]
    ans = y[0]
    for a in y:
        ans = GCD(a, ans)

    print(ans)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    X = int(next(tokens))  
    x = [int(next(tokens)) for _ in range(N)]  
    solve(N, X, x)


if __name__ == '__main__':
    main()

Solution (Python):
N,X = map(int,input().split())
x = list(map(int,input().split()))
x.append(X)
x.sort()
xdif = [x[i+1] - x[i] for i in range(N)]
minxdif = min(xdif)
divisor = []
i = 1
for i in range(1,int(minxdif**0.5) + 1):
    if minxdif % i == 0:
        divisor.append(i)
        if i != minxdif//i:
            divisor.append(minxdif//i)
divisor = sorted(divisor)[::-1]
flag = 0
for div in divisor:
    for dif in xdif:
        if dif % div != 0:
            flag = 1
    if flag == 0:
        print(div)
        break
    flag = 0

Solution (Python):
from fractions import gcd
import bisect

N, X = map(int, input().split())
x = [int(i) for i in input().split()]
a = x[-1]
x.append(a)
x.sort()
bisect.insort_left(x, X)
ans = 0
for y, z in zip(x[:-1], x[1:]):
    ans = gcd(ans, z-y)
print(ans)

Solution (Python):


















import math
import numpy as np
import copy
from collections import defaultdict, Counter
from itertools import product
from bisect import bisect_left, bisect_right

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

N, X = s_inpl()
x = inpl()

x_diff = [ abs(X - xi) for xi in x]


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


def gcdlist(numbers):
    a = numbers[0]
    for i in range(len(numbers)):
        a = gcd(a, numbers[i])
    return a

print(gcdlist(x_diff))

Solution (Python):
from functools import reduce

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

def gcd(*num):
    return reduce(gcds, *num)

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

    x_n = sorted(x_n)
    x_n = [n - X for n in x_n] 
    
    print(abs(gcd(x_n)))
    return

main()

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

for idx in range(N):
	xs[idx] = abs(xs[idx]-X)

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

tmp = xs[0]
for idx in range(N-1):
	tmp = gcd(tmp, xs[idx+1])

print(tmp)

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

Solution (Python):
def euclid(diff_list):
    n = len(diff_list)
    gcd_ = gcd(diff_list[0], diff_list[1])
    for i in range(2, n):
        gcd_ = gcd(gcd_, diff_list[i])
    return gcd_
def gcd(a, b):
    a_min, a_max = min(a,b), max(a,b)
    r = 1
    while (r != 0):
        r = a_max % a_min
        a_max, a_min = a_min, r
    return a_max

n, x = map(int, input().split())
x_list = [int(i) for i in input().split()]
x_list.append(x)
x_list = sorted(x_list)
diff_list = [x_list[i+1] - x_list[i] for i in range(len(x_list)-1)]
if n > 1:
    ans = euclid(diff_list)
    print(ans)
else:
    ans = abs(x_list[0] - x_list[1])
    print(ans)

Solution (Python):
import fractions
import sys
from functools import reduce
readline = sys.stdin.readline

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

a = list(map(int, readline().split()))
N = a[0]
X = a[1]
city = list(map(int, readline().split()))

cnt = 0
for i in range(N):
    city[i] -= X
    if city[i] < 0:
        city[i] = 0 - city[i]

print(str(gcd(*city)))

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

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

if X not in li:
    li.append(X)
li=sorted(li)
distance=[]

for i in range(len(li)-1):
    distance.append(li[i+1]-li[i])

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

print(answer)

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


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

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

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

def main():
    ds = list(map(lambda n: abs(X - n), P))
    ans = reduce(lambda a, b: gcd(a, b), ds)
    print(ans)

if __name__ == "__main__":
    main()

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

Solution (Python):



import sys

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

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

difs = []
for i in range(len(x)-1):
    difs.append(x[i + 1] - x[i])
  
min_dif = min(difs)
divisors = sorted(make_divisors(min_dif))[::-1]

for divisor in divisors:
    flag = False
    for dif in difs:
        if dif % divisor != 0:
            flag = True
            break
    if flag == False:
        print(divisor)
        break

Solution (Python):
import fractions
nx=input().split()
N=int(nx[0]);X=int(nx[1])
xs=input().split()
xs=[int(x) for x in xs]
xs.append(X)
xs.sort()
n=xs[0]
xs.remove(n)
t=[]
for i in xs:
    t.append(i-n)
    n=i
count=t[0]
t.remove(count)
for j in t:
    count=fractions.gcd(count,j)
print(str(count))

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):
N,X = (int(x) for x in input().split())

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

d = -1
for x_str in input().split():
    x = int(x_str)
    dx = abs(X-x)
    if d == -1:
        d = dx
        continue
    d = gcd(d, dx)

print(d)

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

n,x=map(int,input().split())
x_lst=list(map(int,input().split()))
x_lst=list(map(lambda a:abs(a-x),x_lst))
print(gcd_list(x_lst))

Solution (Python):
n, lx = map(int, input().split())
x = list(map(lambda x: x-lx, list(map(int, input().split()))))
def gcm(a, b) :
  while(b) :
    a, b = b, a%b
  return a
for i in range(n-1) :
  x[i+1] = gcm(x[i], x[i+1])
print(abs(x[-1]))

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

print(reduce(fractions.gcd, X))

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

n,x = map(int, input().split())
X = [int(i) for i in input().split()]
X = [abs(x-j) for j in X]
ans = reduce(gcd, X)
print(ans)

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

n = min(positions_from_X)

if N==1:
    flg = n
else:
    for d in sorted([i for i in range(1,n+1) if n%i==0], reverse=True):
        flg = d
        for p in positions_from_X:
            if p%d !=0:
                flg=0
                break
        if flg:
            break

print(flg)

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

Solution (Python):
import fractions
n,x=map(int,input().split())
if n==1:
  print(abs(x-int(input())))
  exit()
l=list(map(int,input().split()))
l.append(x)
l.sort()
l2=[]
for i in range(1,n+1):
  l2.append(l[i]-l[i-1])
a=10000000000
for i in range(len(l2)-1):
  b=fractions.gcd(l2[i],l2[i+1])
  if b<a:
    a=b
print(a)

Solution (Python):
import fractions

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

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

print(ans)

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


a=abs(cx-x[0])
b=abs(cx-x[-1])

c=abs(x[0]-x[-1])
d=(min(a,b)+c)
print(d)

"""
def gcd(cx,cy):
    if cy==0:
        return cx
    else:
        return gcd(cy,cx%cy)

d_l=[]
for l in x:
    d_l.append(abs(l-cx))

comp=d_l[0]

    
for i in range(0,len(d_l)):
    comp=gcd(d_l[i],comp)

print(comp)