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

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

x_list.sort()

x_diff = [x_list[i+1]-x_list[i] for i in range(len(x_list)-1)]


A = x_diff

value = A[0]
for i in range(1, len(A)):
    value = math.gcd(value, A[i])
print(value)

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

Solution (Python):
import math

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

D = abs(l[0]-X)

for i in range(N):
    D = math.gcd(D,abs(l[i]-X))

print(D)

Solution (Python):
import math

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

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

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

Solution (Python):

 

 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy
 

 










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

ans = abs(A[0]-X)
for i in range(1,N):
    tmp = abs(A[i]-X)
    ans = math.gcd(ans,tmp)

print(ans)

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

g=0

for y in a:
  g=math.gcd(g,abs(y-x))
  
print(g)

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

def gcd(A):
    return reduce(math.gcd, A)

N,X = map(int, input().split())
x = sorted(map(int, input().split()))
bisect.insort(x,X)
ans = [x[i+1]-x[i] for i in range(N)] 
if N ==1:
    print(x[1]-x[0])
else:
    print(gcd(ans))

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


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


res = abs(X - Y[0])
for i in range(N - 1):
    res = gcd(res, Y[i + 1] - Y[i])
print(res)

Solution (Python):
from math import gcd

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

a=L[0]
for b in L:
    a=gcd(a,b)
print(a)

Solution (Python):
from math import gcd
n,x=map(int,input().split())
c=list(map(int,input().split()))
o=[]
if len(c)==1:
  print(abs(c[0]-x))
else:
  for i in c:
    o.append(abs(i-x))
  ans=gcd(o[1],o[0])
  for j in range(n-2):
      ans=gcd(ans,o[j+2])
  print(ans)

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

y = sorted(x+[X])
d_y = [y[i]-y[i-1] for i in range(1,N+1)]
import math
from functools import reduce
print( reduce(math.gcd,d_y) )

Solution (Python):
import numpy as np
import math

N,X=map(int,input().split())
L=np.array(list(map(int,input().split())))
L=abs(L-X)
ans=L[0]

for i in range(1,N):
  ans=math.gcd(ans,L[i])
print(ans)

Solution (Python):
import math
from functools import reduce
 
def gcd(ns):
    return reduce(math.gcd, ns)
 
N, X = map(int, input().split())
L = list(map(int, input().split()))
 
diff = [abs(x - X) for x in L]
 
if len(diff) == 1:
    print(diff[0])
else:
    print(gcd(diff))

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

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

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

Solution (Python):
import math
def diff(l):
    c = 0
    ans = []
    for i in l:
        try:
            ans.append(abs(i-l[c+1]))
            c+=1
        except:
            continue
    return ans
def multiGCD(l):
    ans = 0
    for i in l:
        ans = math.gcd(ans, i)
    return ans
n, x = map(int, input().split())
l = list(map(int, input().split()))
l.append(x)
l.sort()
l2 = diff(l)
print(multiGCD(l2))

Solution (Python):
import math
[n,x] = [int(i) for i in input().split()]
xs = [int(i) for i in input().split()]
if n != 1:
    xs.append(x)
    xs.sort()
    diff = []
    for i in range(1,n+1):
        diff.append(xs[i] - xs[i-1])
    ans = 0
    for i in range(1,len(diff)):
        if i == 1:
            ans = math.gcd(diff[i-1],diff[i])
        else:
            ans = math.gcd(ans,diff[i])
    print(ans)
else:
    print(abs(x - xs[0]))

Solution (Python):
from math import gcd
N,X = map(int, input().split())
L = list(map(int, input().split()))
k = 0
for i in L:
  if k == 0:
    k = i - X
  else:
    k = gcd(k, i-X)
print(abs(k))

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

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

def gcd(l):
    ans = l[0]
    for i in l:  ans = gcd_(ans, i)
    return ans

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

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

Solution (Python):
import math

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

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

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

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

index = bisect.bisect_left(a, x)
a.insert(index, x)
d = [0]*(n)
for i in range(n):
    d[i] = a[i+1] - a[i]
ans = gcd(*d)
print(ans)

Solution (Python):
n, X = map(int, input().split())
x = list(map(abs, [i-X for i in list(map(int, input().split()))]))
x.sort()
if x[0] == 0:
    del x[0]
    n -= 1
def gcd(a, b):
    while True:
        c = a%b
        if c == 0:
            break
        a = b
        b = c
    return b

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

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

kyori = []

for i in arr:
    kyori.append(abs(X-i))

c =math.gcd(kyori[0],kyori[0])
for i in kyori:
    c =math.gcd(c,i)

print(c)

Solution (Python):

import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd





def solve():
    n, g = [int(x) for x in input().split()]
    a = [int(x) for x in input().split()]
    if n == 1:
        print(abs(a[0]-g))
        return
    
    a.append(g)
    a.sort()
    b = []
    for i in range(1, n+1):
        b.append(a[i]-a[i-1])
    g = b[-1]
    for e in b:
        g = gcd(e, g)
    print(g)
    




        

t = 1

for case in range(1,t+1):
    ans = solve()


"""



"""

Solution (Python):
import math
N,start = [int(x) for x in input().split()]
_x = [int(y) for y in input().split()]
x = [0 for y in range(N)]
for i in range(N):
    x[i] = abs(_x[i] - start)
g = x[0]
for i in range(N):
    g = math.gcd(g,x[i])
print(g)
ans = 1

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

Solution (Python):
def A(a,b):
    if a<b:
        tmp = a
        a = b
        b = tmp
    r = a % b
    while r!=0:
      a = b
      b = r
      r = a % b
    return b
n,X=map(int,input().split())
x=list(map(int,input().split()))
x.append(X)
x.sort()
x2=[]
for i in range(1,n+1):
    x2.append(x[i]-x[i-1])
if len(x2)==1:
    p=x2[0]
else:
    for i in range(n):
        if i==0:
            p=A(x2[i-1],x2[i])
        elif i!=1:
            p=A(p,x2[i])
print(p)

Solution (Python):
n,c = map(int,input().split())
x = [c] + list(map(int,input().split()))
x.sort()
ans = x[1]-x[0]
import math
for i in range(1,n):
    ans = math.gcd(ans,x[i+1]-x[i])
print(ans)

Solution (Python):
import math
N,X  = (int(T) for T in input().split())
Cor  = sorted([abs(int(T)-X) for T in input().split()])
GCDC = Cor[0]
for T in range(1,N):
    GCDC = math.gcd(GCDC,Cor[T])
    if GCDC==1: break
print(GCDC)

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

x.append(m)
x = sorted(x)
l = [0]*n
for i in range(n): l[i] = x[i+1] - x[i]

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

Solution (Python):
import functools
import math

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

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

ans = functools.reduce(math.gcd, dist_next)
print(ans)

Solution (Python):
import math


N, X = map(int, input().split())
x = [int(_) for _ in input().split()]
if N == 1:
    print(abs(x[0]-X))
    exit()

x.sort()

for i in range(N-1):
    if x[i] < X and x[i+1] > X:
        x = x[:i+1] + [X] + x[i+1:]
        break
    elif x[i] >= X:
        x = [X] + x
        break
    elif x[i+1] <= X:
        x = x + [X]
        break

if len(x) >= 3:
    base = math.gcd(x[1]-x[0], x[2]-x[1])
    for i in range(2, N):
        diff = x[i+1] - x[i]
        base = math.gcd(base, diff)
    print(base)
else:
    print(x[1] - x[0])

Solution (Python):
import numpy as np

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

x.append(X)
x.sort()

y = []

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



  
for i in range(N - 1):
  
  g = np.gcd.reduce([ans, y[i + 1]])
  
  if g == 1:
    print(1)
    break
  else:
    ans = g
else:
  print(ans)

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

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

diff = []

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

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

print(ans)

Solution (Python):
import math
from functools import reduce

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


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

X.append(Y)
X2 =sorted(X)
X3 = []

for i in range(1, len(X)):
    X3.append(X2[i] - X2[i-1])

print(gcd_list(X3))

Solution (Python):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0
inf = float("inf")

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

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

Solution (Python):

n, x=  map(int, raw_input().split(' '))
def gcd(a,b): return a if b == 0 else gcd(b, a % b)
print reduce(gcd,map(lambda c: abs(c - x), map(int, raw_input().split(' '))))

Solution (Python):
n, x = map(int, input().split())
X = tuple(map(lambda k:abs(int(k)-x), input().split()))
from math import gcd
from functools import reduce
ans = reduce(gcd, X)
print(ans)

Solution (Python):
import math
from functools import reduce

def my_gcd(*N):
    return reduce(math.gcd, N)

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

if X not in C:
	C.append(X)
C.sort()

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

print(my_gcd(*D))

Solution (Python):
import math
from functools import reduce

def gcd(ns):
    return reduce(math.gcd, ns)

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

diff = [abs(x - X) for x in L]

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

Solution (Python):
import math  

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

diff = [abs(x - X) for x in Coordinates]

if len(diff) == 1:
  print(min(diff))
else:
  ans = diff[0]
  for i in range(1, len(diff)):
    ans = math.gcd(ans, diff[i])
  print(ans)

Solution (Python):
from math import gcd

N, X = map(int, input().split())
xs = sorted(map(int, input().split()))
ds = [xs[i] - X for i in range(N)]
ans = abs(ds[0])
for d in ds:
    ans = gcd(abs(d), ans)
print(ans)

Solution (Python):
N, X = map(int, input().split())
A = list(map(lambda a: abs(int(a) - X), input().split()))
def gcd(a, b):
    while b != 0:
        r = a % b
        a = b
        b = r
    return a
g = A[0]
for a in A[1:]:
    g = gcd(g, a)
print(g)

Solution (Python):
import math

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



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

print(out)

Solution (Python):






import math
from functools import reduce





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





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





def myfunc(x,X):
    mylist = [abs(i-X) for i in x]
    print(gcd_list(list(set(mylist))))





myfunc(x,X)

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

Solution (Python):
from collections import defaultdict
from collections import deque
import itertools
import math

def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

n,x = readInts()
xs = readInts()
xs.append(x)
xs.sort()

ans = xs[1]-xs[0]
for i in range(n):
  ans = math.gcd(ans,xs[i+1]-xs[i])

print(ans)

Solution (Python):
import math
n, x = map(int, input().split())
xx = sorted(list(map(int, input().split())) + [x])
y = xx[0]
for i in range(n + 1):
    xx[i] -= y
y = xx[1]
for i in range(2, n + 1):
    y = math.gcd(y, xx[i])
print(y)

Solution (Python):
def resolve():
    '''
    code here
    '''
    import math
    N, X = [int(item) for item in input().split()]
    xs = [int(item) for item in input().split()] + [X]
    xs.sort()

    if N > 2:
        res = math.gcd(xs[1] - xs[0], xs[2] - xs[0])

        for item in xs[3:]:
            res = math.gcd(res, item - xs[0])
    elif N == 2:
        res = math.gcd(xs[1] - xs[0], xs[2] - xs[0])
    else:
        res = xs[1] - xs[0]
    
    print(res)


if __name__ == "__main__":
    resolve()

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

li = []
x.sort()
for i in range(N):
  li.append(x[i+1]-x[i])
  
li.sort()
while len(li) > 1:
  l = []
  div = li[0]
  for n in li:
    mod = n % div
    if mod != 0:
      l.append(mod)
  l.append(div)
  l.sort()
  li = l
print(*li)

Solution (Python):
import math

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

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

Solution (Python):
import math
from functools import reduce

n, k = map(int, input().split())
x = list(map(int, input().split()))
y = []

for i,X in enumerate(x):
    val = abs(X - k)
    y.append(val)

print(reduce(math.gcd, y))

Solution (Python):
import math
from functools import reduce

N, X = map(int, input().split())
x = list(map(int, input().split()))
x.append(X)
x.sort()
x = list(map(lambda n: n - x[0], x))
print(reduce(math.gcd, x[1:]))

Solution (Python):
import numpy as np
import bisect
def main():
    n,X = map(int,input().split())
    x = [int(i) for i in input().split()]
    index = bisect.bisect_left(x,X)
    x.insert(index,X)
    diff = []
    for i in range(1,n+1):
        diff.append(x[i]-x[i-1])
    diff = np.array(diff)
    ans = np.gcd.reduce(diff)
    print(ans)
main()

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

X_.append(X)
X_.sort()

X_diff=[]
for x_idx in range(1,len(X_)):
    x =X_[x_idx-1]
    x_=X_[x_idx]
    X_diff.append(x_-x)
    
import math
gcd_=X_diff[0]

for x_diff in  X_diff[1:]:
    gcd_=math.gcd(gcd_,x_diff)
    
print(gcd_)

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

x.append(m)
x = sorted(x)

dis = [0]*n
for i in range(n): dis[i] = x[i+1] - x[i]

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

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

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

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

print(a)

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n, x = map(int, input().split())
point = list(map(int, input().split()))
diff = [0] * n
for i in range(n):
    diff[i] = abs(point[i] - x)

def gcd(big, small):
    if small == 0:
        return big
    else:
        return gcd(small, big % small)

import functools

print(functools.reduce(gcd, diff))

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

x = list(map(int,input().split()))
lst = [0]*N
for i in range(len(x)):
    lst[i] = x[i] - X
   
a=0
for e in lst:
  a=fractions.gcd(a,e)
print(abs(a))

Solution (Python):

import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect

sys.setrecursionlimit(10**6)
def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
N,X = zz()
x = zz()

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

ans = distance[0]
for d in distance:
    ans = gcd(ans, d)
    
print(ans)

Solution (Python):
import sys
read = sys.stdin.read
from math import gcd
from bisect import bisect
def main():
    n, x, *a = map(int, read().split())
    if n == 1:
        print(abs(a[0] - x))
        sys.exit()
    a.sort()
    a2 = [x - y for x, y in zip(a[1:], a)]
    xpos = bisect(a, x)
    if xpos == 0:
        xd = a[0] - x
        a2.append(xd)
        a2.append(xd)
    elif xpos == n:
        xd = x - a[-1]
        a2.append(xd)
        a2.append(xd)
    else:
        xd1 = x - a[xpos - 1]
        xd2 = a[xpos] - x
        a2.append(xd1)
        a2.append(xd2)
    if len(a2) == 2:
        r = gcd(a[0], a[1])
        print(r)
        sys.exit()

    r = gcd(a2[0], a2[1])
    for i1 in range(2, n + 1):
        r = gcd(r, a2[i1])
    print(r)

if __name__ == '__main__':
    main()

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

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

s = 0

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

for i in A:
  s = gcd(abs(X-i), s)
  
print(s)

Solution (Python):
import math

def solve():
    arr = [0]*N
    ans = abs(start-x[0])
    for i in range(1,N):
        arr[i] = (abs(start-x[i]))
        ans = math.gcd(arr[i], ans)
    print(ans)
        
if __name__=="__main__":
    N,start = list(map(int, input().split()))
    x = list(map(int, input().split()))
    solve()

Solution (Python):


import math

import itertools
from collections import deque
from collections import Counter




n,x0=map(int,input().split())
x=list(map(int,input().split()))
x.append(x0)
x.sort()
d=[0]*n
for i in range(n):
    d[i]=x[i+1]-x[i]
res=d[0]
for i in range(1,n):
    res=math.gcd(res,d[i])
print(res)

Solution (Python):
n, X = map(int, input().split())
x = list(map(int, input().split()))
x.append(X)
def euclid(a,b):
    if a % b == 0:
        return b
    else:
        return euclid(b, a%b)

now = abs(x[0] -x[1])
for i in range(1, len(x)-2):
    r = euclid(now, abs(x[i] - x[i+1]))
    if r < now:
        now = r
r = euclid(now, abs(x[0] - x[-1]))
if r < now:
    now = r
print(now)

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



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


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






nums = [abs(X - xk) for xk in x]
ans = gcd_list(nums)
print(ans)

Solution (Python):
import bisect,collections,copy,heapq,itertools,math,string
import sys
def li(): return map(int,sys.stdin.readline().rstrip().split())
def lf(): return map(float,sys.stdin.readline().rstrip().split())
def ls(): return sys.stdin.readline().rstrip().split()

n, x = li()
p = list(li())
gcd = abs(x-p[0])
for i in range(n):
    gcd = math.gcd(gcd, abs(x-p[i]))

print(gcd)

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

Solution (Python):
import sys
from math import gcd

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    N, X = in_nn()
    x = in_nl()
    x += [X]
    x.sort()

    diff = [0] * N
    for i in range(N):
        diff[i] = x[i + 1] - x[i]

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

    print(ans)


if __name__ == '__main__':
    main()

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

Solution (Python):
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt, gcd
from copy import deepcopy
from functools import reduce


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

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

    
    list_s = []
    for i in range(n):
        list_s.append(abs(x_list[i]-x))
        
    ans = gcd_list(list_s)
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):


import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))



def a_int(): return int(read())


def ints(): return list(map(int, read().split()))


from functools import reduce
from math import gcd

N, zero = ints()
X = [abs(x - zero) for x in ints()]


print(reduce(gcd, X))

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

import numpy as np
import fractions

a = list(set(abs(np.array(x_list) - X)))
ans = a[0]
for i in range(1, len(a)):
    ans = fractions.gcd(ans, a[i])
print(ans)

Solution (Python):
from math import gcd
N,X = map(int,input().split())
g = None
for x in map(int,input().split()):
    if g == None:
        g = x-X
    else:
        g = gcd(g,x-X)
print(abs(g))

Solution (Python):
import math
from functools import reduce


def gcd_list(l):
    return reduce(math.gcd, l)


def solve():
    N, X = map(int, input().split())
    x = map(int, input().split())
    xX = [abs(X - i) for i in x]
    print(gcd_list(xX))


if __name__ == '__main__':
    solve()

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

N, X = list(map(int, input().split()))
 
x = list(map(int, input().split()))
x.append(X)
x.sort()
 
res = [abs(x[i+1]-x[i]) for i in range(len(x)-1)]
print(gcd(*res))

Solution (Python):
from math import*
N,x=map(int,input().split())
*X,=map(int,input().split())
ans=abs(X[0]-x)
now=X[0]
for i in X[1:]:
    ans=gcd(ans,abs(i-now))
    now=i

print(ans)

Solution (Python):

import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd,numbers)

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

x.append(X)
x.sort()

kosa = []

for i in range(1,n+1):
    k = (x[i]-x[i-1])
    kosa.append(k)
    
print(gcd(*kosa))

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


if __name__ == '__main__':
    n, x = map(int, input().split())
    X = list(map(int, input().split()))

    X = sorted(X)

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

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

    ans = 0
    if (len(diff) == 1):
        print(diff[0])
        exit()
    else:
        ans = gcd(diff[0], diff[1])
        for i in range(2, len(diff)):
            ans = gcd(ans, diff[i])

        print(ans)

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


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

ans = 0
for xx in x:
    ans = gcd(ans, abs(X - xx))

print(ans)

Solution (Python):

import numpy as np

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

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

s.append(x)

s.sort()

l = set([])

for i in range(len(s)-1):
    l.add(s[i+1]-s[i])
    
l = list(l)
    
print(np.gcd.reduce(l))

Solution (Python):
import math


def main():
    n, s = map(int, input().split())
    xs = sorted(list(map(int, input().split())))

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

    for i in range(1, n):
        xs[i] = math.gcd(xs[i], xs[i-1])

    print(xs[n-1])


if __name__ == "__main__":
    main()

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

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

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

import math
for i in range(1,n):
  x[i] = math.gcd(x[i],x[i-1])

print(x[n-1])

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import math
from functools import reduce

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

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


n, s = map(int, readline().split())
x = [v-s for v in list(map(int, readline().split()))]

print(abs(gcd(*x)))

Solution (Python):
import math
from functools import reduce

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

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

N,X=map(int,input().split())
A=list(map(int,input().split()))
B=[abs(a-X) for a in A]
print(gcd(*B))

Solution (Python):
import math
n,x=map(int,input().split())
l=list(map(int,input().split()))
d=abs(l[0]-x)
for m in l:
  d2=math.gcd(d,abs(m-x))
  d=min(d,d2)
print(d)

Solution (Python):
import numpy as np
import math
from functools import reduce
N,X,*x = map(int,open(0).read().split())
print(reduce(math.gcd,abs(X - np.array(sorted(x)))))

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

N,X,*x = map(int,open(0).read().split())
x.sort()
nx = np.array(x)
dif_nx = abs(X - nx)
print(reduce(math.gcd,dif_nx))

Solution (Python):
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 998244353






N, X = getNM()
A = getList()

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

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

Solution (Python):
from math import gcd
n, x = map(int, input().split())
city = list(map(int, input().split()))
if x not in city:
    city.append(x)
city.sort(reverse=True)
for i in range(len(city) - 1):
    city[i] -= city[i + 1]
ans = city[0]
for i in range(len(city) - 1):
    ans = gcd(ans, city[i])
print(ans)

Solution (Python):
import math

n, x = map(int, input().split())
X = sorted(list(map(int, input().split())))
dis = [0] * (n-1)

xdis = 0
for i in range(n-1):
    dis[i] = X[i+1] - X[i]
    if X[i] <= x <= X[i+1]:
        xdis = min(abs(x-X[i]), abs(X[i+1]-x))

if n == 1:
    print(abs(X[0]-x))
    exit()
        
reg = xdis

for i in range(n-1):
    reg = math.gcd(reg, dis[i])

print(reg)