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()))
x.append(X) 
x.sort()

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

init=x[0]
x=[i-init for i in x]
d=x[1]
for i in range(N-1):   
    if d==0:
        d=x[i+2]
    else:
        d=gcd(d,x[i+2])
print(d)

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

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

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

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

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


B = [abs(x - X) for x in A]

d = reduce(gcd, B)
print(d)

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

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

answer = 0
for x in A:
  answer = gcd(answer, x)
print(answer)

Solution (Python):
from fractions import gcd

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

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

def gcd_list(lst):
    if len(lst) <= 1:
        return lst[0]
    ans = gcd(lst[0], lst[1])
    for e in lst:
        ans = gcd(ans, e)
    return ans

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

Solution (Python):
N, X = map(int, input().split())
X_list = list(map(int, input().split()))
X_list.append(X)
X_list.sort()
kyori_list = []
for i, x in enumerate(X_list):
    if i == len(X_list) - 1:
        break
    kyori_list.append(X_list[i + 1] - x)

import fractions
from functools import reduce


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


print(gcd_list(*kyori_list))

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

from fractions import gcd

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

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

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

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

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


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


distance_cap = list(map(lambda c: abs(x-c), capitals))
answer = gcd_list(distance_cap)


print(answer)

Solution (Python):
from fractions import gcd
from functools import reduce
def gcds(*numbers):
    return reduce(gcd, numbers)

def resolve():
    (N, X) = list(map(int, input().split(" ")))
    Xs = list(map(int, input().split(" ")))
    Xs.append(X)
    Xs.sort()
    diffs = [Xs[i+1]-Xs[i] for i in range(len(Xs)-1)]
    print(gcds(*diffs))


if '__main__' == __name__:
    resolve()

Solution (Python):
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.append(X)
x.sort()

D = []
for n in range(N):
    D.append(x[n+1]-x[n])
    
ans = 0
for d in D:
    ans = gcd(ans,d)
        
print(ans)

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

from fractions import gcd
from functools import reduce

def gdc_list(lis):
    return reduce(gcd,lis)

print(gdc_list(ls))

Solution (Python):
import math
import fractions


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

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

x_mi = []
x_pl = []

for i in x:

    if i-X < 0:
        x_mi.append(X - i)

    else:
        x_pl.append(i - X)

now_gcd = -1

for i in range(len(x_mi)):

    if now_gcd < 0:
        now_gcd = x_mi[i]

    else:
        now_gcd = fractions.gcd(now_gcd , x_mi[i])

for i in range(len(x_pl)):

    if now_gcd < 0:
        now_gcd = x_pl[i]

    else:
        now_gcd = fractions.gcd(now_gcd , x_pl[i])

print (now_gcd)

Solution (Python):

import time
import re
import math

def main():
    n,start=map(int,input().split())
    X=list(map(int,input().split()))
    now=abs(X[0]-start)
    for xi in range(1,n):
        now=GCD(now,abs(X[xi]-start))
    print(now)
def GCD(a,b):
    if a%b==0:
        return b
    else:
        return GCD(b,a%b)
main()

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

N, X = map(int, input().split())
xs = list(map(int, input().split()))
a = [X - x if X >= x else x - X for x in xs]

print(reduce(gcd, a))

Solution (Python):
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)
n,x = list(map(int,input().split()))
data = [int(s) for s in input().split()]
dis = [None] * (n-1)

for i in range(n-1):
    dis[i] = abs(data[i+1] - data[i])
if n == 1:
    print(abs(x-data[0]))
    exit()

dis.sort()
if n == 2:
    temp = min(abs(x-data[0]),abs(x-data[1]))
    print(gcd(temp,dis[0]))
    exit()




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

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

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

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

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

print(gcd_list(x))

Solution (Python):
import fractions as fra
n,x=list(map(int,input().split()))
location=list(map(int,input().split()))
diff=[]
for i in location:
    diff.append(abs(x-i))
if len(diff)==1:
    print(diff[0])
else:
    ans=fra.gcd(diff[0],diff[1])
    for i in diff:
        ans=fra.gcd(ans,i)
    print(ans)

Solution (Python):
n, o = map(int, input().split())
x = sorted(list(map(int, input().split())) + [o])
difs = [x[i+1]-x[i] for i in range(n)]

ans = difs[0]
for i in range(n-1):
    a, b = difs[i+1], ans
    while a%b:
        a, b = b, a%b
    ans = b
print(ans)

Solution (Python):
from functools import reduce
n, a = map(int, input().split())
s = [int(i) for i in input().split()]
for i in range(n):
    s[i] = abs(a-s[i])
    
def saidaikouyakusuu(x, y):
    while x%y != 0:
        x, y = y, x%y
    return (y)

print(reduce(saidaikouyakusuu, s))

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

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

print(reduce(gcd, diff))

Solution (Python):
from fractions import gcd
N,X = map(int,input().split())
A = list(map(int,input().split()))+[X]
A.sort()
diff = []
for i in range(1,N+1):
    diff.append(A[i]-A[i-1])
res = diff[0]
for d in diff:
    res = gcd(res,d)
print(res)

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

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

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

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

print(gcds(dif))

Solution (Python):
from fractions import gcd

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

ans = abs(x[0]-X)

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

print(ans)

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

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

def multigcd(List):
    return reduce(gcd,List)
        
print (multigcd(Lxabs))

Solution (Python):
def GCD(a,b):
  if a == 0 or b == 0: return max(a,b)
  else:
    gcd = 1
    while 1:
      if a%b == 0:
        gcd = b
        break
      else:
        r = a%b
        a = b
        b = r
    return gcd

def main():
  n,x = map(int,input().split())
  pos = list(map(int,input().split()))
  res = 1
  if n == 1:
    res = abs(pos[0] - x)
  else:
    gcd = GCD(abs(pos[0] - x), abs(pos[1] - x))
    for i in range(2,n): gcd = GCD(gcd, abs(pos[i] - x))
    res = gcd
  
  print(res)

if __name__ == "__main__":
  main()

Solution (Python):
import fractions
from functools import reduce

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

n, x0 = map(int, input().split())
x = list(map(int,input().split()))
x.append(x0)
x.sort()
xdiff = []
tmp = x[0]
for xs in x:
    if xs - tmp == 0: continue
    xdiff.append(xs-tmp)
print(gcd_list(xdiff))

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

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

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

print(ans)

Solution (Python):
import fractions

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

def dist(n):
    return abs(int(n)-x)

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

ans = a[n-1]

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

print(ans)

Solution (Python):
import fractions

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

def dist(n):
    return abs(int(n)-x)

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

ans = a[n-1]

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

print(ans)

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

Solution (Python):
from fractions import gcd
n,x=map(int,input().split())
lst=list(map(int,input().split()))
gaps=[]
ans=1
if x in lst:
    pass
else:
    lst.append(x)
    lst=sorted(lst)
for i in range(1,len(lst)):
    gaps.append(lst[i]-lst[i-1])

tmp=gaps[0]
for i in range(1,len(gaps)):
    ans=gcd(tmp,gaps[i]) ; tmp=ans
if len(lst)==2:
    print(lst[1]-lst[0])
else:
    print(ans)

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

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


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

def main():
  n,x=LI()
  l=LI()

  b=abs(l[0]-x)
  for a in l[1:]:
    b=gcd(b,abs(a-x))

  return b

print(main())

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

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

Solution (Python):
from fractions import gcd
N, X = map(int, input().split())
x = list(map(int, input().split()))
l = []
for xx in x:
    l.append(abs(xx - X))

g = l[0]

for i in range(1, len(l)):
    g = gcd(g, l[i])

print(g)

Solution (Python):
import fractions

N,X=map(int,input().split())
L=list(map(int,input().split()))
ans = abs(L[0] - X)
for i in range(N-1):
  z = abs(L[i+1] - X)
  if ans > z:
    if ans % z != 0:
      ans = fractions.gcd(ans, ans % z)
    else:
      ans = z
  else:
    if z % ans != 0:
      ans = fractions.gcd(z, z % ans)

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)

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

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

if N == 1:
    print(abs(L[0]-X))
else:
    P = [0]*N
    P[0] = abs(min(L) - X)
    for i in range(1,N):
        P[i] = abs(L[i]-L[i-1])

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

    ans = gcd(P[0],P[1])

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

    print(ans)

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

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

print(reduce(gcd,x))

Solution (Python):
import fractions
from functools import reduce

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

print(abs(reduce(fractions.gcd, cities)))

Solution (Python):


import functools
import fractions
N, X = [int(i) for i in input().split()]
X_N = [int(i) for i in input().split()]
list = []
for e in X_N:
    list.append(abs(e - X))
gcd = functools.reduce(fractions.gcd, list)
print(gcd)

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

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

Solution (Python):
import fractions

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

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

else:
    diff = []

    for i in x:
        diff.append(abs(X - i))

    g = fractions.gcd(diff[0],diff[1])

    for i in range(1,len(diff)):
        g = fractions.gcd(g,diff[i])

    print(g)

Solution (Python):
N, X = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
x.append(X)
D = abs(X-x[0])
x.sort()


def GCD(x, y):
    a = max(x, y)
    b = min(x, y)
    r = a % b

    if r == 0:
        return b
    else:
        return GCD(b, r)

for ni in range(N):
    dif = x[ni+1] - x[ni]
    D = GCD(dif, D)

print(D)

Solution (Python):
N, X = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
x.append(X)
D = abs(X-x[0])
x.sort()


def GCD(x, y):
    a = max(x, y)
    b = min(x, y)
    r = 1
    while r != 0:
        r = a % b
        a = b
        b = r
    return a


for ni in range(N):
    dif = x[ni+1] - x[ni]
    D = GCD(dif, D)

print(D)

Solution (Python):
N, X = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
x.append(X)
D = abs(X-x[0])
x.sort()
for ni in range(N):
    dif = x[ni+1] - x[ni]
    if dif >= D:
        a = dif
        b = D
        r = 1
        while r != 0:
            r = a % b
            a = b
            b = r
        D = a
    else:
        a = D
        b = dif
        r = 1
        while r != 0:
            r = a % b
            a = b
            b = r
        D = a
print(D)

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

Solution (Python):
import fractions

N,X = map(int,input().split())
x = [int(i) for i in input().split()]
x.append(X)
x.sort()
y = [0]*N
for i in range(N):
    y[i] = x[i+1]-x[i]

if len(y) == 1:
    print(y[0])
else:
    answer = fractions.gcd(y[0],y[1])
    for i in range(2,N):
        answer = fractions.gcd(answer,y[i])
    print(answer)

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

def gcd(x,y):
    if x > y:
        x, y = y, x
    d = 0
    while(True):
        if y % x == 0:
            return x
        else:
            d = x
            x = y % x
            y = d

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

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

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

Solution (Python):
def gcd(a, b):
    bigger = max(a, b)
    smaller = min(a, b)
    while smaller != 0:
        bigger, smaller = smaller, bigger % smaller
    return bigger


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

Solution (Python):
import functools
import fractions

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

Solution (Python):
import fractions
import itertools
n,x=map(int,input().split())
X=[int(i) for i in input().split()]
gcd_=[]
for i in X:
    gcd_.append(abs(i-x))
gcd_=list(itertools.accumulate(gcd_,fractions.gcd))

print(gcd_[-1])

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

def euclid(x,y):
    if x > y:
        x,y = y,x
    d = 0
    while(True):
        if y%x == 0:
            return x
        else:
            d= x
            x = y%x
            y= d

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

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

Solution (Python):

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


n, x = [ int(v) for v in input().split() ]
city_list = [ int(v) for v in input().split() ] + [x]
city_list.sort()

ans = 0

def_list = [ city_list[i+1] - city_list[i] for i in range(n)]


if n == 1:
	ans = def_list[0]
else:
	gcd_list = [ 0 for i in range(n-1)]
	gcd_list[0] = gcd(def_list[0],def_list[1])
	for i in range(1,n-1):
		gcd_list[i] = gcd(gcd_list[i-1], def_list[i+1])

	ans = gcd_list[-1]
print(ans)

Solution (Python):
N, X = map(int, input().split())
l = list(map(int, input().split()))
g = X - l[0]
from fractions import gcd
for i in l[1:N]:
	if i == X: continue
	g = gcd(g, abs(X-i))

print(abs(g))

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

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

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

for i in range(n):
    s[i] = abs(s[i] - x)

if s[0] != 0:
    t = s[0]
    for i in range(n-1):
        if s[i+1] == 0:
            continue
        else:
            t = gcd(t,s[i+1])
else:
    t = s[-1]
    for i in range(n-1):
        if s[-i-2] == 0:
            continue
        else:
            t = gcd(t,s[-i-1])

print(t)

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



xs = [int(x) for x in input().split()]
xs.append(start)
xs.sort()
ds = sorted(list({(x1 - x0) for x0, x1 in zip(xs, xs[1:])}), reverse=True)

def gcd(a, b):
    while True:
        r = a % b
        if r == 0:
            return b
        a, b = b, r
        
a = ds[0]
for b in ds[1:]:
    a = gcd(a, b)
print(a)

Solution (Python):
N, X = map(int,input().split())
x = list(map(int,input().split())) + [X]
ans = abs(X-x[0])

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

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

Solution (Python):
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

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

def solve():
    n,start =f()
    x = f()
    x.append(start)

    x = sorted(x)

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

    print(g)





solve()

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

Solution (Python):
from fractions import gcd
N, *X = map(int, open(0).read().split())
X.sort()
y = [X[i + 1] - X[i] for i in range(N)]

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

Solution (Python):
from functools import reduce

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

if X not in x_list:
    x_list.append(X)
    x_list.sort()
    N += 1    

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

if N >= 3:
    space = [abs(x_list[i + 1] - x_list[i]) for i in range(N - 1)]
    print(reduce(gcd, space))
elif N == 2:
    space = x_list[1] - x_list[0]
    print(space)
elif N == 1:
    space = x_list[0]
    print(space)

Solution (Python):
import fractions

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

if N != 1:
    A = [0]*N
    for i in range(N):
        A[i] = x[i+1]-x[i]
    a = A[0]
    for j in range(N):
        a = fractions.gcd(a,A[j])
    print(a)
else:
    print(x[1]-x[0])

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

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

for i in x:
  xX.append(abs(i - X))

ans = xX[0]

for i in range(N):
  ans = fractions.gcd(xX[i],ans)

print(ans)

Solution (Python):
import fractions
n,x=map(int,input().split())
t=list(map(int,input().split()))
d=set()
for t_ in t:
    d.add(abs(t_-x))
if len(d)==1:
    print(d.pop())
else:
    g=fractions.gcd(d.pop(),d.pop())
    while(d):
        g=fractions.gcd(g,d.pop())
    print(g)

Solution (Python):
def euc(x, y):
	if y == 0: return x
	return euc(y, x%y)
def gcdall(lst):
	if lst == []: return 0
	v = lst[0]
	for i in range(1, len(lst)):
		v = euc(v, lst[i])
	return v

N, X = map(int, raw_input().split())
x = map(lambda val: int(val)-X, raw_input().split())
left = []
right = []
for i in range(0, len(x)):
	if x[i] < 0: left.append(-x[i])
	elif x[i] > 0: right.append(x[i])
print euc(gcdall(left), gcdall(right))

Solution (Python):
import sys
from functools import reduce 
n, m = map(int, sys.stdin.readline().split())
a  = list(map(int, sys.stdin.readline().split()))
b = [abs(i-m) for i in a]

def gcd(x,y):
    while y > 0:
        x, y = y ,x % y
    return x
  
print(reduce(gcd, b))

Solution (Python):
from sys import stdin
import fractions
from functools import reduce
A,B=[int(x) for x in stdin.readline().rstrip().split()]
data=[int(x) for x in stdin.readline().rstrip().split()]
data=[abs(i-B) for i in data]

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

print(gcd_list(data))

Solution (Python):
from sys import stdin
import fractions

N, X = [int(k) for k in stdin.readline().rstrip().split()]
x = [int(k) for k in stdin.readline().rstrip().split()]
y = [abs(k - X) for k in x]
C = y[0]
for l in range(N):
    C = fractions.gcd(C, y[l])
print(C)

Solution (Python):

import sys
import functools

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

def solve(N: int, X: int, x: "List[int]"):
    x2 = list(map(lambda x: abs(x-X),x))
    print(functools.reduce(gcd,x2))


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):
from functools import reduce

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

def gcd_from_list(vals):
    return reduce(gcd, vals)

n, x = map(int, input().split())
c = [abs(x - xn) for xn in map(int, input().split())]
print(gcd_from_list(c))

Solution (Python):

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

n, x = list(map(int, input().rstrip().split()))
lst = list(map(int, input().rstrip().split()))
d = abs(x - lst[0])
for i in range(n):
    dif = abs(x - lst[i])
    if dif % d == 0:
        continue
    d = gcd(d, dif)
print(d)

Solution (Python):

import fractions as math

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

Solution (Python):
from fractions import gcd

N, X = map(int, input().split())
P = list(abs(int(x) - X) for x in input().split())

v = P[0]
for x in P[1:]:
  v = gcd(v, x)

print(v)

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

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

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


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

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

Solution (Python):







import fractions


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


ldif = list()

for i in range(n):
    ldif.append(abs(xl[i]-x))



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

print(ac_gcd)

Solution (Python):

"""
C - Skip
https://atcoder.jp/contests/abc109/tasks/abc109_c

"""
import sys

from bisect import bisect_right, bisect_left

def solve(N, X, points):
    def divisor(N):
        divisors = set()
        for i in range(1, int(N**0.5)+1):
            if N % i == 0:
                divisors.add(i)
                divisors.add(N // i)
        return sorted(divisors)

    left, right = float('inf'), float('inf')
    l = bisect_left(points, X)
    if l:
        left = points[l-1]
    r = bisect_right(points, X)
    if r != len(points):
        right = points[r]

    gaps = [abs(X-p) for p in points]
    candidates = divisor(min(abs(left-X), abs(right-X)))
    while True:
        c = candidates.pop()
        if all([g%c==0 for g in gaps]):
            return c


def main(args):
    N, X = map(int, input().split())
    points = sorted(map(int, input().split()))
    ans = solve(N, X, points)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Solution (Python):
import fractions
N, M = list(map(int, input().split()))
X = list(map(int, input().split()))
X.append(M)
X = sorted(X)
diff = [X[i+1]-X[i] for i in range(len(X)-1)]
max_gcd = diff[0]
for i in range(1, len(diff)):
  max_gcd = fractions.gcd(diff[i], max_gcd)
print(max_gcd)

Solution (Python):

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

Solution (Python):
from fractions import gcd

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

l = []
for xx in x:
    l.append(abs(xx - X))

ans = l[0]
for ll in l:
    ans = gcd(ans, ll)

print(ans)

Solution (Python):

"""
Created on Fri May 17 15:12:31 2019

@author: avina
"""
from fractions import gcd
n,m = map(int, input().split())
l = [abs(m - int(i)) for i in input().split()]

g =l[0]
for i in range(1,n):
    g = gcd(g,l[i])
print(g)

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

li = []
for i in A:
    d = abs(i - X)
    li.append(d)

li.sort()
l = li[0]
divisors = []
for i in range(1, int(l ** (1 / 2)) + 1):
    if l % i == 0:
        divisors.append(i)
        if i != l // i:
            divisors.append(l // i)
divisors.sort(reverse = True)
for i in divisors:
    for j in li:
        count = 0
        if j % i != 0:
            count += 1
        if count != 0:
            break
    if count == 0:
        print(i)
        break

Solution (Python):
from fractions import gcd

N, X = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(lambda i: abs(X - i), x))
ans = y[0]
for i in range(1, N):
	ans = gcd(ans, y[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())
p_list=list(map(int, input().split()))
p_list.append(x)
p_list=sorted(p_list)

df_list=[]
for j in range(len(p_list)-1):
  df_list.append(p_list[j+1]-p_list[j])

if n==1:
  print(df_list[0])
else:
  print(gcd_list(df_list))

Solution (Python):
import fractions

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

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

print(d)

Solution (Python):
from fractions import gcd

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

L = []
for l in x:
    L.append(abs(l - X))

res = L[0]
for i in range(len(L)):
    res = gcd(res, L[i])
print(res)

Solution (Python):
from fractions import gcd

N, X = map(int, input().split())
x = list(sorted(list(map(int, input().split())) + [X]))
d = []
for a, b in zip(x, x[1:]):
  d.append(b - a)
g = 0
for v in d:
  g = gcd(g, v)
print(g)

Solution (Python):
import fractions
from functools import reduce

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




print(reduce(fractions.gcd, x))

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


gc = li[0]
for v in li[1:]:
  if ( v != 0 ):
    gc = gcd(gc,v)
print ( gc )

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

a = sorted(A)

def yu(a, b):
	ma = max([a, b])
	mi = min([a, b])
	while (ma % mi):
		t = ma
		mi = ma % mi
		ma = t
	return mi

ld = a[1] - a[0]
for n in range(2, N + 1):
	d = a[n] - a[n - 1]
	ld = yu(ld, d)

print(ld)

Solution (Python):
N,X=map(int,input().split())
x=list(map(int,input().split()))
l=[]
for i in range(N):
    l.append(abs(X-x[i]))
def gcd(a,b):
    if a == 0:
        return b
    if b == 0:
        return a
    r = 1
    while r > 0:
        r = a % b
        a = b
        b = r
    return a

ll=[0]*(N+1)
for i in range(N):
    ll[i+1]=gcd(ll[i],l[i])
print(ll[N])