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):
from fractions import gcd
n,x=map(int,input().split())
X=list(map(int,input().split()))
res=abs(X[0]-x)

for y in X:
	res=gcd(res,abs(y-x))
	
print(res)

Solution (Python):

import fractions
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n,x = iim()
xmod = list(map(lambda y:abs(int(y)-x),input().split()))

gcd = xmod[0]
for i in xmod:
    gcd = fractions.gcd(gcd,i)

print(gcd)

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

Solution (Python):

import sys
import numpy as np
from fractions import gcd

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, X0 = lr()
X = np.array(lr())
Xdiff = np.abs((X-X0)).tolist()
g = Xdiff[0]
for i in range(1, N):
    g = gcd(g, Xdiff[i])

answer = g
print(answer)

Solution (Python):
import numpy as np
from fractions import gcd
from functools import reduce
N, x = map(int, input().split())
X = np.array(list(map(int, input().split())) + [x], dtype=np.int32)
X.sort()
X -= X[0]
print(reduce(gcd, X))

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

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

N, X = map(int, input().split())
x = np.array(list(map(int, input().split())))
if N == 1:
    print(np.abs(x[0] - X))
else:
    x = np.abs(x - X)
    print(gcd(x))

Solution (Python):


import sys



















from fractions import gcd                    


def main():
    mod = 1000000007                
    inf = float('inf')              
    
    sys.setrecursionlimit(10**6)    
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    n, x = mi()
    L = list(map(lambda point: abs(int(point) - x), input().split()))
    g = L[0]
    for i in range(1, n):
        g = gcd(g, L[i])
    print(g)




if __name__ == "__main__":
    main()

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

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

lis=[]
for i in range(0,n):
  lis.append(abs(x[i]-k))

def gcd(a,b):
  aa=max(a,b)
  bb=min(a,b)
  cc=aa%bb
  aa=bb
  bb=cc
  if bb!=0:
    return gcd(aa,bb)
  else:
    return aa

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

Solution (Python):

from fractions import gcd
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)
ans = reduce(gcd, x)
print(ans)

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

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

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

p = [abs(n - X) for n in x]

print(reduce(gcd, p))

Solution (Python):
n,start=map(int,input().split())
town=list(map(int,input().split()))

kyori=[]

for item in town:
    kyori.append(abs(item-start))
import fractions
temp=kyori[0]

for item in kyori:
    temp=fractions.gcd(item, temp)

print(temp)

Solution (Python):
from fractions import gcd

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

temp_list = [abs(num - x) for num in x_list]

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

Solution (Python):
N, X = map(int, input().split())
A = list(map(int, input().split()))
A.append(X)
A.sort()
distances = {}

for i in range(N):
    dist = A[i+1] - A[i]
    distances[dist] = None

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

distances = list(distances.keys())
gcd_calc = distances[0]

if N > 1:
    for dist in distances[1:]:
        gcd_calc = gcd(gcd_calc, dist)
        
        

print(gcd_calc)

Solution (Python):
N, X = map(int, input().split())
A = list(map(int, input().split()))
A.append(X)
A.sort()
distances = {}

for i in range(N):
    dist = A[i+1] - A[i]
    distances[dist] = None

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

distances = list(distances.keys())
gcd_calc = distances[0]

if N > 1:
    for dist in distances[1:]:
        gcd_calc = gcd(gcd_calc, dist)
        if gcd_calc == 1:
            break

print(gcd_calc)

Solution (Python):
from fractions import gcd

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

sub = []

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

max = sub[0]

for i in range(1,N):
    max = gcd(max, sub[i])

print(max)

Solution (Python):
import functools
import fractions
N,S = map(int,input().split())
x = list(map(int,input().split()))
D = [0]*N
D[0] = S-x[0]

for i in range(1,N):
  D[i] = x[i] - x[i-1]
ddd=functools.reduce(fractions.gcd, D)
if ddd < 0:
  ddd *= -1
print(ddd)

Solution (Python):


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

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




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

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

print(res)

Solution (Python):
mod = 1000000007
eps = 10**-9


def main():
    import sys
    from fractions import gcd
    input = sys.stdin.readline

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

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


if __name__ == '__main__':
    main()

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

_, X = map(int, input().split())
print(reduce(gcd, (abs(X - i) for i in map(int, input().split()))))

Solution (Python):
from fractions import gcd


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

Solution (Python):
import fractions

N, X = map(int, input().split(" "))
X = [X]
X.extend(map(int, input().split(" ")))
X.sort()
ans = X[1] - X[0]
for i in range(1, len(X) - 1):
    ans = fractions.gcd(ans, X[i + 1] - X[i])
print(ans)

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

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


def main():
    n, x = input_list()
    a = input_list()
    a.append(x)
    sa = list(sorted(a))
    kukan = []
    for i, v in enumerate(sa):
        if i+1 > len(sa)-1:
            break
        d = sa[i+1] - v
        kukan.append(d)
    print(gcd_list(kukan))


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

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

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

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

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

if __name__ == "__main__":
    main()

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

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

Solution (Python):
import fractions

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

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

print(ans)

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

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):
import sys
import os

import bisect
import collections
import itertools
from fractions import gcd

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]



MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, X = il()
    T = il()
    T = sorted(T + [X])
    ret = abs(T[0] - T[1])
    for i in range(len(T)-1):
        ret = gcd(ret, abs(T[i]-T[i+1]))
    print(ret)


if __name__ == '__main__':
    main()

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

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

print(ans)

Solution (Python):
n,x = map(int,input().split())
c = list(map(int,input().split()))
def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)
c.append(x)
c.sort()
g = c[1]-c[0]
for i in range(1,n):
    g = gcd(g,c[i+1]-c[i])
print(g)

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

distances = [abs(i - X) for i in target]

def GCD(x,y):
    if y == 0:
        return x
    else:
        return GCD(y, x % y)
res = 0
for d in distances:
    res = GCD(res, d)
print(res)

Solution (Python):
import numpy as np

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



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

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

Solution (Python):
from fractions import gcd
from functools import reduce
n,x=list(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):
import fractions

n,x=list(map(int,input().split()))
X=list(map(int,input().split()))
X.append(x)
X=sorted(X)
Y=[X[i+1]-X[i] for i in range(n)]

if n==1:
  print(max(X)-min(X))
  
else:
  gcd=fractions.gcd(Y[0],Y[1])
  for i in range(2,n):
    gcd=fractions.gcd(gcd,Y[i])
  print(gcd)

Solution (Python):
import fractions


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

A.append(X)
A.sort()

diff = []
for a,b in zip(A, A[1:]):
    diff.append(b-a)

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


print(ans)

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

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

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

print(a)

Solution (Python):
from functools import reduce


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


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

Solution (Python):
N, X = map(int, input().split())
x = list(map(lambda x:abs(int(x)-X), input().split()))
def gcd_base(a, b):
    while b!=0:
        a, b = b, a%b
    return a

def gcd(num_list):
    ans = 0
    for i in num_list:
        ans = gcd_base(ans, i)
    return ans

print(gcd(x))

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

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

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

Solution (Python):
from fractions import gcd
n, X = map(int, input().split())
x = sorted([int(i) for i in input().split()] + [X])
diff_x = [x[i + 1] - x[i] for i in range(n)]
if len(diff_x) == 1:
    print(diff_x[0])
else:
    d = gcd(diff_x[0], diff_x[1])
    for i in range(2, n):
        d = gcd(d, diff_x[i])
    print(d)

Solution (Python):


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

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

ans = abs(x - nums[0])
for num in nums:
    d = abs(x - num)
    ans = gcd(d, ans)
print(ans)

Solution (Python):
N,M = map(int,input().split())
l_n = list(map(int,input().split()))
l_n.append(M)
l_n.sort()
l_a = []
l_s = []
for i in range(N):
    l_a.append(l_n[i+1]-l_n[i])
min_number = l_a[0]
n_list = []
for i in range(1,int(min_number**0.5)+1):
    if min_number % i == 0:
        if i == min_number // i:
            pass
        else:
            n_list.append(min_number // i)
        n_list.append(i)
n_list.sort(reverse=True)
for i in n_list:
    if [j for j in l_a if j % i != 0] == []:
        print(i)
        exit()

Solution (Python):

import sys


def solve(N: int, X: int, x: "List[int]"):
    from fractions import gcd
    from functools import reduce
    return reduce(gcd, [abs(xx-X) for xx in x])



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)]  
    print(solve(N, X, x))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    
    main()

Solution (Python):

import sys


def solve(N: int, X: int, x: "List[int]"):
    from fractions import gcd
    from functools import reduce
    Y = sorted(x+[X])
    Z = [x2-x1 for x1, x2 in zip(Y, Y[1:])]
    return reduce(gcd, Z)



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)]  
    print(solve(N, X, x))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    
    main()

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 x[1:]:
    ans = gcd(ans, abs(i-X))
print(ans)

Solution (Python):

from functools import reduce
import sys
try:
    from typing import List
except ImportError:
    pass


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


def solve(N: int, X: int, x: "List[int]"):
    x2 = [abs(xi - X) for xi in x]
    print(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):
import math
from functools import reduce
import fractions


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


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


N, X = map(int, input().split())
x = list(map(int, input().split()))
dif = [abs(X - x[0])]

if N > 1:
    for i in range(N - 1):
        dif.append(x[i + 1] - x[i])
print(abs(gcd_list(dif)))

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

Solution (Python):

from functools import reduce
from fractions import gcd


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

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

print(reduce(gcd, x))

Solution (Python):
import fractions
def main():
    N, St = map(int, input().split())
    X = [int(a) for a in input().split()]
    X.append(St)
    X.sort()

    D = list()
    for i in range(len(X)-1):
      d = X[i+1] - X[i]
      D.append(d)
    ans = D[0]

    for i in range(1, len(D)):
        ans = fractions.gcd(ans, D[i])
    
    print(ans)
    
if __name__ == "__main__":
    main()

Solution (Python):
import fractions

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

Solution (Python):
n,x = map(int,input().split())
x_list = list(map(int,input().split()))
x_list.append(x)
x_list.sort()
sa_list = []
for i in range(1,n+1):
  sa = x_list[i] - x_list[i-1]
  sa_list.append(sa)
from fractions import gcd
from functools import reduce
def gcd_list(numbers):
    return reduce(gcd, numbers)

print(gcd_list(sa_list))

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

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

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



ans = city[0]

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

print(ans)

Solution (Python):
import fractions
from functools import reduce

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

def myAnswer(N:int,X:int,x:list) -> int:
   ans = []
   for a in x:
      ans.append(abs(a-X))
   return gcd_list(ans)

def modelAnswer():
   return
def main():
   N,X = map(int,input().split())
   x = list(map(int,input().split()))
   print(myAnswer(N,X,x[:]))
if __name__ == '__main__':
   main()

Solution (Python):
import functools
import fractions

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

a.append(x)
a.sort()

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

gcd = functools.reduce(fractions.gcd, a)
print(gcd)

Solution (Python):

from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd



def I(): return int(input())


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


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


show_flg = False


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


def gcd_n(a, n):
    ans = a[0]
    for i in range(1, n):
        ans = gcd(ans, a[i])
    return ans


def main():
    N, X = MI()
    x = LI()
    x.append(X)
    x.sort()
    d = []

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

    print(gcd_n(d, len(d)))


if __name__ == '__main__':
    main()

Solution (Python):









import numpy as np





from fractions import gcd

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

while len(arrA)>1:
    a = arrA.pop()
    b = arrA.pop()
    c = gcd(a,b)
    arrA.append(c)

ans = arrA[0]
print(ans)

Solution (Python):
import fractions
from functools import reduce
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
N,X=map(int,input().split())
x=list(map(int,input().split()))
for i in range(N):
  if x[i]>X:
    x[i]=x[i]-X
  elif x[i]<X:
    x[i]=X-x[i]
  else:
    del x[i]
n=gcd_list(x)
print(n)

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

def hoge():
    global n,x,X
    ret=abs(X-x[0])
    for i in range(1,n):
        ret=gcd(abs(X-x[i]),ret)
    return ret

print(hoge())

Solution (Python):
import fractions

def gcd_list(a):
    ans = a[0]
    for i in range(1, N):
        ans = fractions.gcd(ans, a[i])
    return ans

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

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

print(gcd_list(dl))

Solution (Python):
import fractions

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


minimum = x[0]
for i in range(len(x)):
    x[i] = x[i] - X
    minimum = min(x[i], minimum)


gcd_value = fractions.gcd(x[0], x[0])
for i in range(len(x)):
    gcd_value = abs(fractions.gcd(gcd_value, x[i]))
    
print(gcd_value)

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

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

Solution (Python):
import fractions
n,x = map(int,input().split())
s = set(map(int,input().split()))
s.add(x)
l = list(s)
l.sort()
for i in range(len(l)-1):
  if i == 0:
    y = l[1]-l[0]
  else:
    y = fractions.gcd(l[i+1]-l[i],y)
print(y)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, X = MAP()
x = LIST()

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

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

print(ans)

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


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

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

x_list.sort()

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


print(gcd_list(tmp))

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

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

print(reduce(lambda a,b:fractions.gcd(a,b),list1,list1[0]))

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):
def gcd(a, b):
    big = max(a, b)
    small = min(a, b)
    if small == 0:
        return big
    
    r = small
    while r != 0:
        r = big % small
        big = small
        small = r
        
    return big
   
N, X, *x = map(int, open(0).read().split())

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

Solution (Python):
def ABC162C(a,b):
    while b != 0:
        a %= b
        if a == 0:break
        b %= a
    return max(a,b)

n,*x=map(int,open(0).read().split())
p=abs(x[-1]-x[-2])
for i in range(n):
    p=ABC162C(abs(x[i]-x[i+1]),p)
print(p)

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

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

Solution (Python):

















mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    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)
if __name__ == '__main__':
  main()

Solution (Python):
import fractions

n,x=map(int,input().split())
X=list(map(int,input().split()))
A=[]
for i in range(n):
    if X[i]!=x:
        A.append(abs(X[i]-x))
g=A[0]
for i in range(n):
    g=fractions.gcd(g,A[i])
print(g)

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

ls_x = [abs(l - X) for l in ls]

import fractions

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

Solution (Python):
from fractions import gcd

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

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

Solution (Python):
from fractions import gcd

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

if N == 1:
    ans = abs(X-next(x))
else:
    ans = gcd(abs(X-next(x)), abs(X-next(x)))
    for i in x:
        ans = gcd(ans, abs(X-i))
print(ans)

Solution (Python):
def main():
    import fractions
    n,x=map(int, input().split())
    xn=list(map(int, input().split()))
    xn.append(x)
    xn.sort()
    for i in range(n):
        buf=xn[i+1]-xn[i]
        if i==0:
            d=buf
        else:
            d=fractions.gcd(d,buf)
    print(d)

if __name__=='__main__':
    main()

Solution (Python):



import fractions
import math
import io

nim, mike = map(int, input().split())
are1 = list(map(int, input().split()))
are2, result = [abs(x - mike) for x in are1], 0

for i in are2:
    result = fractions.gcd(result, i)
print(result)

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

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

print(reduce(gcd, S))

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

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

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

def main():
    N, X = map(int, readline().rstrip().split())
    x = list(map(int, readline().rstrip().split()))
    x = [abs(e-X) for e in x]
    
    if N == 1:
        print(x[0])
        return
    
    g = gcd(x[0], x[1])
    if N == 2:
        print(g)
        return

    for e in x[2:]:
        g = gcd(g, e)
    
    print(g)  


if __name__ == '__main__':
    main()

Solution (Python):
import fractions
def main():
    n, X = map(int,input().split())
    x = list(map(int,input().split()))
    sub = []
    min_s = 0
    for i, xx in enumerate(x):
        sub.append(abs(xx-X))

    min_s = min(sub)
    ans = 1
    flg = True
    s = list(set(sub))
    if X == 1:
        print(sub[0])
        return
    ans = s[0]
    for i, ss in enumerate(s):
        if i == 0:
            continue
        ans = fractions.gcd(ans,ss)

    print(ans)



if __name__ =='__main__':
    main()

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

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

import fractions

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

print(ans)

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

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

sys.setrecursionlimit(10 ** 6)


def input(): return sys.stdin.readline().rstrip()

N, X = map(int, input().split())
x = list(map(int, input().split()))
d = [abs(i - X) for i in x]
print(reduce(lambda i, j: gcd(i, j), d))

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

ls = []

for i in range(n):
    ls.append(abs(x - x_list[i]))

ret = ls[0]

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

print(ret)

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

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

nx = list(map(lambda a: abs(a - X),x))
g = reduce(gcd,nx)

print(g)