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 bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

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

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


N, X0 = list(map(int, sys.stdin.buffer.readline().split()))
X = list(map(int, sys.stdin.buffer.readline().split()))
X = np.array(X, dtype=int) - X0
X = np.abs(X)

ans = reduce(gcd, X)
print(ans)

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

D = []
for x in xs: D.append(abs(X-x))

from fractions import gcd
from functools import reduce
g = reduce(gcd, D)
print(g)

Solution (Python):
import fractions
from functools import reduce
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)
n,x = map(int,input().split())
xs = list(map(int,input().split()))
xt = []
for i in xs:
    xt.append(i - x)
    
if n == 1:
    ans = xt[0]
else:
    ans = gcd(*xt)
print(abs(ans))

Solution (Python):
import functools
import fractions

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

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

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

Solution (Python):
import math
import numpy as np
from fractions import gcd
import fractions
import statistics
import collections
from functools import reduce

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

A.append(X)
A.sort()

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

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

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


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


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

Solution (Python):

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

from fractions import gcd
from functools import reduce

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

left = diff[:] + [abs(x[0]-X)]
right = diff[:] + [abs(x[-1]-X)]

print(max(reduce(gcd, left), reduce(gcd, right)))

Solution (Python):
from functools import reduce
import fractions

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

diffs = list(map(lambda z: abs(X - z), x))
print(reduce(fractions.gcd, diffs))

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

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

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

print(g)

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

n,x = map(int,input().split())
lstx = [int(i) for i in input().split()]
lstx.append(x)
dx = [abs(lstx[i]-lstx[i-1]) for i in range(1,n+1)]

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

print(g)

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

from fractions import gcd
from functools import reduce
def koyaku(numbers):
    return reduce(gcd, numbers)

print(koyaku(sa))

Solution (Python):
import fractions
from functools import reduce

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

n,s=map(int,input().split())
x=list(map(int,input().split()))
x2=[]
for i in x:
    x2.append(abs(i-s))

print(gcd_list(x2))

Solution (Python):

import sys
from fractions import gcd
from functools import reduce

def solve(N: int, X: int, x: "List[int]"):
    dif = []
    for i in range(N):
        dif.append(abs(x[i]-X))
    
    a = reduce(gcd,dif)
    print(a)
    
    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())
XL = list(map(int, input().split()))
XL.append(X)
XL.sort()
A = [0 for i in range(N)]
for i in range(N):
  A[i] = XL[i+1] - XL[i]
a = A[0]
for i in range(N - 1):
  b = A[i+1]
  while b != 0:
    a, b = b, a % b
print(a)

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

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

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

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

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

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

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

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

Solution (Python):
def gcd(l, r):
  while r:
    l, r = r, l%r
  return l
N, *X = map(int, open(0).read().split())
X = sorted(X)
ans = X[1] - X[0]
for i in range(N):
  ans = gcd(ans, X[i+1] - X[i])
print(ans)

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


def gcd_expand(values):
    return reduce(gcd, values)


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

x_abs = [abs(X - i) for i in x]
print(gcd_expand(x_abs))

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

def gcd_many(x):
	x = sorted(x)
	y = x[0]
	for i in range(1, len(x)):
		y = gcd(y, x[i])
	return y


n, x = [int(el) for el in input().split(' ')]
Y = [abs(int(el) - x) for el in input().split(' ')]
print(gcd_many(Y))

Solution (Python):
import fractions

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

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

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

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

print(ans)

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

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

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

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    gcd = fractions.gcd
    N, X = LI()
    A = LI()
    maxD = abs(A[0] - X)
    for a in A[1:]:
        maxD = gcd(maxD, abs(X-a))
    print(maxD)
main()

Solution (Python):
def gcd(x, y):
    if x < y:
        a, b = x, y
    else:
        a, b = y, x

    while True:
        r = a % b
        if r == 0:
            break
        a, b = b, r

    return b


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

ans = abs(X - x[0])

for i in range(1, N):
    ans = gcd(ans, abs(X - x[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(a)
    else:
        return(gcd(b,a%b))

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

Solution (Python):
from functools import reduce


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


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

print(reduce(gcd, d))

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

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

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

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

X = tuple(map(int,input().split()))
def gcd(a,b):
  if b == 0:
    return a
  return gcd(b,a % b)
diff_gcd = abs(x - X[0])
for i in range(n - 1):
  diff_gcd = gcd(diff_gcd,abs(X[i + 1] - X[i]))
print(diff_gcd)

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

def gcd(p, q):
    if p % q == 0:
        return q
    else:
        return gcd(q, p % q)

n, x = map(int, readline().split())
lst = [abs(int(i) - x) for i in readline().split()]
if n == 1:
    print(lst[0])
    quit()
p = lst[0]
for i in range(1, n):
    p = gcd(p, lst[i])
print(p)

Solution (Python):
import fractions
N,X = map(int,input().split())
x = list(map(int,input().split()))
distance = []
for i in range(N) :
    d = abs(x[i] - X)
    distance.append(d)
s = 1000000001
if N == 1 :
    s = distance[0]
else :
    for i in range(0,N-1) :
        s = min(fractions.gcd(distance[i],distance[i+1]),s)
print(s)

Solution (Python):
from fractions import gcd
from functools import reduce
import numpy as np
n, x = [int(i) for i in input().split()]
xi = np.array([int(i) for i in input().split()]) - x
print(abs(reduce(gcd, xi)))

Solution (Python):
import sys
import numpy as np
input = sys.stdin.readline
N, X = [int(x) for x in input().split()]
x = np.array([int(x) for x in input().split()])
if len(x) == 1:
    print(abs(X-x[0]))
    sys.exit()
x -= X
import fractions
from functools import reduce

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)
    
x.tolist()
D = gcd(* x)
print(abs(D))

Solution (Python):

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

Solution (Python):
def p(a,b):
    x = max(a,b)
    y = min(a,b)
    while(y!=0):
        x,y = y,x%y
    return x

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

Solution (Python):
import fractions
N,X=[int(s) for s in input().split()]
ls=[int(s)-X for s in input().split()]
a=0
for e in ls:
  a=fractions.gcd(a,e)
print(abs(a))

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

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

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

Solution (Python):
from functools import reduce
from fractions import gcd
n,x=map(int,input().split())
xlis=list(map(int,input().split()))
dlis=[]
for i in range(n):
	d=abs(xlis[i]-x)
	dlis.append(d)
print(reduce(gcd,dlis))

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

Solution (Python):

import sys
input = sys.stdin.readline
n,x = list(map(int,input().split()))
x_list = list(map(int,input().split()))

x_list.append(x)
x_list.sort()
x_dif_list = [i-j for i,j in zip(x_list[1::],x_list)]


import fractions

ret = min(x_dif_list)

for i in x_dif_list:
    ret = fractions.gcd(ret, i)
    if ret==1:
        break
print(ret)

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

n,x=map(int,input().split())
r=list(map(int,input().split()))
r.append(x)
r.sort()
d=[]
e=[]
for i in range(n):
  if r[i+1]!=r[i]:
    d.append(r[i+1]-r[i])
d=list(set(d))
ans=gcd(d[0],d[-1])
for y in d:
  if y%ans!=0:
    ans=gcd(ans,y)
print(ans)

Solution (Python):
from statistics import median
from fractions import gcd

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

if X < x[0]:
  ans = x[0] - X
elif X > x[len(x)-1]:
  ans = X - x[len(x)-1]
else:
  for i in range(len(x)-1):
    if x[i] < X < x[i+1]:
      if X - x[i] > x[i+1] - X:
        ans = x[i+1] - X
      else:
        ans = X - x[i] 

for i in range(1, len(x)):
  ans = gcd(ans, x[i] - x[i-1])

print(ans)

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

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


N,K=map(int,input().split())
A=[abs(int(i)-K) for i in input().split()]
print(gcd_list(A))

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

l = abs(X-X_list[0])
for i in range(len(X_list)-1):
  l = fractions.gcd(l,abs(X_list[i]-X_list[i+1]))
print(l)

Solution (Python):
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N, X = MAP()
A = MAP()

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

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

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

print(ans)

Solution (Python):
import fractions

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

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

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

ans = reduce(gcd, x)

print(ans)

Solution (Python):
import fractions
from functools import reduce


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


def main():
    N, X = map(int, input().split())
    x = list(map(int, input().split()))
    x.append(X)
    x = sorted(x)

    m = []
    for i in range(N):
        m.append(x[i + 1] - x[i])
    print(gcd_list(m))


main()

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

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

res=abs(a[0]-x)
for i in range(n-1):
    res=gcd(res,abs(a[i+1]-x))
print(res)

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

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

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

Solution (Python):
import fractions

def lcm(a,b):
    return fractions.gcd(a,b)

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

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

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

print(ans)

Solution (Python):
import sys
n, x = [int(i) for i in sys.stdin.readline().split()]
x_ls = [int(i) for i in sys.stdin.readline().split()] + [x]
x_ls.sort()
diff_ls = [x_ls[i + 1] - x_ls[i] for i in range(n)]

def gcd(ls):
    while len(ls) > 0:
        _min = min(ls)
        ls = [i % _min for i in ls if i % _min > 0]
    return _min

res = gcd(diff_ls)
print(res)

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


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

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

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

N, X = map(int, input().split())
Xs = list(map(int, input().split()))
Xs.append(X)
Xs.sort()
print(reduce(gcd, np.diff(Xs)))

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

res_abs = []
res = []

s = 10**10

for i in range(n):
    s = abs(li[i] - x)
    res_abs.append(s)
    
    s = li[i] - x
    res.append(s)
    
res.sort()

temp = 10**10

for i in range(n-1):
    temp = min(temp, res[i+1] - res[i])

    
s = min(min(res_abs), temp)
    
while True:
    for i in range(n):
        if res_abs[i]%s != 0:
            break
    else:
        print(s)
        exit()
        
    s -= 1

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

print(ans)

Solution (Python):

try:
    from math import gcd
except:
    from fractions import gcd
N, X = map(int, input().split())
x = list(map(int, input().split()))
x.append(X)
x.sort()
l = []
for i in range(N):
    tmp = (x[i+1] - x[i])
    if tmp != 0:
        l.append(tmp)
l.sort()
ans = l[0]
for i in range(1, len(l)):
    ans = gcd(ans, l[i])
print(ans)

Solution (Python):
import fractions as fra
import functools as fun

N, X = map(int, input().split())
x = [int(i) for i in input().split()]
x.append(X)
x.sort()
dif = [x[i + 1] - x[i] for i in range(N)]
print(fun.reduce(fra.gcd, dif))

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

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

n,y = map(int,input().split())
x = sorted(list(map(int, input().split())) + [y], reverse=True)
base = x.pop()
a = [i-base for i in x][::-1]
ans = reduce(gcd, a)
print(ans)

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

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

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

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
ans = 0
a = dif[0]

for d in dif[1:]:
    ans = gcd(a, d)
    a = ans

print(ans)

Solution (Python):
import fractions
from functools import reduce

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

N, X = map(int, input().split())
A =sorted(list(map(int, input().split())))
len_A=len(A)-1
A_dif=[]

for i in range(len_A):
    A_dif.append(A[i+1]-A[i])

A_X=[abs(X-i) for i in A]
A_dif=A_dif+A_X
print(gcd(*A_dif))

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

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

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

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 main():
    N, X = MI()
    x = [abs(int(i) - X) for i in input().split()]

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


if __name__ == '__main__':
    main()

Solution (Python):
N,X=map(int,input().split())
A=[int(x) for x in input().split()]
if N>=2:
  Diff=[]
  for i in range(N):
    Diff +=[abs(X-A[i])]
  def gcd(a,b):
    return a if b == 0 else gcd(b,a%b)
  g=gcd(Diff[0],Diff[1])
  for i in range(2,N):
    g=gcd(Diff[i],g)
  print(g)
else:
  print(abs(X-A[0]))

Solution (Python):


from functools import reduce

'''
def gcdList(ls):
    return reduce(math.gcd, ls)

'''

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

n,y = map(int,input().split())
x = sorted([int(i) for i in input().split()])
x_ = [0 for _ in range(n)]
for i in range(n):
    x_[i] = abs(y-x[i])
print(gcdList(x_))

Solution (Python):

import fractions
from functools import reduce

def gcdList(ls):

    return reduce(fractions.gcd, ls)

n,y = map(int,input().split())
x = sorted([int(i) for i in input().split()])
x_ = [0 for _ in range(n)]
for i in range(n):
    x_[i] = abs(y-x[i])
print(gcdList(x_))

Solution (Python):
n,x=map(int,input().split())
a=list(map(int,input().split()))
a.append(x)
a.sort(reverse=True)
b=[]
for i in range(n):
    b.append(a[i]-a[i+1])
import fractions as f
maxi=float('inf')
if len(b)==1:
    print(b[0])
    exit()
for i in range(n-1):
    tmp=f.gcd(b[i],b[i+1])
    maxi=min(maxi,tmp)
print(maxi)

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

print(reduce(gcd, x))

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

Solution (Python):
import bisect
def gcd(x , y):
    max_val = max(x , y)
    min_val = min(x , y)
    while min_val != 0:
        max_val , min_val = min_val , max_val % min_val
    return max_val
N , X = map(int,input().split())
x = list(map(int,input().split()))
x.sort()
split_idx = bisect.bisect_left(x , X)
BeforeList = x[:split_idx]
AfterList = x[split_idx:]
now = X
ans = 0
DistanceList = []
for val in AfterList:
    distance = abs(val - now)
    DistanceList.append(distance)
    now = val
for val in BeforeList:
    distance = abs(val - now)
    DistanceList.append(distance)
    now = val

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

Solution (Python):
import fractions


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

ans = abs(x-X[0])
for xi in X:
    a = abs(x-xi)
    ans = fractions.gcd(ans, a)

print(ans)

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

Solution (Python):
from fractions import gcd

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

Solution (Python):
from fractions import gcd
N, X = map(int, input().split())
xs = list(map(int, input().split()))
xs.append(X)
xs.sort()
ds = [xs[i+1]-xs[i] for i in range(N)]
ans = ds[0]
for i in range(1, N):
    ans = gcd(ans, ds[i])
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())
Towns=list(map(int, input().split()))
dist=[]
for i in Towns:
    dist.append(abs(i-X))

print(gcd(*dist))

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

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

if len(d) == 1:
    print(d[0])
else:    
    g = gcd(d[0], d[1])
    for i in range(2,N):
        g=gcd(g,d[i])
    print(g)

Solution (Python):
from functools import reduce
import fractions

n, x = map(int, input().split())
cities = list(map(lambda k: abs(int(k)-x), input().split()))
ans = reduce(fractions.gcd, cities)
print(ans)

Solution (Python):
import fractions

n,X=map(int,input().split())
x=list(map(int,input().split()))
x.append(X)
x2=sorted(x)
a=x2[1]-x2[0]
if len(x2)==2:
    print(a)
else:
    
    for i in range(1,n):
        b=x2[i+1]-x2[i]
        ans=fractions.gcd(a,b)
        a=ans
    print(ans)

Solution (Python):
inpl = lambda: list(map(int,input().split()))
def gcd(a, b):
    if a < 0: a = -a
    if b < 0: b = -b
    while b > 0:
        (a, b) = (b, a % b)
    return a

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

Solution (Python):
import fractions

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

Solution (Python):
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])

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

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

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


def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)
res = dist[0]
for i in range(1, N):
    res = gcd(res, dist[i])

print(res)

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

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

print(reduce(gcd, dist_list))

Solution (Python):
import fractions

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

Solution (Python):

import sys
from fractions import gcd
def solve(N: int, X: int, x: "List[int]"):
    ans = abs(X-x[0])
    for i in range(N):
        ans = gcd(ans, abs(X-x[i]))
    print(ans)


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())

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



xl = [i-x for i in xl]

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


ans = abs(xl[0])
for xx in xl:
    ans = abs(gcd(ans, xx))

print(ans)

Solution (Python):
from fractions import gcd
import numpy as np
N, X = map(int, input().split())
xlist = np.array(list(map(int, input().split())))
xabs = np.abs(xlist - X)
num = xabs[0]
for x in xabs:
    num = gcd(x, num)
print(num)

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

n, x = map(int, input().split())
xl = map(lambda _: abs(_ - x),map(int, input().split()))
ans = reduce(gcd, xl)
print(ans)

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

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

if N == 1:
  print(xn[0])
else:
  n = (gcd(xn[0], xn[1]))
  for x in xn[2:]:
    n = gcd(x, n)
  else:
    print(n)

Solution (Python):
import fractions
from functools import reduce

N, X = map(int, input().split(' '))
city = list(map(int, input().split(' ')))
for i in range(N):
    city[i] = abs(city[i] - X)
    
def gcd(numbers):
    return reduce(fractions.gcd, numbers)

if N == 1:
    ans = city[0]
else:
    ans = gcd(city)

print(ans)

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

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

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

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

l.append(x)
l = list(set(l))
l.sort()

ans = l[1]-l[0]
for i in range(2,len(l)):
  num = l[i]-l[i-1]
  ans = gcd(ans,num)
print(ans)

Solution (Python):
import fractions
from functools import reduce

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

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

d = [l[i+1] - l[i] for i in range(n)]

d.sort()

print(gcd(d))