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

dist = [abs(X - D[i]) for i in range(N)]

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,dist[i])
  
print(D)

Solution (Python):
N,X=map(int,input().split())
x=list(map(int,input().split()))
x.append(X)
x=sorted(x)
dif=[0]*(len(x)-1)
for i in range(len(x)-1):
  dif[i]=x[i+1]-x[i]

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

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

print(ans)

Solution (Python):




import sys







import functools






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

def main():
    n, *x = (int(i) for i in sys.stdin.read().split())

    res = functools.reduce(gcd, [abs(x[i+1] - x[i]) for i in range(n)])

    print(res)

if __name__ == "__main__":
    
    main()

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

d = []
d.append(abs(X-x[0]))
gc = d[0]
for i in range(1, n):
	d.append(abs(X-x[i]))
	gc = fractions.gcd(d[i], gc)
print(gc)

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

if N == 1:
    ans = x[0]

else:
    ans = fractions.gcd(x[0],x[1])
    for n in range(2,N):
        ans = fractions.gcd(ans,x[n])

print(ans)

Solution (Python):
from sys import stdin
import fractions


n,x = [int(x) for x in stdin.readline().rstrip().split()]

li = list(map(int,stdin.readline().rstrip().split()))
lin = []
for i in range(len(li)):
    lin.append(abs(li[i]-x))
poi = lin[0]
for i in range(len(lin)-1):
    poi = fractions.gcd(poi,lin[i+1])

print(poi)

Solution (Python):
from sys import stdin
import fractions


n,x = [int(x) for x in stdin.readline().rstrip().split()]

li = list(map(int,stdin.readline().rstrip().split()))
lin = []
for i in range(len(li)):
    lin.append(abs(li[i]-x))
poi = lin[0]
for i in range(len(lin)-1):
    poi = fractions.gcd(poi,lin[i+1])

print(poi)

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

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

dif = []

for n in range(N):
    dif.append(abs(x - X[n]))

ans = dif[0]

for n in range(1, N):
    ans = gcd(ans, dif[n])

print(ans)

Solution (Python):
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

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

import fractions
import math

N,X=two_int()

city=many_int()

temp = list(map(lambda x : abs(x-X), city))


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

Solution (Python):
import fractions
import functools

def f_gcd(numbers):
  return functools.reduce(fractions.gcd, numbers)
  
n, x = map(int, input().split())
X = list(map(lambda a:abs(int(a)-x), input().split()))
print(f_gcd(X))

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

A.append(X)
A.sort()
diffs = [A[i+1] - A[i] for i in range(N)]

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


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

print(ans)

Solution (Python):
import fractions
from functools import reduce


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

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

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

arr1 = [(i-x if i-x>=0 else x-i) for i in arr]

print(gcd(*arr1))

Solution (Python):
import fractions
N, X = map(int,input().split())
x = list(map(int,input().split()))
x.extend([X])
x.sort()
sa = [0]*(N)
for i in range(N):
    sa[i] = x[i+1]-x[i]
ans = max(x)
if len(sa) == 1:
    ans = sa[i]
else:
    for i in range(N-1):
        ans = min(ans, fractions.gcd(sa[i],sa[i+1]))
print(ans)

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

Solution (Python):
def GCD(x,y):
    if y>x :
        x,y = y,x
    mod = x%y
    return GCD(y,mod) if mod!=0 else y

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

Solution (Python):

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

M = [abs(i - X) for i in L]

def gcd(a,b):
    if b==0: 
        return a 
    return gcd(b,a%b)
    
D = 0 
for i in range(0,len(M)): 
    D = gcd(D,M[i])

print(D)

Solution (Python):
import fractions

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

dp = [0]*n
for i in range(n):
    if i == 0:
        dp[0] = s[0]
    else:
        dp[i] = fractions.gcd(dp[i-1],s[i])
print(dp[-1])

Solution (Python):
n,k=map(int,input().split())
l=[int(i) for i in input().split()]
l=[abs(i-k) for i in l]
def gcd(a,b):
    if b==0: 
        return a 
    return gcd(b,a%b)
g=0 
for i in l: 
    g=gcd(g,i)
print(g)

Solution (Python):
import fractions

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

L = list(map(int,input().split()))
y = []
for i in range(n):
  y.append(abs(L[i]-x))
tmp = y[0]

for i in range(n-1):
  tmp = fractions.gcd(tmp,y[i+1])
print(tmp)

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

Y=[0]*N

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

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

print(tmp)

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

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

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

ans = fix_x[0]
for i in range(len(fix_x)):
    ans = gcd(ans, fix_x[i])

print(ans)

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

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

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

x.append(X)
x = sorted(x)

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

print(ans)

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


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

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

zahyo.append(X)
zahyo.sort()

distant = []
for i in range(N):
    distant.append(zahyo[i+1] - zahyo[i])


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

print(ans)

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

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

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

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

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

Solution (Python):
n,s=map(int,input().split())
l=[abs(int(i)-s) for i in input().split()]
ans=l[0]
def gc(a,d):
  ai=a;bi=d
  a,d=min(ai,bi),max(ai,bi)
  if a==0:return d
  else:return gc(d%a,a)
  
  
for i in l:
  ans=gc(ans,i)
print(ans)

Solution (Python):
n,s=map(int,input().split())
l=[abs(int(i)-s) for i in input().split()]
ans=l[0]
def gc(a,d):
  ai=a;bi=d
  a,d=min(ai,bi),max(ai,bi)
  if a==0:return d
  else:return gc(d%a,a)
  
  
for i in l:
  ans=gc(ans,i)
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 x in A[1:]:
    ans = gcd(ans, abs(x - X))
    if ans == 1:
        break

print(ans)

Solution (Python):
import fractions as math
n,x = map(int,input().split())
list1 = list(map(int,input().split()))
ans = max(abs(x-list1[0]),abs(list1[-1]-x))
for i in range(n):
	gcd = math.gcd(ans,abs(x-list1[i]))
	ans = min(ans, gcd)

print(ans)

Solution (Python):
import fractions


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

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

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

Solution (Python):
def GCD(x,y):
    x,y=max(abs(x),abs(y)),min(abs(x),abs(y))
    if y==0:
        return x
    elif x%y==0:
        return y
    else:
        return GCD(y,x%y)

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

ans=0

for xi in x:
    ans=GCD(ans,xi-X)

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 functools import reduce
from fractions import gcd
n,x = map(int,input().split())
X = list(map(int,input().split()))
X = [abs(a-x) for a in X]
print(reduce(gcd,X))

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

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

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

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

print (ans)

Solution (Python):
from fractions import gcd

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

x = [abs(int(i) - X) for i in input().split()]  
for i in range(1,N):
	x[i] = gcd(x[i-1], x[i])

print(x[-1])

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

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

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











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

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

    divisors.sort(reverse=True)
    return divisors

for divisors in make_divisors(min(x_list)):
  devided_list = [x_list[i]%divisors for i in range(N)]
  if sum(devided_list)==0:
    print(divisors)
    break

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

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

if n == 1:
  a.append(a[0])
  n = n+1
d = []
for i in range(n):
  y = abs(a[i] - x)
  d.append(y)

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

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

    print(x[-1])

if __name__ == '__main__':
    main()

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

def gcd_list(L):
    b=min(L)
    for i in L:
        while True:
            if i%b==0:
                break
            c=b
            b=i%b
            i=c
    return(b)

print(gcd_list(P))

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

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

import fractions
from functools import reduce

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

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

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

Solution (Python):
import fractions

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

if N == 1:
    if X < x_list[0]:
        x_list.insert(0, X)
    else:
        x_list.insert(1, X)
else:
    for i in range(N-1):
        if x_list[i] < X < x_list[i+1]:
            x_list.insert(i+1, X)
        else:
            x_list.append(X)

x_list.sort()

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

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

Solution (Python):
import fractions

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

x.append(X)
x.sort()

for i in range(len(x)-1):
    dif=x[i+1]-x[i]
    if i==0:
        ans=dif
    elif dif<ans:
        ans=dif
    elif dif%ans!=0:
        ans=fractions.gcd(ans,dif)

print(ans)

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

Solution (Python):
import math
from fractions import gcd
N, X = map(int,input().split())
x = list(map(int,input().split()))
L = []
for i in range(N):
    y = math.fabs(X-x[i])
    y = int(y)
    L.append(y)
ans = L[0]
for i in range(len(L)):
    ans = gcd(ans,L[i])
print(ans)

Solution (Python):
from fractions import gcd

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

x_diff = [abs(y-X) for y in x]
for i in range(N):
  if i == 0:
    tmp = x_diff[i]
  else:
    tmp = gcd(tmp, x_diff[i])
print(tmp)

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

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

Solution (Python):

import fractions
from functools import reduce
def gcd_list(lst):
    return reduce(fractions.gcd, lst)

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

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


ans = gcd_list(diff_list)
print(ans)

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

Solution (Python):
N,X=map(int,input().split())
x=list(map(int,input().split()))
lst=[]
for i in range(N):
  lst.append(abs(X-x[i]))
  
def gcd(a,b):
  a,b=max(a,b),min(a,b)
  if a==b:
    return a
  else:
    if a%b==0:
      return b
    else:
      return gcd(b,a%b)
if N==1:
  print(lst[0])
else:
  tmp=gcd(lst[0],lst[1]) 
  if N==2:
    print(tmp)
  elif N>=3:
    for i in range(2,N):
      tmp=gcd(tmp,lst[i])
    print(tmp)

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

l=list()

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

for i in range(n):
  if x[i]!=s:
    l.append(abs(x[i]-s))

d=l[0]
for i in range(1,len(l)):
  d=lcd(d,l[i])

print(d)

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)
x = sorted(x)
diff_x = []
for i in range(len(x)-1):
    diff_x.append(x[i+ 1] - x[i])


ans = reduce(gcd, diff_x)

print(ans)

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

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

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

    print(ans)

Solution (Python):
n,x=map(int,input().split())
A=[]*n
A[:]=map(int,input().split())
for i in range(n):
  A[i]=abs(A[i]-x)
if len(A)==1:
  print(A[0])
else:
  def gcd(a,b):
    while b:
        a,b=b,a%b
    return a
      
  left=[0]*n
  right=[0]*n
  for i in range(1,n):
    left[i]=gcd(left[i-1],A[i-1])
    right[n-1-i]=gcd(right[n-i],A[n-i])
 
  ans=10**9
  for i,j in zip(left,right):
    ans=min(ans,gcd(i,j))
  print(ans)

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

Solution (Python):
n,x=map(int,input().split())
l=list(map(int,input().split()))
a=[0]*n
for i in range(n):
  a[i]=abs(l[i]-x)
a.sort()
from fractions import gcd
from functools import reduce
def gcdl(list):
  return reduce(gcd,list)
print(gcdl(a))

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

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

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

print(g)

Solution (Python):
N,K=map(int,input().split())
l=list(map(int,input().split()))

for i in range(N):
    l[i]=abs(l[i]-K)
    
def ins(num):
    l=[]
    for i in range(1,int(num**0.5//1)+1):
        if num%i==0:
            l.append(i)
            l.append(num//i)
    return l

cand=(ins(min(l)))

cand.sort()


count=0

for item in cand:
    temp=0
    for target in l:
        if target%item==0:
            temp+=1
    count=max(count,temp)
    if count==temp:
        ans=item
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)  

def gcdlist(L):
    a = L[0]-X
    for i in L:
        a = gcd(a, abs(i-X))
    return a
    
    
print(gcdlist(x))

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

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

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


c = m[0]
for i in range(1, N):
    if c == 1: break
    c = gcd(c, m[i])

print(c)

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

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

absli = list(map(lambda x: abs(x - y), li))

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

tmp = absli[0]
for i in range(n-1):
  tmp = gcd(tmp, absli[i+1])
print(tmp)

Solution (Python):
from functools import reduce
import bisect

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

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

x.sort()
bisect.insort_left(x, X)


diff = [abs(x[idx] - x[idx-1]) for idx in range(1,N+1)]
print(reduce(gcd,diff))

Solution (Python):
from functools import reduce
from fractions import gcd
n,x=map(int,input().split())
a=list(map(lambda i: abs(i-x),map(int,input().split())))
print(reduce(gcd,a))

Solution (Python):
def slove():
    import sys
    import fractions
    input = sys.stdin.readline
    n, x = list(map(int, input().rstrip('\n').split()))
    xl = list(map(int, input().rstrip('\n').split()))
    xl.append(x)
    xl.sort()
    gcd = 0
    for i in range(1, len(xl)):
        gcd = fractions.gcd(gcd, xl[i] - xl[i-1])
    print(gcd)


if __name__ == '__main__':
    slove()

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

X=X+[x]
X.sort()
sa=[0]*n
for i in range(1,n+1):
  sa[i-1]=X[i]-X[i-1]
if len(sa)==1:
  print(sa[0])
else:
  ans=sa[0]
  for i in range(1,n):
    ans=gcd(ans,sa[i])
  print(ans)

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

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

print(reduce(gcd, [abs(x[i] - X) for i in range(N)]))

Solution (Python):
import fractions
n,*x=map(int,open(0).read().split())
x.sort()
a=[i-j for i,j in zip(x[1:],x[:-1])]
set(a)
a.sort()
b=[i for i in a if i%a[0]]
b.append(a[0])
if len(b)==1:
    print(*b)
else:
    ans=b[0]
    for i in b[1:]:
        ans=fractions.gcd(ans,i)
    print(ans)

Solution (Python):
import math
import fractions
n,x = map(int,input().split())
l  = sorted(map(int,input().split()+[x]))
dec = []
for i in range(n):
    j = abs(l[i-1]-l[i])
    dec.append(j)
ans = dec.pop()
for i in dec:
    ans = fractions.gcd(ans,i)
print(ans)

Solution (Python):
N,X = map(int, input().split())
l = sorted(map(int, input().split()+[X]))
r = [l[n+1] - l[n] for n in range(N)]
ans = r.pop()
for i in r:
    while ans%i != 0:
        ans,i = i,ans%i
    ans = i
print(ans)

Solution (Python):
def solve():
    N,X = map(int, input().split())
    r = [abs(X-i) for i in map(int, input().split())]
    ans = r.pop()
    for i in r:
        while ans%i != 0:
            ans,i = i,ans%i
        ans = i
    return ans

if __name__ == '__main__':
    print(solve())

Solution (Python):
N,X = map(int, input().split())
r = {abs(X-i) for i in map(int, input().split())}
ans = r.pop()
for i in r:
    while ans%i != 0:
        ans,i = i,ans%i
    ans = i
print(ans)

Solution (Python):
N,X = map(int, input().split())
r = {abs(X-i) for i in map(int, input().split())}
ans = r.pop()
for i in r:
    while ans%i != 0:
        ans,i = i,ans%i
    ans = i
print(ans)

Solution (Python):
N,X = map(int, input().split())
r = [abs(X-i) for i in map(int, input().split())]
ans = r.pop()
for i in r:
    while ans%i != 0:
        ans,i = i,ans%i
    ans = i
print(ans)

Solution (Python):
N,X = map(int, input().split())
l = sorted(map(int, input().split()+[X]))
r = [l[n+1] - l[n] for n in range(N)]
ans = r.pop()
for i in r:
    while ans%i != 0:
        ans,i = i,ans%i
    ans = i
print(ans)

Solution (Python):
from fractions import gcd

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

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

print(g)

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



def getInputInt():
    inputNum = int(input())
    return inputNum

def getInputListInt():
    outputoData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData

def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList

def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList



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

data = getInputListInt()

data.append(x)

data.sort()

tmp = []

for i in reversed(range(1, n+1)):
    tmp.append(data[i]-data[i-1])



gcdans = reduce(fractions.gcd, tmp)

print(gcdans)

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


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


x_n.sort()
min_start = abs(x_n[0] - x)
for i in range(1, len(x_n)):
    tmp = abs(x_n[i] - x)
    if min_start > tmp:
        min_start = tmp

ans = min_start
for i in range(1, len(x_n)):
    ans = gcd(ans, abs(x_n[i] - x_n[i-1]))
print(ans)

Solution (Python):
n,x = map(int,input().split())
cities = list(map(int,input().split()))
dist = []
for city in cities:
    dist.append(abs(city-x))

gcf = dist[0]

def gcd(x,y):
    a = max(x,y)
    b = min(x,y)
    while a%b !=0:
        a,b = b,a%b
    return b
for i in dist:
    gcf = gcd(gcf,i)
print(gcf)

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

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

print(reduce(gcd,A))

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


from functools import reduce
import fractions

x=sorted(x)
x_bet=[0]*(n-1)

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

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

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


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


ns = [abs(x-X) for x in XS]
print(gcd_list(ns))

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

Solution (Python):
import fractions

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

xsas = [abs(xi-x) for xi in xis]

if n == 1:
    print(xsas[0])
else:
    res = fractions.gcd(xsas[0],xsas[1])
    for xsa in xsas:
        res = fractions.gcd(res,xsa)
    print(res)

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

Solution (Python):


def gcd(GCD1,GCD2):
    x = min(GCD1,GCD2)
    y = max(GCD1,GCD2)
    if y%x == 0:
        return x
    else:
        return gcd(x,y%x)
N,X = map(int,input().split())
C = list(map(int,input().split()))

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

for i in range(N):
    if i == 0:
        g = D[0]
    else:
        g = gcd(g,D[i])
        
print(g)

Solution (Python):
import fractions
a,b = [int(i) for i in input().split()]

l = [int(i) for i in input().split()]

l2 = [abs(i-b) for i in l]

ans = l2[0]

for i in range(len(l2)):
    ans = fractions.gcd(l2[i],ans)
    
print(ans)

Solution (Python):
import fractions

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

print(ans)

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(map(int,input().split()))
x.append(X)
mx=min(x)
x=list(map(lambda t:t-mx,x))
def gcd(a,b):
    while b:
        a,b=b,a%b
    return(a)
a=10**10
for i,j in zip(x,x[1:]):
    a=min(a,gcd(i,j))
print(a)

Solution (Python):
N,X=map(int,input().split())
x=list(map(int,input().split()))
x.append(X)
mx=min(x)
x=list(map(lambda t:t-mx,x))
def gcd(a,b):
    while b:
        a,b=b,a%b
    return(a)
a=10**10
for i,j in zip(x,x[1:]):
    a=min(a,gcd(i,j))
print(a)

Solution (Python):
from fractions import gcd

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

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

dists = [abs(x - X) for x in xs]
D = gcd(dists[0], dists[1])
for d in dists[2:]:
    D = gcd(D, d)

print(D)

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

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

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

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

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

def main():
  n,m=map(int,input().split())
  x=list(map(int,input().split()))
  s=make_divisors(x[0]-m)
  news=[]
  for i in range(1,n):
    d=x[i]-x[i-1]
    news=[]
    for j in s:
      if d%j==0:
        news.append(j)
    s=set(news)
  print(max(s))
  
main()

Solution (Python):
import os, sys, re, math

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

N,X = map(int,input().split(' '))
cities = list(map(lambda x: abs(int(x) - X),input().split(' ')))
D = cities[0]

for i in range(len(cities)):
    D = gcd(D, cities[i])

print(D)