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

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

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

if N==1:
    print(abs(X-x[0]))
    sys.exit()



x.append(X)
x.sort()

ANS=gcd(x[1]-x[0],x[2]-x[1])

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

print(ANS)

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

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

x = list(map(int, input().split()))
ans = float("inf")
for i in range(0,n):
    x[i] = abs(x[i]-X)
    if i >= 1:
        x[i] = gcd(x[i],x[i-1])
    ans = min(ans,x[i])
print(ans)

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)


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

    A = sorted(A)

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

    g = 1
    g = gcd(A[1] - A[0], A[2] - A[1])
    for i in range(1, len(A)):
        g = gcd(g, A[i] - A[i - 1])
            
    print(g)


if __name__ == "__main__":
    main()

Solution (Python):
N, X = map(int, input().split())
xs = list(map(int, input().split()))
xs.append(X)
xs.sort()
xs = [_ - xs[0] for _ in xs]
diffs = [xs[i]-xs[i-1] for i in range(1, len(xs))]
def gcd(a, b):
    if(a<b): return gcd(b, a)
    if a % b == 0:
      return b
    else:
      r = a % b
      return gcd(b, r)

prev = diffs[0]
for cur in diffs[1:]:
    prev = gcd(prev, cur)
print(prev)

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_list(numbers):
    return reduce(gcd, numbers)

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

ans = gcd_list([abs(c - X) for c in cities])

print(ans)

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


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

y = [abs(xi - X) for xi in x]
r = y[0]

for i in range(N-1):
    if y[i+1] != 0:
        r = gcd(r, y[i+1])

print(r)

Solution (Python):
def gcd( a,b ):

	if b == 0:
		return a;
	else:

		return gcd( b, a%b);


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

arr = list(map(int,input().split()))
arr.sort()

minn =0;
temp =0;

if n > 1:

	flag=0;
	
	for i in range(n):

		if i < n-1:
			temp = arr[i+1]-arr[i];
			minn = gcd(temp,minn);

	if minn==0:

		print( abs(x-arr[0]));

	for i in range(n):

		if x == arr[i]:
			flag=1;
			break;
		else:

			diff = abs(x-arr[i])
			if minn !=0 and diff%minn==0:
				flag=1;
				break;
	if flag==1:
		print(minn)
	else:

		maxx = 0;

		for i in range(n):

			diff = abs(x-arr[i]);
			temp = gcd(minn,diff);

			if temp > maxx:
				maxx = temp;
		print (maxx);
else:

	print (abs(x-arr[0]));

Solution (Python):
from fractions import gcd


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

x.append(X)
x.sort()

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

print(ans)

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

Solution (Python):
def gratest_common_factor(x,y):
    while y:
        amari = x % y

        x = y
        y = amari
    return x


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

l2 = list(map(lambda t: t-x, l))

for i in range(n-1):
    l2[1] = gratest_common_factor(l2[0],l2[1])
    del l2[0]

print(abs(l2[0]))

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

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

x.append(X)
sx = sorted(x)
dx = [j - i for i, j in zip(sx[:-1], sx[1:])]

mdx = reduce(gcd, dx)

print(mdx)

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

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

d = sorted(list(set(d)))

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

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

ans = d[0]
for i in range(1, len(d)):
    ans = calc_gcd(ans, d[i])

print(ans)

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

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

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

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

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

print(D)

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

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

xs[0] -= X
g = xs[0]
import math
for i in range(1,N):
    xs[i] -= X
    g = gcd(g,xs[i])
print(abs(g))

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


n, x = [int(_) for _ in input().split()]
x_list = [int(_) - x for _ in input().split()]

x_sorted = sorted(x_list)

x_gaps = [x_sorted[i+1] - x_sorted[i] for i in range(0, n-1)]

if len(x_gaps) == 0:
    print(abs(x_sorted[0]))
elif len(x_gaps) == 1:
    print(gcd(abs(x_list[0]), abs(x_list[1])))
else:
    result = x_sorted[0]
    for i in range(0, n-2):
        if i == 0:
            result = gcd(x_gaps[0], x_gaps[1])
        else:
            result = gcd(result, x_gaps[i+1])
    print(result)

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

x.append(X)
x.sort()
diff = list(set([i-j for i, j in zip(x[1:], x[:-1])]))

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

comm = diff[0]
for i in diff:
  while i > 0:
    comm, i = i, comm%i

print(comm)

Solution (Python):
inputs = raw_input().replace("\n", "").split(" ")
N, X = map(int, inputs)
inputs = raw_input().replace("\n", "").split(" ")

xs = [abs(int(input_) - X) for input_ in inputs]

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

if N >= 2:
    for i in xrange(1, N):
        if i >= 2:
            y = gcd(y, xs[i])
        else: 
            y = gcd(xs[0], xs[1])
else:
    y = xs[0]

print y

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



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


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


ans = 0
for i, x in enumerate(x_list):

    diff = abs(x - X)

    

    if i == 0:
        ans = diff
    else:
        larger = min(ans, diff)
        smaller = max(ans, diff)

        if smaller % larger == 0:
            ans = larger
        else:
            ans = gcd(ans, diff)

print(ans)

Solution (Python):
def lcm(a, b):
    while a % b != 0:
        a, b = b, a % b
    return b


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

xs.append(X)
xs.sort()

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

res = min(D)
for d in D:
    if res == 1:
        break
    
    if d % res == 0:
        continue

    res = lcm(d, res)
    
print(res)

Solution (Python):
from fractions import gcd

N, X = map(int, input().split())
xs = list(map(int, input().split()))
xs.append(X)
xs = sorted(xs)
m = 999999999999999999
diffs = []
for idx,e in enumerate(xs):
  if idx==0:
    continue
  diff = abs(e - xs[idx-1])
  diffs.append(diff)
diffs = sorted(diffs)
for idx,dif in enumerate(diffs):
  if idx == 0:
    continue
  if gcd(diffs[idx], diffs[idx-1]) < m:
    m = gcd(diffs[idx], diffs[idx-1])
if len(diffs) == 1:
  m = diffs[0]
print(m)

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

def minus_x(t):
    return abs(int(t) - x)
cities = sorted(list(map(minus_x,input().split(" "))))

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

if n == 1:
    ans = cities[0]
else:
    ans = gcd(cities[0],cities[1])
    for i in range(2,n-1):
        ans = gcd(cities[i],ans)

print(ans)

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

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


for i in range(N):
  D.append(abs(A[i]-X))

ans=min(D)
for i in range(len(D)):
  ans=gcd(ans,D[i])
  
print(ans)

Solution (Python):




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

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

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

a = []

for i in range(n):
    tmp = abs(w[i]-x)
    a.append(tmp)
    
ans = a[0]

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

Solution (Python):
import sys

ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: [int(x) for x in ns().split()]
nall = lambda: [int(x) for x in sys.stdin.readlines()]
sall = lambda: sys.stdin.readlines() 


from fractions import gcd


def main():
    n, xx = na()
    xs = na()
    xs = [abs(x - xx) for x in xs]

    if len(xs) == 1:
        print(xs[0])
        return
    
    m = float('inf')
    v = xs[0]
    for x in xs[1:]:
        m = min(m, gcd(x, v))

    print(m)

main()

Solution (Python):
def gcd(a, b):
    while b > 0:
        a, b = b, a%b
    return a
  
def gcd_list(y):
    if len(y)==1:
        return y[0]
    if len(y)==2:
        return gcd(y[0],y[1])
    else:
        return gcd(gcd_list(y[:len(y)/2]),gcd_list(y[len(y)/2:]))

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

x = map(int,raw_input().split())

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

print gcd_list(x)

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

x = sorted(x+[X])
x_diff = [x[i+1]-x[i] for i in range(n)]

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

Solution (Python):


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

def maximum_d(cities, x):
    distances = set()
    for city in cities:
        distances.add(abs(x - city))
    if 0 in distances:
        distances.remove(0)

    result = None
    for distance in distances:
        if result:
            result = gcd(result, distance)
        else:
            result = distance
    return result

def main():
    n, x = [int(s) for s in input().split()]
    cities = [int(s) for s in input().split()]

    print(maximum_d(cities, x))

main()

Solution (Python):
import fractions
from functools import reduce
 
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
 
ip = input().split()
st = int(ip[1])
 
li = []
 
ip2 = input().split()
for i in ip2:
    li.append(abs(int(i) - st))
 
print(gcd_list(li))

Solution (Python):
import fractions

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

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

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

distance=[0]*N

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

distance.sort()

D=distance[0]
for i in range(N):
  D=min(D,fractions.gcd(D,distance[i]))
print(D)

Solution (Python):
from functools import reduce

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

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

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

print(gcd_multi(*dif_list))

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

print(ans)

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

if N==1:
	print abs(A[0]-X)
	quit()

for i,x in enumerate(A):
	t=abs(x-X)
	if i==0:  D=t
	else:
		D=fractions.gcd(D,t)

print D

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


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

ans = diff[0]
for d in diff[1:]:
    ans = lcm(ans, d)
print(ans)

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


def euclid(a,b):
    big = max(a,b)
    small = min(a,b)
    
    r = big % small
    while(r != 0):
        big = small
        small = r
        r = big % small

    return small


haba = x[0] - X

for i in range(1,N):
    haba = euclid(haba,x[i]-X)
    if haba == 1:
        break

print(abs(haba))

Solution (Python):
from functools import reduce

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

xs = {abs(y-x) for y in xs}

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

print(reduce(gcd, xs))

Solution (Python):
n,x = map(int,input().split())
xs = [abs(int(k)-x) for k in input().split()]
xs.sort()
d = xs[0]
for x in xs:
    y =d
    while y!=0:
        x,y = y,x%y        
    d=x
print(d)

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

def devidable(numbers,i):
    for number in numbers:
        if number%i: return False
    return True

def gcd(numbers):
    i=min(numbers)
    while True:
        if devidable(numbers,i): return i
        else: i-=1

x.append(X)
x.sort()
y=[]

for i in range(len(x)-1):
    y.append(x[i+1]-x[i])
    
print(gcd(y))

Solution (Python):




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


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

    a.append(x)
    a.sort()

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

    print(g)


if __name__ == '__main__':
    main()

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


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

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

dist_list = [abs(X - e) for e in x]

ans = dist_list[0]
for e in dist_list:
    ans = gcd(ans, e)


print(ans)

Solution (Python):
def gr(x,y):
    while y:
        amari = x % y
        x = y
        y = amari
    return x
n,x = map(int,input().split())
lis = list(map(int,input().split()))
li = []
for i in range(n):
  if abs(lis[i]-x) != 0:
    li.append(abs(lis[i]-x))
li.sort()
if len(li) == 1:
  print(abs(li[0]))
  exit()
ans = abs(li[0]-li[1])

for i in range(len(li)-1):
  ans = gr(ans,abs(li[i+1]))
print(ans)

Solution (Python):
n, x0 = [int(_) for _ in input().split(' ')]
x = [abs(int(_) - x0) for _ in input().split(' ')]

def gcm(p, q):
    if p % q == 0:
        return abs(q)
    else:
        return gcm(q, p % q)

if n == 1:
    print(x[0])
else:
    answer = x[0]
    for i in range(n - 1):
        answer = gcm(answer, x[i + 1])
    print(answer)

Solution (Python):
import fractions
import functools

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

ans = functools.reduce(fractions.gcd, map(lambda y: abs(y - x), xs))
print(ans)

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

Solution (Python):
import fractions
from functools import reduce
n, k = map(int, input().split())
distlist = [abs(a-k) for a in list(map(int, input().split()))]

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

max_d = gcd_list(distlist)
print(max_d)

Solution (Python):
'''input
2 1
555 556
'''
from fractions import gcd
n,x = map(int,raw_input().split())
arr = map(int,raw_input().split())
arr.append(x)
arr.sort()
diff = []
for i in range(1,n+1):
	diff.append(arr[i]-arr[i-1])
gc = diff[0]
for i in range(1,len(diff)):
	gc = gcd(gc,diff[i])
print gc

Solution (Python):
def main():
    """
    1 <= N  <= 10^5
    1 <= X  <= 10^9
    1 <= xi <= 10^9
    xi != xj
    xi != X
    """
    N, X = map(int, input().split())
    *xs, = map(int, input().split())

    ans = f(N, X, xs)
    print(ans)


def f(N, X, xs):
    """
    直線上に N 個の都市
    i 番目の都市は座標 xi

    あなたの目的は、これら全ての都市を 1度以上訪れること
    あなたは、はじめに正整数 Dを設定
    その後、あなたは座標 Xから出発し、以下の移動 1、移動 2を好きなだけ行う

        移動 1: 座標 yから座標 y+Dに移動する
        移動 2: 座標 yから座標 y−Dに移動する

    全ての都市を 1 度以上訪れることのできる Dの最大値を求めよ
    ここで、都市を訪れるとは、その都市のある座標に移動すること


    D=1, OK
    """
    ds = [abs(X - x) for x in xs]
    ans = ds[0]
    from fractions import gcd

    for d in ds:
        ans = gcd(d, ans)

    return ans


if __name__ == '__main__':
    main()

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

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

b = []
for i in range(n):
    b.append(abs(a[i]-x))

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

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

Solution (Python):
import fractions

n, k = list(map(int, input().split()))
xs = list(map(int, input().split()))

ans = k - xs[0]

for x in xs:
    if k == x:
        continue
    ans = fractions.gcd(ans, abs(k - x))
    

print(ans)

Solution (Python):
N, X = list(map(int, input().split()))
pos = list(map(int, input().split()))
dis = []

for p in pos:
	dis.append(abs(p - X))

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

dis.sort()
ans = dis[0]
for d in dis:
	ans = gcd(d, ans)
print(ans)

Solution (Python):
import functools
import fractions
N,X=map(int,input().split())
x=list(map(int,input().split()))
def minus(n):
  return n-X
x=list(map(minus, x)) 


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

Solution (Python):
import platform
ver = platform.python_version_tuple()
if int(ver[1]) < 5:
    from fractions import gcd
else:
    from math import gcd

from functools import reduce
from sys import stdin, stdout

input = lambda: stdin.readline()


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

    city = [abs(i - X) for i in Xn]
    ans = reduce(gcd, city)
    print(ans)

main()

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

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

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

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


d = x[0]

for i in x:
	d = gcd(d,i)
print(d)

Solution (Python):




import copy
import math
import fractions
from functools import reduce

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

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

def main(n, start, x):
    pos = copy.deepcopy(x)
    pos.append(start)
    sp = sorted(pos)
    
    sabun = [ (sp[i+1] - sp[i]) for i in range(n)]
    
    print(gcd_list(sabun))
        
if __name__ == '__main__':
    try:
        n, start  = list(map(int, input().strip().split(' ')))
        x = list(map(int, input().strip().split(' ')))
        main(n, start, x)
    except EOFError:
        pass

Solution (Python):
import fractions
from functools import reduce

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

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

print(gcd_list(pos))

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

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

N, X = [int(v) for v in input().split()]
x = [abs(int(v) - X) for v in input().split()]
x.sort()
d = gcd_list(x)
print(d)

Solution (Python):
import fractions
from functools import reduce

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

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

z = []
for i in y:
    z.append(abs(i-x))

print(gcd_list(z))

Solution (Python):
import fractions

n, x = map(int, input().split())
array = [int(x) for x in input().split()]
tmp = abs(array[0]-x)
for i in array:
    tmp = fractions.gcd(tmp, abs(i-x))
print(tmp)

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

Solution (Python):



from fractions import gcd
from functools import reduce

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

N, X = [int(elem) for elem in input().split(' ')]
x_list = [int(elem) for elem in input().split(' ')]
assert len(x_list) == N

difference_list = [abs(X - x) for x in x_list if X - x != 0]
max_gcd = gcd_list(difference_list)
print(max_gcd)

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

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

N, S = map(int,input().split())
x = list(map(int,input().split()))
x.append(S)
x = sorted(x)
t = x[1]-x[0]

for k in range(N):
    t = gcd(t,x[k+1]-x[k])

print(t)

Solution (Python):
import fractions, math
n,x=map(int, input().split())
a=list(map(int, input().split()))
mina=min(a+[x])
a=[i-mina for i in a]+[x-mina]
f=max(a)
for i in a:
    if i!=0:
        f=fractions.gcd(f,i)
print(f)

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

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

ans = 0
for x in xs:
    d = abs(x - X)
    if ans == 0:
        ans = d
    else:
        ans = GCD(ans, d)

print(ans)

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

from collections import Counter

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

A0 = A[0]
ans = []
ans2 = []
for i in range(1,int(abs(A0)**.5)+1):
    if A0%i==0 and i not in ans:
        ans.append(i)

ans2 = ans.copy()
for a in ans:
    if abs(A0//a) not in ans:
        ans2.append(abs(A0//a))

Ans = 1
for a in ans2:
    for i in range(N):
        if A[i]%a==0:
            continue
        else:
            break
    else:
        Ans = max(Ans,a)

print(Ans)

Solution (Python):
def GCD(x,y):
    if x < 0:
        x = -x
    if y < 0:
        y = -y
    
    if x <= y:
        tmp = x
        x = y
        y = tmp
    r = x % y
    while r != 0:
        x = y
        y = r
        r = x % y
    return y
n,x = map(int,input().split())
xl = list(map(int,input().split()))
G = x-xl[0]
for i in range(n):
    G = GCD(G,x-xl[i])
print(G)

Solution (Python):
import fractions
from functools import reduce

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

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

dif=[]

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

print(gcd_list(dif))

Solution (Python):
import math  
  

def printDivisors(n,arr) : 
      
    
    i = 1
    while i <= math.sqrt(n): 
          
        if (n % i == 0) : 
              
            
            if (n // i == i) : 
                arr.append(i)
            else:
                arr.append(i)
                arr.append(n//i) 
        i = i + 1

n,k=map(int,input().split())
arr=list(map(int,input().split()))
for i in range(n):
    arr[i]=abs(arr[i]-k)
arrx=[]
printDivisors(min(arr),arrx)
arrx.sort(reverse=True)
for i in range(len(arrx)):
    flag=0
    for j in range(len(arr)):
        if(arr[j]%arrx[i]!=0):
            flag=1
            break
    if(flag==0):
        print(arrx[i])
        exit(0)

Solution (Python):
import sys

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

def abs(a):
    if a<0:
        return -a
    else:
        return a

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

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

if N==1:
    print(abs(X-x[0]))
    sys.exit()

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

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

print(abs(ans))

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


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

ret = a[0]

for i in range(1, n):
    ret = gcd(ret, a[i])
print(ret)

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_list(numbers):
    return reduce(gcd, numbers)
na = lambda: list(map(int, input().split()))
n, X = na()
x = na()
x.append(X)
x.sort()
l = []
for i in range(len(x)-1):
    l.append(x[i+1]-x[i])
print(gcd_list(l))

Solution (Python):
from fractions import gcd

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

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

B = []
for i in range(len(A)-1):
    B.append(A[i+1]-A[i])

G = B[0]
if G>1:
    for b in B[1:]:
        G = gcd(G,b)
        if G==1:break
            
print(G)

Solution (Python):
N, X = map(int, input().split())
x = list(map(int, input().split()))
y = [i-X if i-X >= 0 else X-i for i in x]


def gcp(a,b):
    if b == 0:
        return a
    else:
        return gcp(b, a%b)
koyaku = y[0]
for i in range(1, N):
    koyaku = gcp(koyaku,y[i])
print(koyaku)

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


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


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


print(a)

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

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

yli = list(map(lambda a:abs(a-x),xli))

def GCD(a, b):

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

import functools
print(functools.reduce(GCD,yli))

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

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

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

print(ans)

Solution (Python):
import fractions

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

if n == 1:
    print(abs(x[0]-start))
    exit()
dist = [0 for i in range(n)]
for i in range(n):
    dist[i] = abs(start-x[i])
max_div = 1000000000
for i in range(1, n):
    max_div = min(max_div, fractions.gcd(dist[i-1], dist[i]))
print(max_div)

Solution (Python):
from fractions import gcd

n, s = map(int, raw_input().split())
a = map(int, raw_input().split())

g = 0
for x in a:
	g = gcd(g, abs(s - x))

print g

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


N, X = map(int, input().split())
l = list(map(int, input().split()))
res = -1

for i in range(N):
    d = abs(l[i] - X)
    
    if res == -1:
        res = d
    else:
        res = gcd(res, d)

print(res)

Solution (Python):
from functools import reduce
memo = {}
def gcd(a, b):
  x, y = a, b = (a, b) if a >= b else (b, a)
  if (a, b) in memo:
    return memo[(a, b)]
  while b > 0:
    a, b = b, a % b
  memo[(x, y)] = a
  return a

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

xs.append(X)
m = min(xs)
arr = [x - m for x in xs]
print(reduce(gcd, arr))

Solution (Python):
N,X=map(int,input().split())
x=sorted(map(lambda x:int(x)-X if int(x)-X>0 else -(int(x)-X),input().split()))
for i in range(x[0]+1)[::-1]:
    if x[0]%i:continue
    if sum(map(lambda x:x%i,x))==0:
        print(i)
        break

Solution (Python):


import fractions

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

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

print(abs(ans))

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

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

print(gcd_list(d))

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





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

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

d = np.zeros(N, dtype=int)
for n in range(N):
    d[n] = x[n] - X

ret = abs(reduce(gcd, d))


print(ret)

Solution (Python):


INF = float('inf')


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


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


N, S = inpl()
X = inpl()
X = [abs(X[i] - S) for i in range(N)]

if len(X) == 1:
    ans = X[0]
else:
    X.sort()
    ans = gcd(X[0], X[1])
    for i in range(2, N):
        ans = gcd(ans, X[i])

print(ans)

Solution (Python):
def c_skip(N, X, Pos):
    from fractions import gcd
    diff = [abs(X - x) for x in Pos]
    ans = diff[0]
    for x in diff[1:]:
        ans = gcd(ans, x)
    return ans

N, X = [int(i) for i in input().split()]
Pos = [int(i) for i in input().split()]
print(c_skip(N, X, Pos))

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

a = list(map(int, input().split()))
a.append(x)
r = 0

def g(k, l):
    if l>k:
        k, l = l, k
    m = k%l
    while m!= 0:
        k = l
        l = m
        m = k%l
    return l
        

for i in range(n):
    b = abs(a[i+1]-a[i])
    if i == 0:
        r = b
    else:
        r = g(r, b)
    
print(r)

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

n,m=map(int, input().split(" "))

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

arr=[abs(i-m) for i in X]

min=arr[0]
for i in range(len(arr)):
    min=gcd(min,arr[i])

print(min)

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

n, x = [int(i) for i in input().split()]
xa = [int(i) for i in input().split()]
ans = abs(x - xa[0])

for i in range(n):
    num = abs(x - xa[i])
    ans = gcd(num, ans)
    
print(ans)

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