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())
l=list(map(int,input().split()))
l=sorted([abs(i-x) for i in l],reverse=True)

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

if n!=1:
    p=gcd(l[0],l[1])
    for i in l[2:]:
        p=gcd(i,p)
else:
    p=l[0]
print(p)

Solution (Python):
n,x=map(int,input().split())
l=list(map(int,input().split()))
l=sorted([abs(i-x) for i in l],reverse=True)

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

if n!=1:
    p=gcd(l[0],l[1])
    for i in l[2:]:
        q=gcd(i,p)
        p=q
else:
    p=l[0]
print(p)

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

x.append(X)
x.sort()

from fractions import gcd

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

print(ans)

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

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

diff = np.diff(sorted(coord + [x])).tolist()
while len(diff) > 1:
    diff.append(gcd(diff.pop(), diff.pop()))

print(diff.pop())

Solution (Python):

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

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

dx =[abs(x-X) for x in Xn]

gcd_num = dx[0]
for x in dx:
  a, b = (gcd_num, x) if gcd_num > x else (x, gcd_num)
  gcd_num = gcd(a, b)
print(gcd_num)

Solution (Python):

from functools import reduce
from fractions import gcd
n,x=map(int,input().split())
L=[abs(x-int(i)) for i in input().split()]
print(reduce(gcd,L))

Solution (Python):
n,x=map(int,input().split())
xx=list(map(int,input().split()))
xx.append(x)
xx.sort()
y=[]
from fractions import gcd

for i in range(n):
    y.append(xx[i+1]-xx[i])
w=y[0]
for i in y[1:]:
    w=gcd(w,i)
print(w)

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):
def gcd(a, b):
    while b:
        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()))
a = abs(X[0] - x)
for i in range(1, n):
    a = gcd(a, abs(X[i] - x))
print(a)

Solution (Python):
import numpy as np
import functools
import sys
sys.setrecursionlimit(10**9)


def gcd_impl(n,m):
    for _ in range(10):
        t = n - m
        q = m > t
        if q:
            n = m
        else:
            n = t
        if q:
            m = t
        else:
            m = m
        if m == 0:
            return n
    return gcd_impl(m, n%m)

def gcd(n,m):
    if n > m:
        return gcd_impl(n,m)
    else:
        return gcd_impl(m,n)


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

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

Solution (Python):
import fractions
from functools import reduce

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

if n == 1:
    ans = xx[0]
else:
    ans = reduce(fractions.gcd, xx)

print(ans)

Solution (Python):
from fractions import gcd
from functools import reduce
n,*x = map(int, open(0).read().split())
x.sort()
d = [x[i+1]-x[i] for i in range(n)]
print(reduce(gcd,d))

Solution (Python):
from fractions import gcd

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

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

coord.append(X)
coord.sort()

diffs = []
for i in range(1, len(coord)):
    diffs.append(coord[i] - coord[i-1])

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

GCD = diffs[0]
for el in diffs[1:]:
    GCD = gcd(GCD, el)

print(GCD)

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

Solution (Python):
import fractions
N, X = map(int, input().split())
points = list(map(int, input().split()))
g = -1

for point in points:
  if g == -1:
    g = abs(X - point)
  g = fractions.gcd(g, abs(X - point))
print(g)

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

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

x -= X
x = abs(x)
x = x.tolist()

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

print(gcd(x))

Solution (Python):

from fractions import gcd
def main():
    n, x = map(int, input().split())
    L = list(set(map(int, input().split())))
    dist = sorted(set([abs(l-x) for l in L]))
    ans = dist[0]
    for d in dist:
        ans = gcd(d, ans)
    print(ans)
main()

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

Solution (Python):
n,x0 = map(int,input().split( ))
*x_, = map(int,input().split( ))

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

from fractions import gcd

g = x[0]

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

Solution (Python):


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


def submit():
    n, s = map(int, input().split())
    xlist = list(map(int, input().split()))

    if n == 1:
        print(abs(xlist[0] - s))
    else:
        dist_list = [abs(x - s) for x in xlist]
        curr = gcd(dist_list[0], dist_list[1])
        for d in dist_list[2:]:
            curr = gcd(curr, d)
        print(curr)


if __name__ == "__main__":
    submit()

Solution (Python):
import sys
import math
mod=10**9+7
inf=float("inf")
from math import sqrt
from collections import deque
from collections import Counter
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from functools import lru_cache




n,k=map(int,input().split())
A=sorted(list(map(int,input().split()))+[k])
def gcd(a,b):
    if b==0: return a
    else:
        return gcd(b,a%b)
def lcm(a,b):
    return a*b//gcd(a,b)
SA=[]
for  i in range(n):
    SA.append(A[i+1]-A[i])
ans=SA[0]
for i in range(n-1):
    ans=gcd(ans,SA[i+1])
print(ans)

Solution (Python):
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007



def ggg(a,b):
	while b>0:
		nb=a%b
		na=b
		a,b=na,nb
	return a
		

def main():
	n, x = IN()
	al = list(IN())
	al.append(x)
	al.sort()
	bl=[b-a for a,b in zip(al,al[1:])]
	ret=bl[0]
	for diff in bl:
		ret = ggg(ret, diff)
	return ret
	
	
	

isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		
			
	ret = main()
	if ret is not None:
		print(ret)

Solution (Python):


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


def gcd(a,b):
    x = max(a,b)
    y = min(a,b)

    while y != 0:
        r = x % y
        
        x = y
        y = r
    
    return x

ans = abs(x_list[0]-X)
for i in range(1,len(x_list)):
    ans = gcd( ans, abs(x_list[i]-X) )

print(ans)

Solution (Python):
from functools import reduce
def gcd_list(n):
    return reduce(gcd, n)
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())) + [x]
a.sort()
b = []
for i in range(n):
    b.append(a[i+1]-a[i])
print(gcd_list(b))

Solution (Python):
import fractions

def main():
    n, x = [int(e) for e in input().split()]
    X = [int(e) for e in input().split()]

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

    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
def gcd(a: int, b: int) -> int:
    """a, bの最大公約数(greatest common divisor: GCD)を求める
    計算量: O(log(min(a, b)))
    """
    if b == 0:
        return a
    return gcd(b, a%b)


def lcm(a: int, b: int) -> int:
    """a, bの最小公倍数(least common multiple: LCM)を求める
    計算量: O(log(min(a, b)))
    """
    return (a * b) // gcd(a, b)


def multi_gcd(array: list) -> int:
    """arrayのGCDを求める"""
    n = len(array)
    ans = array[0]
    for i in range(1, n):
        ans = gcd(ans, array[i])
    return ans



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

li = []
for i in range(n):
    li.append(abs(x[i] - y))
print(multi_gcd(li))

Solution (Python):
def main():
  import fractions
  n,X=map(int,input().split())
  x=sorted(list(map(int,input().split())))
  ans=abs(x[0]-X)
  for i in range(n):
    ans=fractions.gcd(ans,abs(x[i]-X))
  print(ans)
if __name__=='__main__':
  main()

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

import fractions
ans = lens[0]
for le in lens :
    ans = fractions.gcd(ans, le)

print(ans)

Solution (Python):
import sys
from fractions import gcd
from functools import reduce
def input(): return sys.stdin.readline().rstrip()

sys.setrecursionlimit(10 ** 9)
def main():
    _, X = input().split()
    x = sorted(map(int, input().split() + [X]))
    min_x = x[0]
    x = map(lambda a: a - min_x, x[1:])
    print(reduce(gcd, x))

if __name__ == '__main__':
    main()

Solution (Python):
import sys
from functools import reduce
def input(): return sys.stdin.readline().rstrip()

sys.setrecursionlimit(10 ** 9)
def main():
    _, X = input().split()
    x = sorted(map(int, input().split() + [X]))
    min_x = x[0]
    x = map(lambda a: a - min_x, x[1:])

    def gcd(m, n):
        if n == 0:
            return m
        else:
            return gcd(n, m % n)
    print(reduce(gcd, x))

if __name__ == '__main__':
    main()

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

Solution (Python):
from fractions import *
from functools import *

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

print(reduce(gcd,[abs(x-x0) for x in X]))

Solution (Python):


import fractions

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

x_list = list(map(int, input().rstrip().split(" ")))

current = abs(x-x_list[0])
for i in range(1,n):
    current = fractions.gcd(current, abs(x-x_list[i]))

print(current)

Solution (Python):
from fractions import gcd
N,X=map(int,input().split())
x=list(map(int,input().split()))
m=abs(X-x[0])

for i in range(1,N):
    
    if gcd(m,abs(x[i]-X))<m:
        m=gcd(m,abs(x[i]-X))
print(m)

Solution (Python):
import numpy as np
N, X = [int(i) for i in input().split()]
xn = np.array([int(i) for i in input().split()])
xn = abs(X-xn)

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

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

print(ans)

Solution (Python):
import fractions

N, X = map(int, input().split())
x = list(map(int, input().split()))
y = []
x.insert(0, X)
x.sort()
for i in range(1, N+1):
    x1 = x[i] - x[i-1]
    y.append(x1)

d = y[0]

for i in range(1, len(y)):
    d = fractions.gcd(y[i], d)

print(d)

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

Solution (Python):
import fractions
from functools import reduce

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

n, *spot = map(int, open(0).read().split())
spot.sort()
dist = set([spot[i+1]-spot[i] for i in range(n)])
print(gcd_list(dist))

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

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

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

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

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

Solution (Python):
import fractions
n,X = map(int,input().split())
x_ = list(map(int,input().split()))
x_.append(X)
x_.sort()
if len(x_) == 2:
    print(x_[1]-x_[0])
else:
    a = x_[1]-x_[0]
    for i in range(1,n):
        b = x_[i+1]-x_[i]
        a = fractions.gcd(a,b)
    print(a)

Solution (Python):
import itertools as it
import collections as col
import fractions
from functools import reduce

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

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

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

P.sort()
D=[0]
for i in range(n):
    D.append(abs(P[i]-x))
print(gcd_list(D))

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

dist = [0] * n
for i in range(n):
    dist[i] = abs(X-x[i])
def gcd(a,b):
    if a%b == 0:return b
    return gcd(b,a%b)
if n == 1:
    print(dist[0])
    exit(0)
    
g = gcd(dist[0],dist[1])
for i in range(n):
    if i == 0:continue
    g = gcd(g,dist[i])
    
print(g)

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

Solution (Python):
import fractions
from functools import reduce

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

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

print(gcd_list(ans))

Solution (Python):
from fractions import gcd

def gcds(List):
    __ = 0
    for _ in List:
        __ = gcd(__, _)
    return __

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

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

print(gcds(y))

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

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

Solution (Python):


import fractions
from functools import reduce
n,x = map(int,input().split())
x_list = list(map(int,input().split()))
if n == 1:
    print (abs(x_list[0]-x))
    exit (0)

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

y_list = []
for i in x_list:
    y_list.append(abs(i-x))

print (gcd_list(y_list))

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

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

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

n, X = map(int, input().split())
x = list(map(int, input().split()))
if len(x) == 1:
  print(abs(x[0] - X))
else:
  x.sort()
  s = x[1] - x[0]
  for i in range(1, n-1):
    s = gcd(s, x[i+1]-x[i])
  a = 1
  for i in range(n):
    a = max(a, gcd(abs(X-x[i]), s))
  print(a)

Solution (Python):


from fractions import gcd
N, X = map(int, input().split())
Xs = [int(i) for i in input().split()]

Xs.append(X)
position = sorted(Xs)

dist = []
for i in range(1, len(position)):
    dist.append(position[i] - position[i - 1])


i = dist[0]

for j in dist[1:]:
    i = gcd(i, j)

print(i)

Solution (Python):
from fractions import gcd
n, x = map(int, input().split())
positions = [int(i) for i in input().split()]

distances = [abs(x - p) for p in positions]
i = distances[0]
for j in distances[1:]:
    i = gcd(i, j)
print(i)

Solution (Python):
from fractions import gcd
n, x = map(int, input().split())
positions = [int(i) for i in input().split()]

distances = [abs(x - p) for p in positions]
i = distances[0]
for j in distances:
    i = gcd(i, j)
print(i)

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

number = []

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

import fractions 

ans = number[0]
for i in range(1, N):
    ans = fractions.gcd(ans, number[i])
    
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()

dist = []

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

ans = 0

for d in dist:
    ans = gcd(ans, d)

print(ans)

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

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

memo = []

for i in t:
    memo.append(abs(i-x))
ans = memo[0]
for i in range(n):
    ans = fractions.gcd(ans,memo[i])
print(ans)

Solution (Python):
from fractions import gcd

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

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

print(abs(num))

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

def eu(a, b):
    a, b = sorted([a,b])
    while a != 0:
        b, a = a, b%a
    return b
d = y[0]
for i in range(1, n):
    d = eu(d, y[i])
print(d)

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

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


n, x = map(int, input().split())
l = list(map(int, input().split()))
sa = []
for i in range(n):
    t = abs(l[i] - x)
    sa.append(t)
sa = list(set(sa))
sa.sort()

q = len(sa)
t = sa[0]

for i in range(1, q):
    t = gcd(t, sa[i])
print(t)

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

Solution (Python):
from fractions import gcd

n, x = map(int,input().split())
x_list = list(map(int,input().split()))
x_list.append(x)
x_list.sort()
dis_list = []

for i in range(n):
    dis_list.append(x_list[i+1] - x_list[i])

ans = dis_list[0]
for i in range(n):
    ans = gcd(dis_list[i],ans)

print(ans)

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

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

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

Solution (Python):
from fractions import gcd

N, X = map(int, input().split())
P = list(map(int, input().split()))
x0 = min(min(P), X)
ans = X - x0
for x in (x - x0 for x in P):
    ans = gcd(ans, x)

print(ans)

Solution (Python):
from fractions import gcd

N, X = map(int, input().split())
P = list(map(int, input().split()))
x0 = min(min(P), X)
P = [x - x0 for x in P]
ans = X - x0
for x in P:
    ans = gcd(ans, x)

print(ans)

Solution (Python):
from fractions import gcd

N, X = map(int, input().split())
P = list(map(int, input().split()))
P.append(X)
P.sort()
x0 = P[0]
P = [x - x0 for x in P]
ans = 0
for x in P:
    ans = gcd(ans, x)

print(ans)

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

Solution (Python):
S = input().split(" ")
n = int(S[0])
x = int(S[1])

arr = [int(s) for s in input().split(" ")]

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





def calculate(n,x,arr):
    data = []
    for ar in arr:
        if ar < x:
            data.append(x - ar)
        else:
            data.append(ar - x)

    return data

data = calculate(n,x,arr)

if len(data) == 1:
    print(data[0])
else:
    res = gcd(data[0],data[1])
    for index,da in enumerate(data):
        if index < 2:
            continue
        res = gcd(res,da)
    print(res)

Solution (Python):

def gcd(p, q):
  a, b = (p, q) if p >= q else (q, p)
  c = a % b
  while c != 0:
    a, b = (b, c) if b >= c else (c, b)
    c = a % b
  return  b

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

diffs = []

if X < xn[0]:
  diffs.append(xn[0] -X)
for n in range(N-1):
  if xn[n] < X < xn[n+1]:
    diffs.append(X - xn[n])
    diffs.append(xn[n+1] - X)
  else:
    diffs.append(xn[n+1] - xn[n])
if X > xn[N-1]:
  diffs.append(X - xn[N-1])
if len(diffs) > 1:
  D = gcd(diffs[0], diffs[1])
  for i in range(N-2):
    D = gcd(D, diffs[i+2])
else:
  D = diffs[0]
print(D)

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

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

print(g)

Solution (Python):
import numpy as np

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

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


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

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

x.append(xx)

x.sort()

y = []

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


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

print(ans)

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

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

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

def main():
    n, x, *a = map(int, open(0).read().split())
    ans = abs(x-a[0])
    for i in a:
        dif = abs(x-i)
        if dif%ans:
            ans = gcd(ans, dif)
    print(ans)

main()

Solution (Python):
from functools import reduce

import fractions


def main():
    
    
    
    

    
    
    
    
    
    

    
    

    
    
    
    
    
    
    
    
    
    INF = float("inf")

    
    MOD = 10**9+7
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    
    
    
    
    N, X = (int(_) for _ in input().split())
    x = list(int(_) for _ in input().split())
    x.append(X)
    x.sort()
    x_diff = []
    for i in range(N):
        x_diff.append(x[i+1]-x[i])
        if i != 0:
            ans = fractions.gcd(x_diff[i],ans)
        else:
            ans = fractions.gcd(x_diff[i],x_diff[i-1])
    print(ans)
if __name__ == '__main__':
    main()

Solution (Python):

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

Solution (Python):
n, x = map(int, input().split())
a = list(map(int, input().split()))
d = list(map(lambda z: abs(z-x), a))

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

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

Solution (Python):
import fractions
n,x = [int(x) for x in input().split()]
X = [int(x) for x in input().split()]
X.append(x)
X.sort()

x_diff = [int(X[i+1] - X[i]) for i in range(n)]

ans = x_diff[0]
for y in range(1,n):
    ans = fractions.gcd(ans, x_diff[y])

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)

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

d = []
for i, j in zip(a, a[1:]):
  d.append(j - i)

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

print(ans)

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

Solution (Python):
import fractions
N, X = map(int, input().split())
*x, = [int(v) - X for v in input().split()]
chk = 0
for v in x:
    chk = fractions.gcd(chk, v)
print(abs(chk))

Solution (Python):
import itertools
import math
import sys
from collections import Counter
from fractions import gcd
from functools import reduce

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

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

if len(gaps) == 1:
    print(gaps[0])
else:
    ans = reduce(gcd, gaps)
    print(ans)

Solution (Python):
import fractions
from functools import reduce
def main():
    n,x = map(int, input().split())
    X = list(map(int,input().split()))

    array = []
    for i in range(len(X)):
        array.append(abs(X[i]-x))
    gcd1 = reduce(lambda a,b: fractions.gcd(a,b), array)
    print(gcd1)


if __name__ == '__main__':
    main()

Solution (Python):
import fractions
from functools import reduce
def main():
    n,x = map(int, input().split())
    X = list(map(int,input().split()))

    array = []
    for i in range(len(X)):
        array.append(abs(X[i]-x))
    reduce(lambda a,b: a-b, [1,2,3])
    gcd1 = reduce(lambda a,b: fractions.gcd(a,b), array)
    print(gcd1)


if __name__ == '__main__':
    main()

Solution (Python):
def gcdf(a):
    a.sort()
    a0=a[0]
    a=[int(x%a0) for x in a if x%a0 != 0]
    if len(a)==0:
        return a0
    else:
        a.append(a0)
        a0=min(a)
        return gcdf(a) 
    
n,x=map(int,input().split())
xi=list(map(int,input().split()))

for i in range(n):
    if xi[i]>x:
        xi[i]=xi[i]-x
    else:
        xi[i]=x-xi[i]
    
gcdx=gcdf(xi)
print(gcdx)

Solution (Python):
f=lambda:map(int,input().split())
_,x=f()
m=[abs(i-x) for i in f()]
from fractions import *
a=m.pop()
for i in m: a=gcd(a,i)
print(a)

Solution (Python):
f = lambda:map(int,input().split())
_,x = f()
m = [abs(i-x) for i in f()]
from fractions import gcd
a = m.pop()
for i in m: a = gcd(a,i)
print(a)

Solution (Python):
f = lambda:map(int,input().split())
n,x = f()
l = [x]+list(f())
m = [abs(l[i+1]-l[i]) for i in range(n)]
def gcd(a,b):
  while b:
    a,b = b,a%b
  return a
ans = m.pop()
for i in m:
  ans = gcd(ans,i)
print(ans)

Solution (Python):
n, x = map(int,input().split())
tmp = list(map(int,input().split()))
tmp.append(x)
se = list(sorted(set(tmp)))
lis = []
for si,s in enumerate(se):
    lis.append(se[si]-se[si-1])

import fractions
a = lis
ans = a[0]
for i in range(1, len(a)):
    ans = fractions.gcd(ans, a[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 i in range(1, N):
    ans = gcd(ans, abs(A[i] - X))
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()))
x.sort()
dist = []

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

tmp = []
for i in range(N):
    tmp.append(abs(x[i]-X))
mindist = min(tmp)
for i in range(N-1):
    dist.append(abs(x[i]-x[i+1]))

ans = mindist

for i in range(N-1):
    ans = gcd(ans,dist[i])

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)


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


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

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

X = int(input().split()[1])
x = [abs(int(x) - X) for x in input().split()]

print(reduce(gcd, x))

Solution (Python):
import numpy as np
n, x = map(int, input().split())
city = np.array(list(map(int, input().split())))
w = abs(city - x)


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


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

print(ans)

Solution (Python):
import sys, math
def input():
    return sys.stdin.readline()[:-1]
from itertools import permutations, combinations
from collections import defaultdict, Counter
from math import factorial
from fractions import gcd

sys.setrecursionlimit(10**7)
N, X = map(int, input().split())
xs = list(map(int, input().split()))

xs.append(X)
xs.sort()

set_num = set()
for i in range(N):
    set_num.add(xs[i+1] - xs[i])

list_num = list(set_num)
val = list_num[0]
for new_val in list_num[1:]:
    val = gcd(val, new_val)

print(val)

Solution (Python):
import fractions
a = list(map(int,input().split()))
N = a[0]
b = []
x = list(map(int,input().split()))
x.append(a[1])
x.sort()
flag = 0
for i in range(N):
    c = x[i+1] - x[i]
    if flag == 1:
        ans = fractions.gcd(c, ans) 
    else:
        ans = c 
    b.append(c)
    flag = 1
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, k = map(int, input().split())
x = [int(x) for x in input().split()]

min = abs(k-x[0])

for i in range(n-1):
    min = gcd(min, abs(x[i]-x[i+1]))

print(min)

Solution (Python):
def gcd(x1, x2):
    if x2 == 0:
        return x1
    return gcd(x2, x1 % x2)

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