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 math
from functools import reduce
N, X = map(int, input().split())
x = list(map(int,input().split()))
 
for i in range(N):
    x[i] = abs(x[i]-X)
 
x = sorted(x)[::-1]
cnt = 0
 
for i in range(N):
    cnt = math.gcd(cnt, x[i])
 
print(cnt)

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


def read():
    N, X = map(int, input().strip().split())
    A = list(map(int, input().strip().split()))
    return N, X, A


def solve(N, X, A):
    A = [a-X for a in A]
    ans = reduce(math.gcd, A)
    return abs(ans)


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

Solution (Python):
N,X=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)
X=abs(X-x[0])
for i in range(N-1):
  X=gcd(max(X,abs(x[i+1]-x[i])),min(X,abs(x[i+1]-x[i])))
print(X)

Solution (Python):
import math
from functools import reduce
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
a,b=map(int,input().split())
c=list(map(int,input().split()))
d=[]
for i in c:
    d.append(abs(b-i))
print(gcd_list(d))

Solution (Python):
from math import gcd
N, X = map(int, input().split())
x = list(map(int, input().split()))
x.append(X)
x.sort()
m = 0
for i in range(N):
    if m == 0:
        m = x[i+1]-x[i]
    else:
        m = gcd(m, x[i+1]-x[i])
print(m)

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

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

if n==1:
    print(xlist[0])
    sys.exit()

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

Solution (Python):
from math import gcd

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

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

N, X = MI()
x = LI()
D = abs(X - x[0])

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

Solution (Python):
import math
import sys
def gcd(l: list):
    n=len(l)
    gcd=math.gcd(l[0],l[1])
    for i in range(2,n):
        gcd=math.gcd(l[i],gcd)

    return gcd

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

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


y=[0]*n
for i in range(n):
    y[i]=abs(x_list[i]-x)

print(gcd(y))

Solution (Python):
import numpy as np
import math
N, X = map(int,input().split())
x = list(map(int,input().split()))
_x = N*[0]

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

if N == 1:
  print(_x[0])
  exit()
ans = math.gcd(_x[0],_x[1])
for i in range(2,N):
  ans = math.gcd(_x[i],ans)
  
print(ans)

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 math import gcd
n, x = map(int, input().split())
x = list(map(lambda xi: abs(int(xi) - x), input().split()))
g = x[0]
for xi in x:
    g = gcd(g, xi)
print(g)

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

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

x.sort()

gcd = 0

for i in range(N):
    if i == 0:
        gcd = x[i+1]-x[i]
    else:
        gcd = fractions.gcd(gcd,x[i+1]-x[i])
    st.append(x[i+1]-x[i])
print(gcd)

Solution (Python):
import fractions
from functools import reduce
n,s=map(int,input().split())
x=list(map(int,input().split()))


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

print(reduce(fractions.gcd,x))

Solution (Python):
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
N,X=map(int,input().split())
x=list(map(int,input().split()))
kari=[]
for i in range(N):
    kari.append(abs(x[i]-X))
ans=gcd(min(kari),max(kari))
for i in range(N):
    ans=gcd(ans,kari[i])
print(ans)

Solution (Python):
import functools
from fractions import gcd
n,x =map(int,input().split())
if n==1:
    c = abs(int(input())-x)
    print(c)
else:
    lis = list(map(int,input().split()))
    for i in range(n):
        lis[i] = abs(lis[i]-x)
    print(functools.reduce(gcd,lis))

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):
def gcd(a, b):
    if (b == 0):
        return a
    return gcd(b, a % b)

n, x = map(int,input().split())
arr = list(map(int,input().split()))
diff = []
arr.sort()
g = abs(arr[0] - x)
for i in range(1,n):
    g = gcd(g, abs(arr[i] - x))
print(g)

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

Solution (Python):
n,x = map(int,input().split())
ls = list(map(int,input().split()))
ls = list(map(lambda t:abs(t-x),ls))
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)
def gcdlist(l):
    a = l[0]
    for i in range(len(l)):
        a = gcd(a,l[i])
    return a
print(gcdlist(ls))

Solution (Python):
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]





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

N, S = mi()
X = li()
ans = abs(S - X[0])
for i in range(1, N):
    ans = gcd(ans, abs(S - X[i]))

print(ans)

Solution (Python):
import fractions

N,X = map(int, input().split())
S = list(map(int, input().split()))
S = [abs(s-X) for s in S]

gcd = S[0]
for k in range(N-1):
  gcd = fractions.gcd(gcd, S[k+1])
print(gcd)

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

x.append(X)
x = list(set(x))
x.sort()
y = [x[i+1]-x[i] for i in range(len(x)-1)]

if len(x) == 1:
  print(0)
  exit()
elif len(x) == 2:
  print(abs(x[1]-x[0]))
  exit()
else:
  ans = y[0]
  for i in range(len(y)):
    ans = gcd(ans,y[i])
print(ans)

Solution (Python):
import math 
import fractions

a,b=map(int,input().split())
l=list(map(int,input().split()))
b_l = []
for i in range(a):
    b_l.append(abs(b-l[i]))
ans=b_l[0]
for j in range(1,a):
    ans = fractions.gcd(ans,b_l[j])
print(ans)

Solution (Python):
def gcd(a,b):
	if a%b==0:return b
	else:return gcd(b,a%b)
INF=10**9
ans=INF
n,X=map(int,input().split())
x=list(map(int,input().split()))
if n==1:
	print(abs(X-x[0]))
else:
	for i in range(n-1):
		tmp=gcd(abs(X-x[i]),abs(X-x[i+1]))
		ans=min(ans,tmp)
	print(ans)

Solution (Python):
from fractions import gcd

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

def main():
    N, X = mi()
    x = list(mi())
    y = [abs(x[i]-X) for i in range(N)]
    t = y[0]
    for i in range(N):
        t = gcd(t, y[i])
    print(t)


if __name__ == '__main__':
    main()

Solution (Python):






from collections import deque,defaultdict











import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,X = readInts() 
a = list(map(lambda x:abs(X - int(x)), input().split()))
res = 0
from fractions import gcd
for i in range(n):
    res = gcd(res,a[i])
print(res)

Solution (Python):
import fractions
from functools import reduce

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






ans = []


for i in range(N):
    dfe = abs(L[i] - X)
    ans.append(dfe)

ans = list(set(ans))






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




print(gcd_list(ans))

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

is_ok = True


from fractions import gcd
if N == 1:
    print(abs(x[0]-X))
elif N == 2:
    GCD = gcd(abs(x[0]-X), abs(x[1]-X))
    print(GCD)
else:
    GCD = gcd(abs(x[0]-X), abs(x[1]-X))
    for i in range(2, N):
        a = abs(x[i] - X)
        GCD = gcd(GCD, a)

    print(GCD)

Solution (Python):
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
  
N,X = map(int,input().split())
A = list(map(int,input().split()))
B = [abs(X-i) for i in A]
ans = B[0]
for j in B:
    ans = gcd(ans, j)
print(ans)

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

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

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)


def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
n,x=map(int,input().split())
b=list(map(int,input().split()))
a=[]
for i in b:
  a.append(abs(i-x))
print(gcd_list(a))

Solution (Python):
import fractions

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

for i in xl:
    l.append(abs(i - x))

ans = l[0]

for i in l:
    ans = fractions.gcd(ans, i)

print(ans)

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

from fractions import gcd
g = abs(A[0]-x)
for a in A:
  g = gcd(g, abs(a-x))
print(g)

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

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

    ans = fractions.gcd(ans, abs(x[i]-x[i-1]))

print(ans)

Solution (Python):
from sys import stdin
from fractions import gcd
def main():
    readline=stdin.readline
    n,x=map(int,readline().split())
    a=list(map(int,readline().split()))

    for i in range(n):
        if i==0:
            ans=abs(x-a[i])
        else:
            ans=gcd(ans,abs(x-a[i]))

    print(ans)

if __name__=="__main__":
    main()

Solution (Python):
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy


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())) + [X]

x.sort()

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

print(y)

Solution (Python):
def gcd(a,b):
    a=abs(a)
    b=abs(b)
    if a<b:
        c=a
        a=b
        b=c
    if a%b==0:
        return b
    else:
        return gcd(b,a%b)
n,x = map(int,input().split())
xlist= list(map(int,input().split()))
ans=x-xlist[0]
for i in xlist:
    ans=gcd(ans,x-i)
print(ans)

Solution (Python):

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

n,x = map(int,input().split())
X = list(map(int, input().split()))
a = []
dist = []
if len(X) == 1:
    print(abs(X[0]-x))
    exit()
for i in range(len(X)):
    a.append(abs(X[i]-x))
ans = 0
for d in a:
    ans = gcd(ans,d)
print(ans)

Solution (Python):
from fractions import gcd


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

    
if __name__ == '__main__':
    main()

Solution (Python):
import sys
import math

N, X = map(int, input().split())
x = list(input().split())
city = [abs(int(x[i]) - X) for i in range(N)]
MAX = min(city)
candidate = []
for i in range(int(math.sqrt(MAX)+1)):
    if MAX % (i+1) == 0:
        candidate.append(i+1)
        candidate.append(MAX // (i+1))

candidate = list(sorted(candidate, reverse=True))

for j in range(len(candidate)):
    ans = candidate[j]
    tmp = [city[i] % ans for i in range(N)]
    if max(tmp) == 0:
        print(ans)
        sys.exit()

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

from fractions import gcd

if n==1:
    print(abs(city[0]-x))
    exit(0)

city = sorted(city)

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

for j in range(n):
    if j==0:
        ans = gcd(city[j],city[j+1])
    else:
        ans = gcd(ans,city[j])

print(abs(ans))

Solution (Python):
import fractions
from functools import reduce

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

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

sub=[]
for c in C:
  sub.append(abs(c-X))

print(gcd(sub))

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

n, x = map(int,input().split())
li = list(map(int,input().split()))
d = [abs(x-li[0])]
 
for i in range(n-1):
    d.append(abs(li[i]-li[i+1]))

print(gcd(*d))

Solution (Python):
from fractions import gcd

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

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

Solution (Python):
from fractions import gcd

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

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

print(res)

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

Solution (Python):
n, x = map(int, input().split())
xs = list(map(int, input().split()))
ds = []
for i in range(n):
  if xs[i]-x < 0:
    ds.append((xs[i]-x)*(-1))
  else:
    ds.append(xs[i]-x)
nums = sorted(list(set(ds)))
if n==1 or len(nums)==1:
  print(nums[0])
  quit()
else:
  cnd = []
  for j in range(len(nums)-1):
    a = nums[j+1]
    b = nums[j]
    while b>0:
      a,b = b, a%b
    cnd.append(a)
  print(min(cnd))

Solution (Python):
import fractions
N,X=map(int,input().split())
x=list(map(lambda x: abs(int(x)-X), input().split()))
x_min=min(x)
g_min=x_min
for i in x:
  g=fractions.gcd(g_min,i)
  if g==1:
    print(1)
    exit()
  if g < g_min:
    g_min = g
print(g_min)

Solution (Python):
import fractions
N,X=map(int,input().split())
x=list(map(lambda x: abs(int(x)-X), input().split()))
x_min=min(x)
g_min=x_min
for i in x:
  g=fractions.gcd(g_min,i)
  if g < g_min:
    g_min = g
print(g_min)

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

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

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

gcd_value = abs(X-x[0])

for i in range(1,n):
    gcd_value = gcd(gcd_value,abs(X-x[i]))

print(gcd_value)

Solution (Python):
import fractions

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

gcd_value = abs(X-x[0])

for i in range(1,n):
    gcd_value = fractions.gcd(gcd_value,abs(X-x[i]))

print(gcd_value)

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

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

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

print(ans)

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

gaps = [b-a for a,b in zip(x, x[1:])]

from fractions import gcd
g1=gaps[0]
for g2 in gaps[1:]:
    g1 = gcd(g1, g2)

print(g1)

Solution (Python):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import bisect

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

if __name__ == "__main__":
    n,x = map(int,input().split())
    X = list(map(int,input().split()))
    X.sort()
    a = bisect.bisect_left(X,x)
    X.insert(a,x)
    ans = []
    for i in range(1,len(X)):
        diff = X[i] - X[i-1]
        ans.append(diff)
    d = ans[0]
    for i in range(1,len(ans)):
        d = gcd(d,ans[i])
    print(d)

Solution (Python):
import fractions
n,x = map(int,input().split())
a = list(map(int,input().split()))
b = [abs(a[i]-x) for i in range(n)]

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

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,x=map(int, input().split())
town=list(map(int, input().split()))+[x]
town.sort()
if n == 1:
    town.remove(x)
    print(abs(town[0]-x))
    exit()

d1 = abs(town[0]-town[1])
d2 = abs(town[1]-town[2])
ans = gcd(d1,d2)

for i in range(2,n):
    d = abs(town[i]-town[i+1])
    ans = gcd(d,ans)
print(ans)

Solution (Python):
def gcd(a, b):
    big, small = max(a, b), min(a, b)
    if big % small == 0:
        return small
    div = None
    while big % small != 0:
        div = big % small
        big, small = small, div
    else:
        return div


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

d = x[0]
for xi in x[1:]:
    d = gcd(d, xi)
print(abs(d))

Solution (Python):
from fractions import gcd

n,x=map(int,input().split())
l=list(map(int,input().split()))+[x]
l.sort()

ans=l[1]-l[0]
for i in range(2,n+1):
  sa=l[i]-l[i-1]
  ans=gcd(ans,sa)

print(ans)

Solution (Python):
def main():
    from functools import reduce

    N, X = map(int, input().split())
    A = (int(j) - X for j in input().split())

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

    print(abs(reduce(gcd, A)))


if __name__ == '__main__':
    main()

Solution (Python):
from fractions import gcd

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



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

Solution (Python):
import math
import string
import collections
from collections import Counter
from collections import deque
from decimal import Decimal
import sys
import fractions


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


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor



dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
N, X = map(int, input().split())
x = readints()



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

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

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

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

print(g)

Solution (Python):
import numpy as np
from fractions import gcd
n,x=map(int,input().split())
xl=list(map(int,input().split()))

xl.append(x)


p=min(xl)
ans=x-p
for i in range(n+1):
    ans=gcd(xl[i]-p,ans)
print(ans)

Solution (Python):
N, X = map(int, input().split())
Xs = list(map(int, input().split()))
from fractions import gcd

lis = []
for x in Xs:
    lis.append(abs(x-X))

G = 0
for l in lis:
    G = gcd(l, G)
print(G)

Solution (Python):
from collections import deque
from fractions import gcd
N, X = map(int, input().split())
x = list(map(int, input().split()))

x.append(X)
x.sort()

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

g = d[0]
for j in d:
    g = gcd(g, j)
print(g)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,x=map(int, input().split())
    l=list(map(int,input().split()))
    if n==1:
        print(abs(l[0]-x))
    else:
        l.append(x)
        l.sort()
        S=[]
        for i in range(n):
            S.append(l[i+1]-l[i])
        from functools import reduce
        from fractions import gcd
        print(reduce(gcd,S))
resolve()

Solution (Python):
import sys
from collections import Counter
from collections import deque
import heapq
import math
import fractions
import bisect
import itertools
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n,X=mp()
x=lmp()
ans=abs(X-x[0])
for i in range(0,n-1):
    ans=fractions.gcd(ans,abs(x[i]-x[i+1]))
print(ans)

Solution (Python):
import fractions
def GCD(a):
    gcd = a[0]
    N = len(a)
    for i in range(1, N):
        gcd = fractions.gcd(gcd, a[i])
    return gcd

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

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

x.append(X)
x.sort()

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

ans = GCD(d)
print(ans)

Solution (Python):
import fractions
from collections import deque
from functools import reduce
def gcd(numbers):
    return reduce(fractions.gcd, numbers)
N,X = map(int,input().split())
x = list(map(int,input().split()))
A = deque([])
for i in x:
    A.append(abs(X-i))
print(gcd(list(A)))

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

from fractions import gcd

now = lin[0]
for i in range(1,n):
    p = gcd(now,lin[i])
    now = p

print(now)

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

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

Solution (Python):
def gcd(x,y):
    while y>0:
        x,y = y,x%y
    return x
N,X = map(int,input().split())
A = list(map(int,input().split()))
B = [0 for _ in range(N)]
for i in range(N):
    if X>A[i]:
        B[i] = X-A[i]
    else:
        B[i] = A[i]-X
D = B[0]
for i in range(1,N):
    D = gcd(D,B[i])
print(D)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


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

    def ngcd(self, A):
        res = A[0]
        for i in range(len(A)):
            if res != 1:
                res = gcd(A[i], res)
        return res

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

    def nlcm(self, A):
        res = A[0]
        for i in range(len(A)):
            res = lcm(res, A[i])
        return res


def resolve():
    n, x = map(int, input().split())
    X = sorted(list(map(int, input().split())))

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

    g = Gcd()
    res = dist[0]
    for i in range(1, len(dist)):
        res = g.gcd(res, dist[i])
    print(res)


if __name__ == '__main__':
    resolve()

Solution (Python):
from itertools import accumulate


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


N, X = map(int, input().split())
A = [abs(X - a) for a in map(int, input().split())]
ans = list(accumulate(A, func=GCD))[-1]
print(ans)

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

x_list.sort()
x_sa=[]
a=x_list[1]-x_list[0]
for i in range(1,n):
  b=x_list[i+1]-x_list[i]
  a=fractions.gcd(a,b)
print(a)

Solution (Python):
def examA():
    C1 = SI()
    C2 = SI()
    ans = "YES"
    if C1[0]!=C2[2] or C1[1]!=C2[1] or C1[2]!=C2[0]:
        ans = "NO"
    print(ans)
    return

def examB():
    A, B, C, X, Y = LI()
    loop = max(X,Y)
    ans = inf
    for i in range(loop+1):
        cost = i*2*C
        if X>i:
            cost += A*(X-i)
        if Y>i:
            cost += B*(Y-i)
        ans = min(ans,cost)
    print(ans)
    return

def examC():
    def gcd(x, y):
        if y == 0:
            return x
        while (y != 0):
            x, y = y, x % y
        return x
    N, x = LI()
    X = LI()
    if N==1:
        print(abs(X[0]-x))
        return
    for i in range(N):
        X[i] = abs(X[i]-x)
    now = gcd(X[0],X[1])
    for i in range(2,N):
        now = gcd(now,X[i])
    ans = now
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

from decimal import Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examC()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Solution (Python):
from fractions import gcd
n, x = map(int, input().split())
xx = map(int, input().split())
ans = 0
for i in xx:
    ans = gcd(ans, abs(i - x))
print(ans)

Solution (Python):
def gcd(a, b):
  if(a == b):
    return a
  elif(a % b == 0):
    return b
  elif(b % a == 0):
    return a
  elif(a == 1 or b == 1):
    return 1
  elif(a > b):
    return gcd(a- a// b* b, b)
  elif(a < b):
    return gcd(a, b- b// a* a)

def ggcd(lista):
  if(len(lista) == 1):
    return lista.pop()
  else:
    l = lista.pop()
    for i in range(1, len(lista)):
      l = gcd(l, lista.pop())
    return l

N, X = map(int, input().split())
x = list(map(int, input().split()))
x.append(X)
d = []
gcds = set()
x.sort()

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

gcds.add(d[0])

for i in range(N- 1):
  if(d[i+ 1] != d[i]):
    gcds.add(d[i+ 1])

print(ggcd(gcds))

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

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

n, s = map(int, input().split())
x = [abs(i-s) for i in map(int, input().split())]
print(gcds(*x))

Solution (Python):
import fractions
from functools import reduce

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

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

print(gcd(*L))

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


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


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

x_arr = [0] * n

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

for i in range(len(x_arr)):
    x_arr[i] = abs(x_arr[i] - x)
print(gcd_list(x_arr))

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

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

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

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


print(gcd_list(y))

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

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

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

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


print(gcd_list(y))

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

from functools import reduce


y = [abs(x - X) for x in Xs]
print(reduce(gcd, y))

Solution (Python):
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

def main():
    N, X = map(int, input().split())
    x = list(map(int, input().split()))
    y = [abs(X-a) for a in x]
    cnt = set(make_divisors(min(y)))
    for d in y:
        tmp = []
        for c in cnt:
            if d%c == 0:
                tmp.append(c)
        cnt.intersection_update(set(tmp))
        if len(cnt) == 1:
            print(1)
            return
    ans = max(cnt)
    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):


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

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

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

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

from fractions import gcd

ans=abs(x-x_list[0])
for i in range(1, n):
    x_diff=x_list[i]-x_list[i-1]
    ans=gcd(ans, x_diff)

print(ans)

Solution (Python):
import fractions as math

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

a = []
for i in s:
    a.append(abs(i-x))

tmp = a[0]
for i in range(1,len(a)):
    tmp = math.gcd(tmp,a[i])

print(tmp)