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

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

xl.append(x)
xl.sort()
res = None
for i in range(n):
    d = xl[i+1] - xl[i]
    if res is None:
        res = d
    else:
        res = gcd(res, d)
print(res)

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

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

res = 0
for i in P:
    if res:
        res = kouyaku(res, abs(X - i))
    else:
        res = abs(X - i)

print(res)

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


def main():
    N, x = map(int, input().split())
    y = list(map(int, input().split()))
    y = [abs(i - x) for i in y]
    ans = y[0]
    for i in y[1:]:
        ans = gcd(i, ans)

    print(ans)

main()

Solution (Python):
def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)
def inpl(): return [int(i) for i in input().split()]

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

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

l=list(map(int,input().split()))
l=list(map(lambda i: abs(i-x),l))

x = reduce(gcd,l)
print(x)

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

def euclid(m,n):
    while n:
        m,n=n,m%n
    return m

N,X=map(int,input().split(" "))
x=np.array(list(map(int, input().split(' '))))
y=abs(x-X)
print(reduce(euclid,y))

Solution (Python):
from fractions import gcd


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

diffs = [abs(x - X) for x in xs]

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

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


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


if __name__ == "__main__":
    main()

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

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

def gcd(x,y):
    if y==0:
      return x
    else:
      return gcd(y,x%y) 
    
if n==1:
  x=l[0]
else:
  x=gcd(l[0],l[1])
  if n>2:
    for i in range(2,n):
      x=gcd(x,l[i])
print(x)

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.append(X)
x.sort()
array = []
for i in range(N):
    array.append(x[i+1]-x[i])

if len(array) > 1:
    result = gcd(array[0], array[1])
    for i in range(2, len(array)):
        result = gcd(result, array[i])
else:
    result = array[0]
    
print(result)

Solution (Python):
from fractions import gcd
n,x=map(int, input().split())
x = list(map(int, input().split())) + [x]
x.sort()
ret = x[1] - x[0]

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

print(ret)

Solution (Python):
from fractions import gcd
N,X = map(int,input().split())
src = list(map(int,input().split()))
src.sort()

g = abs(X - src[0])
for a,b in zip(src,src[1:]):
    d = b-a
    g = gcd(g, d)
print(g)

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


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

N, X = [int(elem) for elem in fin().split()]
x_list = [int(elem) for elem in fin().split()]

distance = [abs(x_list[i] - X) for i in range(N)]
D = distance[0]
for i in range(1, N):
    D = gcd(D, distance[i])

print(D)

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

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

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

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

print(d)

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

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

s=abs(A[0]-X)
for i in range(1,N):
    s=gcd(s,abs(A[i]-X))

print(s)

Solution (Python):
def gcd(g, s):
    while g % s != 0:
        s, g = sorted([g,s])
        g = g % s
    return s

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

    for i in range(n):
        X[i] -= x
        if X[i] < 0:
            X[i] *= -1

    m = X[0]
    for c in X[1:]:
        m = gcd(c,m)

    print(m)

if __name__ == "__main__":
    main()

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

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

n, x = (int(i) for i in input().split(" "))
xn = (int(i) for i in input().split(" "))

nums = [abs(xi-x) for xi in xn]

b = nums[0]
for v in nums[1:]:
    b = gcd(b,v)

print(b)

Solution (Python):



n, x =  [int(i) for i in raw_input().split()]
xx = [int(i) for i in raw_input().split()]

s = []
for i in xx:
    a = x - i
    if a < 0:
        s.append(-a)
    else:
        s.append(a)

import fractions
v = s[0]
for b in s[1:]:
    v = fractions.gcd(b, v)
print v

Solution (Python):



n, x =  [int(i) for i in raw_input().split()]
xx = [int(i) for i in raw_input().split()]

s = []
for i in xx:
    a = x - i
    if a < 0:
        s.append(-a)
    else:
        s.append(a)

import fractions
v = s[0]
for b in s[1:]:
    v = fractions.gcd(b, v)
print v

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


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

X.append(St)
X = sorted(X)

del_X = []
for i in range(N):
    del_X.append(X[i+1] - X[i])
del_X = sorted(list(set(del_X)))




for i in range(len(del_X)):
    if i == 0:
        tmp = gcd(del_X[i],0)
    else:
        tmp = gcd(tmp, del_X[i])
print(tmp)

Solution (Python):
def gcd(a, b):
    """
    最大公約数
    """
    if b > a:
        a, b = b, a
    c = a % b
    return b if c == 0 else gcd(b, c)


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

m = xlist[1] - xlist[0]
for i in range(1, len(xlist) - 1):
    d = xlist[i + 1] - xlist[i]
    m = gcd(d, m)
print(m)

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


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

m = xlist[1] - xlist[0]
for i in range(1, len(xlist) - 1):
    d = xlist[i + 1] - xlist[i]
    m = gcd(d, m)
print(m)

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


def m():
    n, x = map(int, input().split())
    a = list(map(int, input().split()))
    b = [0] * n

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

    tmp = b[0]
    for i in range(n):
        tmp = gcd(tmp, b[i])

    return tmp

print(m())

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


def main():
    n, x = list(map(int, input().split()))
    values = list(map(int, input().split()))
    values.append(x)
    values.sort()
    v = [values[i + 1] - values[i] for i in range(len(values) - 1)]
    res = v[0]
    print(reduce(gcd, v[1:], v[0]))


if __name__ == "__main__":
    main()

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

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

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

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


N ,X = list(map(int,input().strip().split()))
xlist = list(map(int,input().strip().split()))
abs_xlist = list(map(lambda x:abs(X - x), xlist))
abs_xlist.sort()
ans = abs_xlist[0]

for i in range(N):
    num = gcd(abs_xlist[i],ans)
    ans = min(num,ans)
print(ans)

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


N ,X = list(map(int,input().strip().split()))
xlist = list(map(int,input().strip().split()))
abs_xlist = list(map(lambda x:abs(X - x), xlist))
abs_xlist.sort()
ans = abs_xlist[0]

for i in range(N):
    if abs_xlist[i] % ans != 0:
        num = gcd(abs_xlist[i],ans)
        ans = min(num,ans)
print(ans)

Solution (Python):
N,X = map(int, input().split())
def myabs(i):
    return abs(i-X)
xlis = list(map(myabs, map(int, input().split())))


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

res = xlis[0]
for i in xlis:
    if i%res == 0:
        continue
    res = gcd(i,res)

print(res)

Solution (Python):
N,X = map(int, input().split())
def myabs(i):
    return abs(i-X)
xlis = list(map(myabs, map(int, input().split())))

from fractions import gcd

res = xlis[0]
for i in xlis:
    if i%res == 0:
        continue
    res = gcd(i,res)

print(res)

Solution (Python):
N,X = map(int, input().split())
def myabs(i):
    return abs(i-X)
xlis = list(map(myabs, map(int, input().split())))

from fractions import gcd

res = xlis[0]
for i in xlis:
    res = gcd(i,res)

print(res)

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


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

    y = x[0]
    for i in range(N):
        if x[i]%y == 0:
            continue
        y = gcd(y, x[i])
    print(y)


if __name__ == '__main__':
    main()

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


bet2=[]
for i in range(len(bet)-1):
	if 	bet[i+1] != bet[i]:
		bet2.append(bet[i+1]-bet[i])
bet2.sort()


key=bet2[0]
keylen=[key]
i=0
while i < len(bet2):
	if bet2 [i]!=key:
		keylen.append(bet2[i])
		key=bet2[i]
	else:
		i+=1



def multiple(num,k):
	if num %k==0:
		return k
	else:
		return multiple(k,num%k)

while len(keylen) != 1:
	mult=[]
	for i in keylen:
		for j in keylen[keylen.index(i)+1:]:
			if j % i != 0:
				mult.append(multiple(i,j))
			else:
				keylen.remove(j)
	keylen.extend(mult)
	keylen.sort()

print(keylen[0])

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

Solution (Python):
from functools import reduce

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

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

N, X = list(map(int, input().split()))
x = list(map(int, input().split()))
diff = [abs(xi - X) for xi in x]
print(gcd_list(diff))

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

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

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

N, X = list(map(int, input().split()))
x = list(map(int, input().split()))
diff = [abs(xi - X) for xi in x]
print(gcd_list(diff))

Solution (Python):
from functools import reduce

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

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

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

x_sorted = x
x_sorted.append(X)
x_sorted.sort()

diff = []
for i, xi in enumerate(x_sorted):
    if i == 0:
        continue
    else:
        diff.append(xi - x_sorted[i-1])

print(gcd_list(diff))

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

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

Solution (Python):
def gcd(m,n):   
    if(n==0):    return m
    else:    return gcd(n,m%n)

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

print(ans)

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


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

Solution (Python):

import fractions

N,X=input().split()
N=int(N)
X=int(X)
x = [int(i) for i in input().split()]
x.append(X)
x.sort()
de=[]
for i in range( 0, len(x)-1 ):
    dei=x[i+1]-x[i]
    if(dei>0):
        de.append(dei)




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

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


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

b=abs(l[0]-l[1])
li=[b]
lis=[]

for i in range(1,len(l)-1):
    a=abs(l[i]-l[i+1])
    li.append(a)
    b=min(a,b)
li=set(li)
for i in range(1,round(math.sqrt(b)+1)):
    if b%i==0:
        lis.append(i)
        lis.append(b//i)
lis.sort()

for i in lis:
    for j in li:
        if j%i!=0:
            break
    else:
        num=i
print(num)

Solution (Python):
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b



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



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


def main():
    N, X = map(int, input().split())
    l = list(map(int, input().split()))

    if X not in l:
        l.append(X)
    l.sort()

    ans = None
    for i in range(len(l) - 1):
        diff = l[i + 1] - l[i]
        if ans is None:
            ans = diff
        else:
            ans = gcd(ans, diff)
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
def abc109_c():
    import numpy as np
    import functools
    import fractions
    n, x = map(int, input().split())
    x = np.abs(np.array(list(map(int, input().split()))) - x)
    gcd = functools.reduce(fractions.gcd, x)
    return gcd


print(abc109_c())

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

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

xn += [x]
xn = np.abs(np.diff(xn))
print(reduce(fractions.gcd, xn))

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 = x+[X]
x.sort()
d = [x[i+1]-x[i] for i in range(N)]
D = d[0]
for i in range(1,N):
    D = gcd(D,d[i])
print(D)

Solution (Python):

import numpy as np

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

N,X = list(map(int,input().split()))
x = np.array(list(map(int,input().split())))
X_l = np.array([X] * N)
diff = np.unique(abs(x - X_l))

a = diff[0]
for i in range(1, len(diff)):
    b = diff[i]
    a = gcd(a, b)
    
print(a)

Solution (Python):

from functools import reduce
from fractions import gcd

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

print(reduce(gcd, Y, 0))

Solution (Python):
from functools import reduce



from fractions import gcd

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

print(reduce(gcd, d, 0))

Solution (Python):
def yakusuu(i,m):
    _i=i
    while(i**2<=m):
        if(m%i==0):
            return i
        else:
            i+=1
    for j in range(_i-1,0,-1):
        if(m%j==0):
            break
    return m//j



def factoring(N,result):
    original_N=N
    tmp=2
    while(tmp<=N and (tmp-1)**2<=original_N):
        tmp=yakusuu(tmp,N)
        result.append(tmp)

        N//=tmp



N,start=map(int,input().split())
x=list(map(int,input().split()))
tmp_list=[]
factoring(abs(x[0]-start),tmp_list)
for i in range(N-1):
    now=abs(x[i]-x[i+1])
    new_list=[]
    for j in tmp_list:
        if(now%j==0):
            now//=j
            new_list.append(j)
    tmp_list=[new_list[i] for i in range(len(new_list))]

ans=1
for j in tmp_list:
    ans*=j
print(ans)

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

def find_gcd(a, b):
    if b % a == 0:
        return a
    else:
        while b % a != 0:
            r = b % a
            b = a
            a = r
        return a

if n == 1:
    print abs(x - arr[0])
else:
    arr.append(x)
    arr.sort()
    dis_arr = []
    for i in range(n):
        dis_arr.append(abs(arr[i]-arr[i+1]))

    dis_arr.sort()
    for i in range(n-1):
        fir = dis_arr[i]
        sec = dis_arr[i+1]
        dis_arr[i+1] = find_gcd(fir, sec)
    print dis_arr[n-1]

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

def find_gcd(a, b):
    if b % a == 0:
        return a
    else:
        while b % a != 0:
            r = b % a
            b = a
            a = r
        return a

if n == 1:
    print abs(x - arr[0])
else:
    arr.append(x)
    arr.sort()
    dis_arr = []
    for i in range(n):
        dis_arr.append(abs(arr[i]-arr[i+1]))

    dis_arr.sort()
    for i in range(n-1):
        fir = dis_arr[i]
        sec = dis_arr[i+1]
        dis_arr[i+1] = find_gcd(fir, sec)
    print dis_arr[n-1]

Solution (Python):
import math

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

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

for i in range(len(li_x)):
  if li_x[i] - x < 0:
    li_x[i] =x - li_x[i]
  else:
    li_x[i] = li_x[i] -x

if len(li_x)==1:
  print(li_x[0])

elif len(li_x)==2:
  print(gcd(li_x[0],li_x[1]))

else:
  g =gcd(li_x[0],li_x[1])
  k=2
  while k<len(li_x):
    g=gcd(g,li_x[k])
    k+=1
  print(g)

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

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

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

N, X = [int(item) for item in input().split()]
cities = [int(item) for item in input().split()]
if N == 1:
  print(abs(cities[0]-X))
  exit()

mod = gcd(abs(cities[0] - X), abs(cities[1] - X))
for i in range(2, N):
  mod = gcd(mod, abs(cities[i] - X))
print(mod)

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.append(X)
x.sort()
ans = x[1]-x[0]
for i in range(N):
    ans = gcd(ans,x[i+1]-x[i])
print(ans)

Solution (Python):
N, X = map(int, input().split(' '))
xl = list(map(int, input().strip().split()))
for i in range(len(xl)):
    xl[i]=abs(xl[i]-X)

ans=0
for i in range(len(xl)-1):
    while True:
        if xl[i]==0:
            break
            
        a=xl[i]
        xl[i]=xl[i+1]%xl[i]
        xl[i+1]=a


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

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


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


q = X[0]
for i in range(1, N):
    q = gcd(q, X[i])

print(q)

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

z = x
z.append(X)
z.sort()

w = []

for i in range(n + 1):
    if i != 0:
        w.append(z[i] - z[i - 1])

n1=len(w)


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


if n1==1:
    print(w[0])
else:
    element = gcd(w[0], w[1])
    if n1==2:print(element)
    else:
        for i in range(2,n1):
            element=gcd(element,w[i])
        print(element)

Solution (Python):
def quick_sort(arr):
    left = []
    right = []
    if len(arr) <= 1:
        return arr

    
    
    ref = arr[0]
    ref_count = 0

    for ele in arr:
        if ele < ref:
            left.append(ele)
        elif ele > ref:
            right.append(ele)
        else:
            ref_count += 1
    left = quick_sort(left)
    right = quick_sort(right)
    return left + [ref] * ref_count + right

def LCM(m,n):
  if m>n:
    m,n=n,m
  for i in range(1,m+1)[::-1]:
    if n%i==0:
      return i
    
N,X=(int(i) for i in input().split(' '))
x=[int(i) for i in input().split(' ')]
x=[X]+x
x=quick_sort(x)
D=abs(x[1]-x[0])
for i in range(N):
  D=LCM(D,abs(x[i+1]-x[i]))
print(D)

Solution (Python):
import collections
from fractions import gcd

inputs = []
N, X = map(int, input().split())
inputs = list(map(int, input().split()))
inputs.append(X)
inputs.sort()
D = []
for i in range(len(inputs)-1):    
    D.append(abs(inputs[i] - inputs[i+1]))

uniqueD = list(set(D))


result = uniqueD[0]
for i in range(len(uniqueD)):
    result = gcd(result, uniqueD[i])

print(result)

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

li2 = [i-x for i in li]
li3 = [abs(i) for i in li2]
b = li3[0]

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

for i in li3:
    b = gcd(b,i)

print(b)

Solution (Python):
import fractions
import functools

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

x_list.append(X)
x_list.sort()

x_len = list()
for i in range(1,N+1):
    x_len.append(x_list[i]-x_list[i-1])

x_len.sort(reverse = True)

result = functools.reduce(fractions.gcd,x_len)

print(result)

Solution (Python):
import fractions

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

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

print(min_n)

Solution (Python):


from functools import reduce


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


def solve(seq):
    if len(seq) == 2:
        return abs(seq[0] - seq[1])

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

    return reduce(mcd, sorted(satisfy, reverse=True))


if __name__ == "__main__":
    firstline_input = list(map(int, input("").split(" ")))
    seq = list(map(int, input("").split(" ")))
    seq.insert(0, firstline_input[1])
    print(solve(seq))

Solution (Python):


from functools import reduce


def mcd(x, y):
    if x > y:
        big = x
        small = y
    else:
        big = y
        small = x
    while True:
        rest = big % small
        if rest == 0:
            return small
        else:
            big = small
            small = rest


def solve(seq):
    satisfy = []  
    for i in range(len(seq) - 1):
        satisfy.append(abs(seq[i] - seq[i + 1]))

    if len(satisfy) == 1:
        return satisfy[0]

    return reduce(mcd, satisfy)


if __name__ == "__main__":
    firstline_input = list(map(int, input("").split(" ")))
    seq = list(map(int, input("").split(" ")))
    seq.insert(0, firstline_input[1])
    print(solve(seq))

Solution (Python):



def mcd(x, y):
    if x > y:
        big = x
        small = y
    else:
        big = y
        small = x
    while True:
        rest = big % small
        if rest == 0:
            return small
        else:
            big = small
            small = rest


def solve(seq):
    satisfy = []  
    for i in range(len(seq) - 1):
        satisfy.append(abs(seq[i] - seq[i + 1]))
    

    if len(satisfy) == 1:
        return satisfy[0]

    mcds = []
    for i in range(len(satisfy) - 1):
        mcds.append(mcd(satisfy[i], satisfy[i + 1]))
    

    return min(mcds)


if __name__ == "__main__":
    firstline_input = list(map(int, input("").split(" ")))
    seq = list(map(int, input("").split(" ")))
    seq.insert(0, firstline_input[1])
    print(solve(seq))

Solution (Python):
import fractions
from functools import reduce
 
N, X = map(int, input().split())
 
L = []

def minus_X(n):
  return abs(n - X)

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

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

L2 = map(minus_X, L)
 
print(gcd_list(L2))

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

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


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

Solution (Python):
import fractions

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

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

print(ret)

Solution (Python):
from functools import reduce

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

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

def calc(n_list):
    return reduce(_calc, n_list)

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

print(calc(c))

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

Solution (Python):
import fractions
from functools import reduce


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


N, X=map(int,input().split( ))
x=list(map(int,input().split( )))
def minus_d(x):
	x = abs(x-X)
	return x

def percent_d(x):
	x = x % d
	return x

dis = list(map(minus_d, x))
ans = gcd_list(dis)
print(ans)

Solution (Python):

import math
from functools import reduce
a,b=input().split()
l=sorted([abs(int(x)-int(b)) for x in input().split()])

def gcd(a,b):
    if a < b:
        a,b = b,a
    if  b==0:
        return a
    c = a % b
    return gcd(b,c)
while len(l)!=1:
    l.append(gcd(l.pop(0),l.pop(-1)))
print(sum(l))

Solution (Python):
N, X = [int(_) for _ in input().split()]
xs = [abs(int(_) - X) for _ in input().split()]

def gcd(p, q):
    while q != 0:
        p, q = q, p % q
    return p

y = xs[0]
for i in range(N):
    if xs[i] % y != 0:
        y = gcd(y, xs[i])

print(y)

Solution (Python):
from fractions import gcd
import numpy as np
n, x0 = map(int, input().split())
x = np.abs(np.array(list(map(int, input().split()))) - x0)
xx = x[0]
for i in range(1, n):
    xx = gcd(xx, x[i])
print(xx)

Solution (Python):
import sys
from fractions import gcd


def main():
    n, x = map(int, input().split())
    xs = list(map(int, input().split()))

    ans = 0

    for i in range(n):
        xs[i] -= x
        if xs[i] < 0:
            xs[i] *= -1
        ans = gcd(ans, xs[i])

    print(ans)


if __name__ == '__main__':
    main()

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

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

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

if(n==1):
    print(abs(y[0]-z))
    sys.exit()
y=np.array(y)
y=y-z
a=np.min(abs(y))
t=[]
for i in range(1,n):
    t.append(abs(y[i]-y[i-1]))

print(fractions.gcd(a,gcd_list(t)))

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

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

distance = [0] * N
remain = []


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


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

    if(i == 0):
        continue

    
    a = distance[i-1]
    b = distance[i]
    if(distance[i-1] < distance[i]):
        temp = a
        a = b
        b = temp

    r = a % b
    while(r != 0):
        a = b
        b = r
        r = a % b

    remain.append(b)

print(min(remain))

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

Solution (Python):
import fractions

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

if n == 1:
  print(x[0])
  exit()
  
d = x[0]
for t in x[1:n]:
  d = fractions.gcd(d,t)
print(d)

Solution (Python):



def get_line():
    return input()


def get_tokens():
    return get_line().split()


def get_ints():
    return [int(_) for _ in get_tokens()]


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


from functools import reduce


def main():
    N, X = get_ints()
    x = get_ints()
    x = [abs(_ - X) for _ in x]

    print(reduce(gcd, x))


if __name__ == '__main__':
    main()

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

def gcd(x1,x2):
    while x2 != 0:
        x1,x2 = x2, x1%x2
    return x1

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

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

Solution (Python):



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




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



shiftedX = [x - X for x in xlist]



maxDivisor = shiftedX[0]
for n in shiftedX:
    maxDivisor = gcd(maxDivisor, n)

print(maxDivisor)

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

u = []

for i in range(n):
	u.append(abs(s[i]-x))
import math

m = u[0]


s = []
for i in range(math.floor(math.sqrt(m))+3):
	if m%(i+1)==0:
		if (i+1) not in s:
			s.append(i+1)
		if m//(i+1) not in s:
			s.append(m//(i+1))
s.sort()

x = 0

for i in range(len(s)):
	for j in range(n):
		if u[j]%s[i]!=0:
			break
	else:
		x = max(x,s[i])
print(x)