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):
N, X = map(int,input().split())
x = list(map(int,input().split()))
tmp = []
for i in range(N):
  tmp.append(abs(x[i] - X))

def gcd(m, n):
  while n:
    m, n = n, m%n
  return m
ans = tmp[0]
for t in tmp:
  if(t%ans != 0):
    ans = gcd(ans, t)
print(ans)

Solution (Python):
import fractions


def func(l):
    
    for i in range(len(l) - 1):
        r = fractions.gcd(r, l[i + 1])
    return r


def func2(l):
    if len(l) == 1:
        return l[0]

    r = fractions.gcd(l[0], l[1])
    i = 2
    while i <= len(l) - 1:
        r = fractions.gcd(r, l[i])
        i += 1
    return r


def main():
    n, x = map(int, input().split())
    xl = [int(i) for i in input().split()]
    xl.append(x)
    xl.sort()

    
    
    

    dl = []
    for i in range(len(xl) - 1):
        d = xl[i + 1] - xl[i]
        dl.append(d)

    print(func2(dl))


if __name__ == '__main__':
    main()

Solution (Python):
import fractions


def func(l):
    r = fractions.gcd(l[0], l[1])    
    for i in range(1, len(l) - 1):
        r = fractions.gcd(r, l[i + 1])
    return r


def main():
    n, x = map(int, input().split())
    xl = [int(i) for i in input().split()]
    xl.append(x)
    xl.sort()
    
    if n == 1:
      print(abs(xl[1] - xl[0]))
      return
    
    dl = []
    for i in range(len(xl) - 1):
        d = xl[i + 1] - xl[i]
        dl.append(d)

    print(func(dl))


if __name__ == '__main__':
    main()

Solution (Python):
def gcd(x, y):
  while(y > 0):
    x, y = y, x % y
  return x
n, x = map(int, input().split())
city = list(map(int, input().split()))
dist = []
for i in range(n):
  dist.append(abs(city[i] - x))
g = dist[0]
for i in range(1, n):
  g = gcd(g, dist[i])
print(g)

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

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

subs = []
for i in range(N):
  subs.append(abs(x[i] - X))
ans = subs[0]
for sub in subs:
  if(sub%ans != 0):
    ans = gcd(ans, sub)
print(ans)

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

lst = dif_lst
while True:
    dif_lst = [lst[0]]
    for i in range(len(lst)-1):
        dif = lst[i+1] - lst[i]
        if dif == 0:
            continue
        else:
            dif_lst.append(lst[i+1] - lst[i])
    dif_lst.sort()
    if dif_lst[0] == 1:
        print(1)
        break
    elif len(dif_lst) == 1:
        print(dif_lst[0])
        break
    lst = dif_lst

Solution (Python):
import sys
sys.setrecursionlimit(10**8)

from fractions import gcd

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

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











def gcd_list(data):
    
    
    
    
    
    
    
    
    ret = data[0]
    for d in data[1:]:
        ret = gcd(ret, d)
    return ret

print(gcd_list(X))

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

from fractions import gcd
ans = abs(x - li[0])
for y in li[1:]:
    ans = gcd(ans, abs(x - y))

print(ans)

Solution (Python):
import fractions

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

if len(x) > 1:
  gcd = fractions.gcd(x[0], x[1])
  for i in x:
    gcd = fractions.gcd(gcd, i)
else:
  gcd = x[0]
print(gcd)

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

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

def gcd(x,y):
    if y==0:
        return x
    else:
        return gcd(y,x%y)
if n==1:
    ans=abs(x[0]-x0)
else:
    ans=gcd(abs(x[0]-x0),abs(x[1]-x0))
    for i in range(n):
        ans=gcd(ans,abs(x[i]-x0))
print(ans)

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




x.sort()


xmin = x[0]

'''
div = []
for i in range(int(xmin/2)+1, 0, -1):
	if xmin % i == 0:
		div.append(i)

for d in div:
	for xi in x:
		if xi % d != 0:
			break
	else:
		D = d
		break

print(D)
'''
for d in range(xmin,0,-1):
	for xi in x:
		if xi % d != 0:
			break
	else:
		D = d
		break

print(D)

Solution (Python):



from itertools import chain
from functools import reduce
from collections import OrderedDict, Counter, deque
import operator, fractions
from bisect import *

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

def f():
    X.sort()
    L = len(X)
    if L == 1:
        return abs(X[0] - x)
    
    i = bisect_left(X, x)
    
    d = [t - u for t,u in zip(X[1:], X[:-1])]
    s = None
    if i == 0:
        s = set(d)
        s.add(x[0] - x)
    elif i == len(X):
        s = set(d)
        s.add(x - X[-1])
    else:
        s = set(d[:i - 1])
        s.update(d[i+1:])
        s.update({x - X[i-1], X[i] - x})
    return reduce(fractions.gcd, s)

print(f())

Solution (Python):

def getIntList(): return [int(x) for x in input().split()]
def zeros(n): return [0 for i in range(n)]
def gcd(x, y):
    m = max(x,y)
    n = min(x,y)
    while m%n != 0:
        w = m%n
        m = n
        n = w
    return n
def db(x): 
    global debug
    if debug: print(x)
debug = False
N,X = getIntList()
x = getIntList()
dif = zeros(N)
for i in range(N-1):
    dif[i] = x[i+1] - x[i]
dif[N-1] = x[N-1] - X
db(dif)
cd = dif[N-1]
for i in range(N-1):
    cd = gcd(cd,dif[i])
cd = abs(cd)
print(cd)

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

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

sub_list = []
for i in range(N):
  sub_list.append(abs(x[i] - X))
ans = sub_list[0]
for i in range(N):
  if(sub_list[i]%ans != 0):
    ans = gcd(ans, sub_list[i])
print(ans)

Solution (Python):
from fractions import gcd
N, O = map(int, input().split())
X = list(map(int, input().split()))
X.append(O)
X.sort()
diff = [x-y for x, y in zip(X[1:], X[:-1])]

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

Solution (Python):

from functools import reduce

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


def main():
    na = list(map(int, input().split()))
    N, X = na[0], na[1]
    x = list(map(int, input().split()))

    y = list(map(lambda v: abs(v - X), x))

    a = reduce(gcd, y)

    print(a)


if __name__ == '__main__':
    main()

Solution (Python):
from fractions import gcd

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

ans = None
for i in xi:
    distance = abs(i-x)
    if ans is None:
        ans = distance
    else:
        ans = gcd(ans, distance)
print(ans)

Solution (Python):
import math
import numpy as np
def yakusu(num):
    top = []
    bot = []
    for i in range(int(math.sqrt(num))):
        k = i+1
        if num%k == 0:
            top.append(num//k)
            bot.append(k)
    return top + bot[::-1]

n, X = map(int, input().split())
x = list(map(int, input().split()))
x.append(X)
x.sort()
start = x[0]
x = np.array(x[1:])
x -= start


for ans_pred in yakusu(x[0]):
    if ans_pred == 1:
        break
    flag = True
    for i in x:
        if i % ans_pred != 0:
            flag= False
            break
    if flag:
        break

print(ans_pred)

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

for i, n in enumerate(xi):
    xi[i] = abs(xi[i]-x)
ans = xi[0]
for i in range(len(xi)):
    ans = gcd(ans, xi[i])
print(ans)

Solution (Python):
def main():
    N, X = map(int, input().split())
    dx = [abs(X - x) for x in map(int, input().split())]
    if N == 1:
        ans = dx[0]
    else:
        ans = 10 ** 9
    for i in range(N - 1):
        nm = dx[i]
        dm = dx[i + 1]
        while True:
            mod = nm % dm
            if mod == 0:
                break
            nm = dm
            dm = mod
        ans = min(ans, dm)
    print(ans)


main()

Solution (Python):
def main():
    N, X = map(int, input().split())
    dx = [abs(X - x) for x in map(int, input().split())]
    if N == 1:
        ans = dx[0]
    else:
        ans = 10 ** 9
    for i in range(N - 1):
        nm = max(dx[i], dx[i + 1])
        dm = min(dx[i], dx[i + 1])
        while True:
            mod = nm % dm
            if mod == 0:
                break
            nm = dm
            dm = mod
        ans = min(ans, dm)
    print(ans)


main()

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

for i in range(n):
    D.append(abs(x - A[i]))
    
def gcd(x, y):
    while y != 0:
        x, y = y, x % y
    return x

for i in range(n - 1):
    D[i + 1] = gcd(D[i], D[i + 1])
    
print(D[-1])

Solution (Python):


def main():
    n, x = map(int, input().split())
    xn = list(map(int, input().split()))
    di = [abs(xi - x) for xi in xn]
    res = di[0]
    for i in range(1, n):
        res = gcd(res, di[i])
    print(res)

def gcd(x, y):
    if x < y:
        x, y = y, x  
    while y > 0:
        r = x % y
        x = y
        y = r
    return x

main()

Solution (Python):
import functools

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())
list_x = list(map(int,input().split()))

diff=[None]*n
for i in range(n):
  diff[i] = abs(list_x[i] - x)


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

Solution (Python):
import fractions

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

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

gcd = d[0]
i=1
while True:
    if i>=N:
        break
    gcd = fractions.gcd(gcd,d[i])
    i=i+1 

print(gcd)

Solution (Python):
from fractions import gcd
from functools import reduce
def main(n,x,lst):
    lst.append(x)
    lst.sort()
    ans = [0for i in range(n)]
    for i in range(n):
        ans[i] = lst[i+1]-lst[i]
    return reduce(gcd,ans,0)
n,x = map(int,input().split())
lst = list(map(int,input().split()))
print(main(n,x,lst))

Solution (Python):
from functools import reduce
N, X = [int(a) for a in input().strip().split()]
x = [int(a) for a in input().split()]
y = [a - X for a in x]
y.sort()

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

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

ydiff = []
for i in range(0, len(y)-1):
    if y[i+1] * y[i] < 0:
        ydiff.append(abs(y[i]))
        ydiff.append(abs(y[i+1]))
    else:
        ydiff.append(y[i+1] - y[i])
y = list(set(y)) 

if len(ydiff) == 1:
    ydiff.append(ydiff[0])

print(reduce(gcd, ydiff))

Solution (Python):
import fractions
from functools import reduce

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

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

print(abs(func(x)))

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

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


x=lens[0]
for i in range(1,len(lens)):
    x=GCD(x,lens[i])

print(x)

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

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

    c=max(a,b)
    d=min(a,b)
    while True:
        if c%d==0:
            break
        else:
            temp=c
            c=d
            d=temp%d
    return d

def two_gcd(x):
    if len(x)==2:
        return gcd(x[0],x[1])
    elif len(x)==1:
        return x[0]
    else:
        i=len(x)//2
        return gcd(two_gcd(x[:i]),two_gcd(x[i:]))

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

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

x1 = []

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

Solution (Python):
n,s = (int(i) for i in input().split())
x = list(int(i) for i in input().split())
x = sorted(x)
if n>1:
    dif = []
    for i in range(n-1):
        dif.append(x[i+1]-x[i])

    difs = []
    for i in range(n):
        difs.append(abs(s-x[i]))
    res = min(min(dif),min(difs))
    for i in range(res):
        flag = True
        for j in range(n-1):
            if dif[j]%(res-i)!=0:
                flag = False
                break
        if flag:
            res -= i
            break
                
    print(res)
else:
    print(abs(x[0]-s))

Solution (Python):
from functools import reduce


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.append(X)
x = sorted(x)
y = []
for i in range(len(x)-1):
    y.append(x[i+1]-x[i])
print(reduce(gcd, y))

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

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

Solution (Python):
import fractions
N, X = map(int,input().split())
x = list(map(lambda y: abs(int(y)-X),input().split()))
m = min(x)

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

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

def prim(y):
    p=[]
    while y>1:
        for i in range(2,y+1):
            if y%i==0:
                y//=i
                p.append(i)
                break
    return p
   
ans=1

for i in prim(m):
    if m%i !=0:
        continue
    if set([j%i for j in x]) == {0}:
        ans *= i
        x = [j//i for j in x]
    if set([j%(m//i) for j in x]) == {0}:
        ans *= (m//i)
        x = [j//(m//i) for j in x]

print(ans)

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

Solution (Python):
import fractions
from functools import reduce

S = list(map(int,input().split()))
N = S[0]
X = S[1]
x = list(map(int,input().split()))
x.append(X)
xmin = min(x)
xlist = list(map(lambda y: y-xmin ,x))
xlist.remove(0)

answer = reduce(fractions.gcd, xlist)
print(answer)

Solution (Python):
n, x = map(int, input().split())
A = sorted([int(i) for i in input().split()], reverse=True)
B = [abs(A[0] - x)]

for i in range(n-1):
    B.append(A[i] - A[i+1])
    
def gcd(x, y):
    while y > 0:
        x, y = y, x % y
    return x

for i in range(n-1):
    B[i+1] = gcd(B[i], B[i+1])
    
print(B[-1])

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

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

ans = gcd(cities[1], cities[0])
if len(cities) >= 3:
	for i in range(1, len(cities) - 1):
		ans = gcd(ans, cities[i+1])

print(ans)

Solution (Python):
a, b = map(int, input().split())


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

A = list(input().split())
B = []
ans = abs(int(A[0])-b)
for i in A:
    aa = abs(int(i) - b)
    ans = gcd(ans, aa)

print(ans)

Solution (Python):
is_prime = [True] * (10**5)
is_prime[0] = False
is_prime[1] = False
primes = []
for i in range(2, len(is_prime)):
    if is_prime[i]:
        primes.append(i)
        for j in range(i*2, len(is_prime), i):
            is_prime[j] = False

def do_prime_fact(x, ps):
    res = {}
    for prime in ps:
        while x % prime == 0:
            x /= prime
            if not prime in res:
                res[prime] = 0
            res[prime] += 1
    if x > 1: 
        res[x] = 1
    return res

def solve(x):
    y = do_prime_fact(x[1] - x[0], primes)
    ps = y.keys()
    ys = [do_prime_fact(x[i+1] - x[i], ps) for i in range(len(x)-1)]
    d = 1
    for k in ps:
        ok = True
        while ok:
            for y in ys:
                if (not k in y) or (y[k] == 0):
                    ok = False
                    break
            if ok:
                for y in ys:
                    y[k] -= 1
                d *= k
    return d

n, x0 = map(int, raw_input().split())
x = map(int, raw_input().split())
x = list(sorted(set([x0] + x)))
print(solve(x))

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

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


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

print(ans)

Solution (Python):
N_X = list(map(int,input().split()))
data = list(map(int,input().split()))
k = 0

for i in data:
    data[k] = abs(i - N_X[1])
    k += 1

m = min(data)
a = []
for i in range(1,m+1):
    if m % i == 0:
        a.append(i)
        a.append(int(m/i))
    if i**2 > m:
        break

a.sort()
a.reverse()

for i in a:
    if all(c%i == 0 for c in data):
        print(i)
        break

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

for i in range(n):
    dist = abs(x - A[i])
    D.append(dist)
    
def gcd(x, y):
    while y != 0:
        x, y = y, x%y
    return x

for i in range(n - 1):
    D[i + 1] = gcd(D[i], D[i + 1])
    
print(D[-1])

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


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

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

print(ans)

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


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

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

main()

Solution (Python):



def main():
    from fractions import gcd

    n, large_x = map(int, input().split())
    x = sorted(list(map(int, input().split())) + [large_x])
    ans = float('inf')

    if len(x) == 2:
        print(x[1] - x[0])
        exit()

    for k in range(n - 1):
        ans = min(ans, gcd(x[k + 2] - x[k + 1], x[k + 1] - x[k]))

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
try:
    from math import gcd 
except:
    from fractions import gcd 

def solve(X, xs):
    xs = list(xs) + [X]
    xs.sort()
    zs = [x - xs[0] for x in xs]

    for z in zs:
        if z == 0:
            D = z
        else:
            D = gcd(D, z)
    return D

def test():
    print(solve(13, [16 + 3 * 102485 * i for i in range(10**5)]))

if __name__=='__main__':
    N, X = map(int, input().split())
    xs = map(int, input().split())

    print(solve(X, xs))

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


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

xs.append(X)
xs = sorted(xs)

d = [y-x for x,y in zip(xs[:-1], xs[1:])]

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

Solution (Python):
import math
from functools import reduce
N,X = input().split()

x_list = input().split()

x_list_X  = [abs(int(i)-int(X)) for i in x_list]


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

print(reduce(gcd, x_list_X))

Solution (Python):
import fractions
from functools import reduce

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

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

if n == 1:
  print(abs(x-a[0]))
  exit()
  
b = []
for i in range(1,n):
  b.append(a[i]-a[i-1])
b.append(abs(a[0]-x))
print(gcd_list(b))

Solution (Python):
import numpy as np

N, X = list(map(int, input().split()))
x = np.array(list(map(int, input().split())))
x = np.abs(X - x)

for i in range(N-1):
    a, b = x[i:i+2]
    while b > 0:
        a, b = b, a % b
    x[i+1] = a

print(x[-1])

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

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

print(x[-1])

Solution (Python):
from functools import reduce
N, X = map(int, input().split())
loc = list(map(int, input().split()))


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


print(reduce(gcd, [abs(l-X) for l in loc]))

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


def main():
    n, y = map(int, input().split())
    xs = list(map(int, input().split()))
    res = abs(y - xs[0])
    for x in xs[1:]:
        res = gcd(res, abs(y - x))
    print(res)


if __name__ == '__main__':
    main()

Solution (Python):
def gcd(a,b):
    if a==b:
        return b
    elif b==1:
        return 1
    elif a%b == 0:
        return b
    else:
        return gcd(b,a%b)
    
N,X = map(int,input().split())
x = list(map(int,input().split()))

dist = []

for i in range(N):
    dist.append(abs(X-x[i]))
dist.sort
if len(dist) == 1:
    temp = dist[0]
else:
    temp = gcd(dist[1],dist[0])
for i in range(2,N):
    temp = gcd(dist[i],temp)
    
print(temp)

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

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

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

Solution (Python):
def gcd(A, B):
    while B > 0:
        A, B = B, A % B
    return A

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

li = [abs(int(i) - x) for i in input().split()]
ans = li[0]
for i in range(n):
    ans = gcd(ans, li[i])
print(ans)

Solution (Python):
import fractions
from functools import reduce

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


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

clist = [X]
diff = []

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

clist.sort(reverse = False)

for s in range(1, N+1):
    diff.append(clist[s] - clist[s-1])

print(gcd_list(diff))

Solution (Python):
import fractions as math

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

x_0 = [x_- x_min for x_ in x]

gcd = x_0[0]
for x_0_ in x_0:
    gcd = math.gcd(gcd,x_0_)

print(gcd)

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

ans = distance[0]


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

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

print(ans)

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

for i in range(N):
	x[i] -= X
if N == 1:
	print(abs(x[0]))
else:
	a = x[0]
	for i in range(N - 1):
		b = x[i + 1]
		a, b = sorted([a, b])
		while True:
			if b % a == 0:
				break
			else:
				a, b = b % a, a
	print(abs(a))

Solution (Python):
def gcd(A,B):
    while B != 0:
        A,B = B,A%B
    return A
n,x = map(int,input().split())
li = [abs(int(i)-x) for i in input().split()]
ans = li[0]
for i in range(n):
    ans = gcd(ans,li[i])

print(ans)

Solution (Python):
import fractions
import functools
N,X = list(map(int, input().split()))
x = list(map(int, input().split()))
diff_list = []

for i in range(N):
    diff_list.append(max(x[i], X) - min(x[i], X))
gcd = functools.reduce(fractions.gcd, diff_list)
print(gcd)

Solution (Python):
n, x = map(int, input().split())
city = list(map(int, input().split()))
D = []

for i in range(n):
    dis = abs(x - city[i])
    D.append(dis)
    
def gdc(x, y):
    if x%y == 0:
        return y
    x, y = y, x%y
    return gdc(x, y)

for i in range(n-1):
    D[i + 1] = gdc(D[i], D[i + 1])

print(D[-1])

Solution (Python):
import numpy as np
import math
import itertools



def factorize(M):
    P = []
    F = []
    for m in range(2, int(math.sqrt(M))+1):
        n = 0
        while M % m == 0:
            M/= m
            n +=1
        if n != 0:
            P.append(m)
            F.append(n)
    if M != 1:
        P.append(M)
        F.append(1)
    return P,F

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

dN = np.abs(np.array(xN) - X)
P,F = factorize(np.min(dN))

M = []
for F_ in itertools.product(*list(map(lambda f:range(f+1), F))):
    m = 1
    for p,f in zip(P,F_):
        m *= int(pow(p,f))
    if np.all(np.mod(dN, m) == 0):
        M.append(m)

print(max(M))

Solution (Python):

def pri(n):
  i = 2
  X = {}
  while i * i <= n:
    while n % i == 0:
      n //= i
      if i in X:
        X[i] = X[i] + 1
      else:
        X[i] = 1
    i += 1
  if n > 1:
    X[n] = 1
  return X



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

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

x.sort()

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

d.sort()

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

m = d[0]
P = pri(d[0])
for i in range(1,len(d)):
  if d[i] % m != 0:
    t = pri(d[i])
    m = 1
    for j in list(P):
      if j in t:
        P[j] = min(P[j], t[j])
        m *= j ** P[j]
      else:
        del P[j]
print(m)

Solution (Python):

def pri(n):
  i = 2
  X = {}
  while i * i <= n:
    while n % i == 0:
      n /= i
      if i in X:
        X[i] = X[i] + 1
      else:
        X[i] = 1
    i += 1
  if n > 1:
    X[n] = 1
  return X



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

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

x.sort()

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

d.sort()

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

m = d[0]
P = pri(d[0])

for i in range(1,len(d)):
  if d[i] % m != 0:
    t = pri(d[i])
    m = 1
    for j in list(P):
      if j in t:
        P[j] = min(P[j], t[j])
        m *= j ** P[j]
      else:
        del P[j]

print(int(m))

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

Solution (Python):
from functools import reduce

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

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

delta = [abs(X-i) for i in x]
print(reduce(gcd, delta))

Solution (Python):
n, x = map(int, input().split())
X = list(map(int, input().split()))
X.sort(reverse=True)
D = []

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

def gcd(i, j):
    while j != 0:
        i, j = j, i % j
    return i

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

print(D[-1])

Solution (Python):


from functools import reduce

def gcda(x, y):
    while y:
        x, y = y, x % y
    return x

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


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


if __name__ == "__main__":
    n, x = read_int_n()
    y = read_int_n()
    y.append(x)

    y.sort()
    w = [y[i] - y[i-1] for i in range(1, len(y))]
    print(gcd(*w))

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

Solution (Python):
def get_greatest_common_divisor(n1, n2) :
    
    if (n2 == 0) :
        return n1
    return get_greatest_common_divisor(n2, n1 % n2)


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

n2 = abs(locations[0] - X)
for i in range(len(locations),1,-1) :
    n1 = abs(locations[i-1] - X)
    n2 = get_greatest_common_divisor(n1,n2)

print(n2)

Solution (Python):
from fractions import gcd


def gcd_array(a):
    gg = gcd(a[0],a[1])

    for i in range(2, len(a)):
        gg = gcd(gg, a[i])
    return gg


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

b = [abs(int(k) - x) for k in input().split()]

if len(b) == 1:
    print(b[0])
else:
    print(gcd_array(b))

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

def gcd(n,m):
	if n%m==0:
		return m;
	else:
		return gcd(m,n%m);

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

print(ans)

Solution (Python):
import fractions
from functools import reduce

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

N, X = [int(x) for x in input().split()]
x_list = input().split()
x_list = list(map(int, x_list))
x_list = list(map(lambda x: abs(X - x), x_list))
print(gcd(*x_list))

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

N, X = map(int,input().split()) 
nums=list(map(int,input().split()))
nums=list(map(lambda i: abs(i - X),nums))
 
D = reduce(gcd, nums)
print(D)

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

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

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

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

Solution (Python):
import math

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

A = [x - S for x in X]

def lcd(a,b):
    a = abs(a)
    b = abs(b)
    a,b = min(a,b), max(a,b)
    if a == 0:
        return b
    return lcd(b%a, a)


ret = A[0]
for a in A:
    ret = lcd(ret, a)

print(ret)

Solution (Python):
import math

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

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

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

print(ans)