Problem:
 Score : 300 points    Problem Statement There are N cities on a number line. The i -th city is located at coordinate x_i .  Your objective is to visit all these cities at least once.  In order to do so, you will first set a positive integer D .  Then, you will depart from coordinate X and perform Move 1 and Move 2 below, as many times as you like:   Move 1 : travel from coordinate y to coordinate y + D .  Move 2 : travel from coordinate y to coordinate y - D .   Find the maximum value of D that enables you to visit all the cities.  Here, to visit a city is to travel to the coordinate where that city is located.      Constraints  All values in input are integers.  1 \leq N \leq 10^5  1 \leq X \leq 10^9  1 \leq x_i \leq 10^9  x_i are all different.  x_1, x_2, ..., x_N \neq X         Input Input is given from Standard Input in the following format:  N  X  x_1  x_2  ...  x_N       Output Print the maximum value of D that enables you to visit all the cities.        Sample Input 1 3 3
1 7 11      Sample Output 1 2  Setting D = 2 enables you to visit all the cities as follows, and this is the maximum value of such D .   Perform Move 2 to travel to coordinate 1 .  Perform Move 1 to travel to coordinate 3 .  Perform Move 1 to travel to coordinate 5 .  Perform Move 1 to travel to coordinate 7 .  Perform Move 1 to travel to coordinate 9 .  Perform Move 1 to travel to coordinate 11 .        Sample Input 2 3 81
33 105 57      Sample Output 2 24       Sample Input 3 1 1
1000000000      Sample Output 3 999999999

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

xlist.sort()
diclist = [xlist[i+1] - xlist[i] for i in range(N)]


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

if N > 1:
    a = gcd(diclist[0], diclist[1])
    for i in range(N-2):
        a = gcd(a, diclist[i+2])
    print(a)

else:
    print(diclist[0])

Solution (Python):
n,x = map(int,input().split())
xl = list(map(int,input().split()))
a = [abs(i-x) for i in xl]
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)
ans = a[0]
for i in a:
    ans = gcd(ans,i)
print(ans)

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

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

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

Solution (Python):
import fractions
from functools import reduce


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


N, X = [int(i) for i in input().split()]
xs = [int(i) for i in input().split()]
diff = [abs(x - X) for x in xs]
print(gcd(*diff))

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


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


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

ad = [abs(ai - x) for ai in a]

print(gcdm(ad))

Solution (Python):
import fractions

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

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

distance_to_x0 = abs(X-x[0])
distance_to_x1 = abs(X-x[1])
candidate = fractions.gcd(distance_to_x0, distance_to_x1)

for x_i in x:
    distance = abs(X-x_i)
    candidate = fractions.gcd(candidate, distance)

print(candidate)

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


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


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


print(abs(g))

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

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

t=[int(j)-x for j in input().split()]
ans=abs(t.pop())
for i in t:
    ans=gcd(ans,i)

print(ans)

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

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

if N == 1:
    print (abs(X-lst[0]))
    sys.exit()

lst += [X]

lst2 = []
for i in range(N):
    lst2 += [abs(lst[i]-lst[i+1])]


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

A = lst2[0]
B = lst2[1]
C = gcd(A, B)
for i in range(2, N):
    C = gcd(C, lst2[i])

print (C)

Solution (Python):
n, x = map(int, input().split())
city = sorted(map(int, input().split()))
ans = abs(x - city[0])
if n > 1:
    dis = [city[i + 1] - city[i] for i in range(n - 1)]
    def gcd(a, b):
        if b == 0:
            return a
        return gcd(b, a%b)

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

Solution (Python):
from fractions import gcd

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

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

Solution (Python):
def gcd(x,y):
    if y>x:
        a=y
        y=x
        x=a
    while y:
        a=x%y
        x=y
        y=a
    return x

a,b=map(int,input().split())
c=list(map(int,input().split()))
c.append(b)
c.sort()
for i in range(a):
    c[-1-i]-=c[-2-i]
b=0
for i in range(a):
    b=gcd(c[i+1],b)
print(b)

Solution (Python):
def gcd(x,y):
    if y>x:
        a=y
        y=x
        x=a
    a=1
    while a*y:
        a=x%y
        x=y
        y=a
    return x

a,b=map(int,input().split())
c=list(map(int,input().split()))
c.append(b)
c.sort()
for i in range(a):
    c[-1-i]-=c[-2-i]
b=0
for i in range(a):
    b=gcd(c[i+1],b)
print(b)

Solution (Python):
n,x=map(int,input().split())
l=list(map(lambda m:abs(int(m)-x),input().split()))
def gcd(x, y):
    if x<y:x,y=y,x
    while x % y != 0:
        x, y = y, x % y
    return y
ans=l[0]
for i in range(1,n):
    ans=gcd(ans,l[i])
print(ans)

Solution (Python):


from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy


mod = 1


def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


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


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


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


def combination(x, y):
    assert(x >= y)

    if y > x // 2:
        y = x - y

    ret = 1

    for i in range(0, y):
        j = x - i
        i = i + 1

        ret = ret * j
        ret = ret // i

    return ret


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    retlist.append(x)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance





def main():
    N, X = intin()
    xlist = intina()

    x_relative_list = [x - X for x in xlist]

    ans = None
    for xr in x_relative_list:
        xr = abs(xr)
        if ans is None:
            ans = xr
            continue
        ans = lcm(ans, xr)

    print(ans)


if __name__ == '__main__':
    main()

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


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

Solution (Python):
def gcd(l):
    if len(l) == 1:
        return l[0]

    v = gcd2(l[0], l[1])
    for i in range(2, n):
        v = gcd2(v, l[i])

    return v


def gcd2(a, b):
    if b == 0:
        return a

    return gcd2(b, a % b)


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

x = [abs(xi - s) for xi in x]
print(gcd(x))

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

Solution (Python):
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

N,X = inpl()
xx = inpl()

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

xx.append(X)
xx.sort()
li = []
for i in range(1,N+1):
    li.append(xx[i]-xx[i-1])

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

print(ans)

Solution (Python):
from fractions import gcd


def liner_search(n, l):
    for i in range(len(l)):
        if n < l[i]:
            return i
    return len(l)


N, X = map(int, input().split())
x = sorted(list(map(int, input().split())))
x.insert(liner_search(X, x), X)
sabun = [None] * N
for i in range(1, len(x)):
    sabun[i - 1] = x[i] - x[i - 1]
res = gcd(0, sabun[0])
for i in range(1, len(sabun)):
    res = gcd(res, sabun[i])
print(res)

Solution (Python):
n, x = map(int, input().split())
ds = [abs(int(y) - x) for y in input().split()]
def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(b, a % b)
res = max(ds) 
for d in ds:
  res = gcd(res, d)
print(res)

Solution (Python):
from bisect import insort_left
from fractions import gcd
N,X=[int(a) for a in input().split(" ")]
xs = sorted([int(a) for a in input().split(" ")])
insort_left(xs, X)
intervals = [a-b for a, b in zip(xs[1:],xs[:-1])]
curr = intervals[0]
for i in intervals:
    curr = gcd(curr, i)
print(curr)

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

import numpy as np

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

x = np.abs(x)

M = x[0]
from fractions import gcd

for i in x[1:]:
  M = gcd(M, i)

print(M)

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

Solution (Python):
n,x = map(int,input().split())
lista = [int(i) for i in input().split()]
lista.append(x)
lista.sort()
def gcd(a,b):
    if a<b:
        a,b = b,a
    if a%b==0:
        return b
    else:
        return gcd(b,a%b)

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

print(ans)

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

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

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

x.append(X)
x.sort()
a=x[1]-x[0]
for i in range(1,len(x)-1):
    a=fractions.gcd(a,x[i+1]-x[i])
print(a)

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

import numpy as np
X_abs = abs(np.array(x)-X)

import fractions

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

Solution (Python):
import fractions
from functools import reduce

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

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

print(gcd(D))

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

distances = [0 for _ in range(N)]
for i in range(N):
    distances[i] = abs(X-City[i])

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

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

print(ans)

Solution (Python):

def Koyakusu(x, y):
    max = x if x > y else y
    min = x if x < y else y

    while max % min != 0:
        tmp = max % min
        max = min
        min = tmp
    
    return min


def maxKoyakusu(array):
    ans = array[0]
    for i in range(1, len(array)):
        ans = Koyakusu(ans, array[i])

    return ans


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

print(maxKoyakusu(a))

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

import math
N,X = list(map(int,input().split(" ")))
xs = list(map(int,input().split(" ")))
xs = list(map(lambda x:abs(x-X),xs))
gcds = [xs[0]]
for i,x in enumerate(xs[1:]):
    gcds.append(GCD(gcds[i],x))
print(gcds[-1])

Solution (Python):
import numpy as np
from copy import deepcopy
import math
import itertools
from collections import Counter
from functools import reduce
from fractions import gcd


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


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

distance = [X[i]-P for i in range(N)]

ans = gcd_list(distance)
print(abs(ans))

Solution (Python):
import numpy as np
import fractions

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

D= result[0]
for i in range (1,len(result)):
    D=fractions.gcd(D,result[i])
print(D)

Solution (Python):
import fractions
from functools import reduce
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):
  x[i] = abs(x[i] - X)

print(gcd_list(x))

Solution (Python):
input_int = lambda:int(input())
input_ints = lambda:map(int,input().split())
input_str = lambda:input()
input_strs = lambda:input().split()
input_lines = lambda n,f:[f() for _ in range(n)]

import functools,fractions
gcd = lambda a:functools.reduce(fractions.gcd,a)

def solution():
    N,X = input_ints()
    Xs = input_ints()

    diffs = [abs(X-int(x)) for x in Xs]
    ans = gcd(diffs)
    print(ans)

if __name__ == '__main__':
    solution()

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


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

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

if N > 1:
    g = gcd(A[0], A[1])
else:
    g = A[0]

for i in A:
    g = gcd(g, i)

print(g)

Solution (Python):

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

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

G = l[0]
for x in l[1:]:
    G = gcd(G, x)
print(G)

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

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

print(functools.reduce(gcd,diff_x))

Solution (Python):
import fractions

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

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

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

Solution (Python):
from fractions import gcd

n, start  = map(int, (input().split()))
x = list(map(int, (input().split())))
x.append(start)
sorted_x = sorted(x)

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

print(ans)

Solution (Python):
N, X = list(map(int, input().split()))
x = list(map(int, input().split()))
x.sort()
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

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

print(ans)

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


def f(st):
    xs = list(map(int, input().split()))
    sa = [abs(x - st) for x in xs]
    G = sa[0]
    for sk in sa:
        G = gcd(G, sk)
    print(G)


n, st = map(int, input().split())
f(st)

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

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

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


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

    
print(tmp)

Solution (Python):
input_int = lambda:int(input())
input_ints = lambda:map(int,input().split())
input_str = lambda:input()
input_strs = lambda:input().split()
input_lines = lambda n,f:[f() for _ in range(n)]

import functools,fractions
gcd = lambda a:functools.reduce(fractions.gcd,a)

def solution():
    N,X = input_ints()
    Xs = input_ints()

    diffs = [abs(X-int(x)) for x in Xs]
    ans = gcd(diffs)
    print(ans)

if __name__ == '__main__':
    solution()

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

Solution (Python):

import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, X: int, x: "List[int]"):
    return reduce(gcd, [abs(X - xx) 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) ]  
    result = solve(N, X, x)
    print(result)

if __name__ == '__main__':
    main()

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

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

dx = [x[i+1]-x[i] for i in range(len(x)-1)]
now = dx[0]
for i in range(1,len(dx)):
  now = gcd(now, dx[i])
print(now)

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)

new_X = []
for x in X:
    new_X.append(abs(S-x))

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

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

Solution (Python):
import fractions

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

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

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

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


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

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

Solution (Python):
from fractions import gcd

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

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

ans=0
for x_d in diff:
       ans = gcd(ans,x_d)
print(ans)

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

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

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

tmp = 1
for i in range(len(x)-1):
    x[i+1] = f(x[i], x[i+1])

print(x[len(x)-1])

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

A = sorted(map(lambda x:x - X,x))

while N > 1:
    a = A[0]
    b = A[1] % a
    if b == 0:
        A.pop(1)
        N -= 1
    else:
        A[1] = a
        A[0] = b

print(abs(A[0]))

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


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

Solution (Python):
N,X = map(int,input().split())
x = list(map(int,input().split()))
x += [X]
x.sort()
N = N+1
def GCD(x,y):
    c = x%y
    if c == 0:
        return y
    else:
        return GCD(y,c)
    
xdif = [0] * (N-1)
for i in range(1,N):
    xdif[i-1] = x[i]-x[i-1]
    if i == 1: 
        ans = xdif[i-1]
        continue
    ans = GCD(ans,xdif[i-1])
print(ans)

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

def algGCF(a,b):
  if a % b == 0:
    return b
  else:
    return algGCF(b,a%b)
GCF = abs(X-L[0])
for i in range(1,N):
  GCF = algGCF(GCF,abs(X-L[i]))
print(GCF)

Solution (Python):
from functools import reduce

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


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

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

print(abs(gcd_list(x)))

Solution (Python):

import fractions
n, start = list(map(int, input().split()))
x = list(map(int, input().split()))

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

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


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


ans = x_gcd[0]
for i in range(N):
    ans = gcd(ans, x_gcd[i])
if ans:
    print(ans)
else:
    print(x[0] - X)

Solution (Python):
import numpy as np
from fractions import gcd
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.append(x)
a = np.array(list(set(a)))
a.sort()
diff = a[1:] - a[:-1]


diff = list(diff)
tmp = diff[0]
for i in diff[1:]:
    tmp = gcd(tmp, i)
print(tmp)

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)


def kouyakusuu(kyori, num):
    ans = kyori[0]
    pre = kyori[0]
    for i in range(num - 1):
        now_point = kyori[i + 1]
        while now_point:
            pre, now_point = now_point, pre % now_point
        if pre < ans:
            ans = pre
        pre = kyori[i + 1]
    return ans


def main():
    num, start = map(int, input().split())
    data = list(map(int, input().split()))
    kyori = [0 for i in range(num)]

    for i in range(num):
        kyori[i] = abs(data[i] - start)

    ans = kouyakusuu(kyori, num)

    print(ans)





if __name__ == '__main__':
    main()

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

x_processed = list(set([abs(x - X) for x in x_list]))

x_processed.sort()

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

x1 = x_processed[0]
for x2 in x_processed[1:]:
    x1 = func(x2, x1)
    
print(x1)

Solution (Python):
import fractions

N, X = map(int, input().split())
cities = list(map(int, input().split()))
cities.append(X)
cities.sort()
distances = list(map(lambda x: cities[x + 1] - cities[x], range(len(cities) - 1)))
ans = distances[0]
for distance in distances:
    ans = fractions.gcd(ans, distance)
print(ans)

Solution (Python):
from numpy import*
from functools import*
from fractions import*
n,X,*x=map(int,open(0).read().split())
print(reduce(gcd,list(abs(array(x)-X))))

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

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

x.append(X)
sorted_x = sorted(x)
min_sorted_x = sorted_x[0]
dists = ([n - min_sorted_x for n in sorted_x])[1:]
print(reduce(gcd,dists))

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

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

print(ans)

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

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

new_x = []
for i in x:
    new_x.append(abs(i - X))

if len(x) == 1:
    print(new_x[0])
    exit()
else:
    for i, j in enumerate(new_x):
        if i == 0:
            res = gcd(new_x[0], new_x[1])
        else:
            res = gcd(res, new_x[i])

print(res)

Solution (Python):
from fractions import gcd

from math import sqrt
from math import ceil
from itertools import permutations
from heapq import *
from collections import defaultdict
from copy import deepcopy

from bisect import bisect_left as bl

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

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

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

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


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

ans = 0


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

for i in range(N):
    a.append(abs(x[i] - x[i+1]))
    ans = gcd(ans, a[i])


print(ans)

Solution (Python):
from functools import reduce
import fractions
n, x = list(map(int, input().split()))
x_li = list(map(int, input().split()))
x_li.append(x)
x_li.sort()
d = []
for i in range(n):
    d.append(x_li[i + 1] - x_li[i])


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


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


if len(d) > 1:
    print(gcd_list(d))
else:
    print(d[0])

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

if N==1:
    print(s[0])
else:
    r = gcd(s[0], s[1])
    if N==2:print(r)
    else:
        for i in range(2, N):
            r = gcd(r,s[i])
        print(r)

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

def f(m,n):
  if min(m,n)<0:
    return f(abs(m),abs(n))
  elif m<n:
    return f(n,m)
  elif m%n==0:
    return n
  else:
    return f(n,m%n)
ans=abs(X[0]-x)
for i in range(1,n):
  ans=f(ans,X[i]-x)
print(ans)

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

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

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


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


def list_lcm(number_list):
    lcm_number = 1
    for j in number_list:
        lcm_number = lcm(lcm_number, j)

    return lcm_number


def list_gcd(number_list):
    gcd_number = number_list[0]
    for i in number_list:
        gcd_number = gcd(gcd_number, i)

    return gcd_number


if __name__ == '__main__':
    n, x = map(int, input().split())
    x_list = list(map(int, input().split()))
    x_list.append(x)
    x_min = min(x_list)
    for i in range(len(x_list)):
        x_list[i] -= x_min
    print(list_gcd(x_list))

Solution (Python):

import sys

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

def solve(N: int, X: int, x: "List[int]"):
    dis = []
    for a in x:
        dis.append(abs(X - a))
    ret = dis[0]
    for i in range(1, len(dis)):
        ret = gcd(ret, dis[i])
    print(ret)
    return


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):
n,x=map(int,input().split())
m=list(map(lambda y:int(y)-x,input().split()))
if 0 in m:
  m.remove(0)
ans=abs(m[0])
for i in m:
  i=abs(i)
  while 1:
    ans%=i
    ans,i=i,ans
    if i==0:
      break
print(ans)

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

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

x.append(a)
x.sort()

diff_all = []
for i in range(len(x) - 1):
    diff_all.append(abs(x[i] - x[i+1]))

import fractions
from functools import reduce

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

print(gcd_list(diff_all))

Solution (Python):

from functools import reduce
from fractions import gcd    

N, X = map(int, input().split())
x = list(map(int, input().split()))
res = [abs(x[i] - X) for i in range(N)]
print(reduce(gcd, res))