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

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


def gcd(m, n):
  if n == 0:
    return m

  return gcd(n, m % n)


def gcd_2(a):
  if len(a) == 1:
    return a[0]

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

print(gcd_2(sub))

Solution (Python):
import fractions


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

if __name__ == "__main__":
    resolve()

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

N, X = map(int, input().split())
x = list(map(int, input().split()))
x.append(X)
x.sort()
if N == 1:
  print(x[1] - x[0])
elif N == 2:
  print(gcd(x[2] - x[1], x[1] - x[0]))
else:
  l = x[1] - x[0]
  for i in range(1, N - 1):
    d = x[i + 1] - x[i]
    l = gcd(l, d)
  print(l)

Solution (Python):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 
input=lambda:sys.stdin.readline().rstrip()
from fractions import gcd
from functools import reduce
def resolve():
    n, x = map(int,input().split())
    X = list(map(int,input().split()))
    for i in range(n):
        X[i] = abs(X[i] - x)

    res = reduce(gcd, X)
    print(res)
resolve()

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

Solution (Python):

n,x = map(int,input().split())
a = 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
cur_gcd = abs(x-a[0])
a.sort()
for i in range(n-1):
    cur_gcd = gcd(cur_gcd,abs(x-a[i+1]))
    
print(cur_gcd)

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

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

Xn.append(X)

Xn.sort()
B = []

for i, x in enumerate(Xn):
    if i < len(Xn)-1:
        B.append(Xn[i+1]-Xn[i])
A = B[0]

for i in B:
    A = euclid(A,i)
print(A)

Solution (Python):
from fractions import gcd

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

def gcd_calc(a):
  ans = a[0]
  for i in range(1, len(a)):
    ans = gcd(ans, a[i])
  return ans

x.sort()
cnt=0
for i,_x in enumerate(x):
  if (_x-X)>0:
    x.insert(i, X)
    cnt=1
    break
if cnt!=1:
  x.append(X)
list=[]
for i in range(len(x)-1):
  list.append(x[i+1]-x[i])

print(gcd_calc(list))

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

x.sort()
for i in range(n):
    x[i] -= first
    x[i] = abs(x[i])
import fractions
ans=x[0]
for i in x[1:]:
    ans = fractions.gcd(ans, i)

print(ans)

Solution (Python):
from fractions import gcd

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

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

def gcd(a, b):
    mod = 1
    
    while (mod > 0):
        mod = a % b
        a = b
        b = mod
    
    return (a)

gc = distant[0]

for i in range(1, len(distant)):
    gc = gcd(gc, distant[i])

print(gc)

Solution (Python):
import fractions
import sys

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

if len(li) == 1:
  print(abs(li[0] - X))
  sys.exit()
  
li.append(X)
li.sort(reverse=True)

ans = li[0] - li[1]

for index, i in enumerate(li):
  if index == 0:
    continue

  if index == len(li) - 1:
    break

  ans = fractions.gcd(ans, i - li[index+1])

print(ans)

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

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

Solution (Python):

import fractions
from functools import reduce

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

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


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

print(gcd_list(B))

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


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


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

x.append(X)

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

print(abs(dis))

Solution (Python):
from fractions import gcd
N,X=map(int,input().split(' '))
x=sorted(list(map(int,input().split(' ')))+[X],reverse=True)
x_dif=[x[i]-x[i+1] for i in range(N)]
ans = x_dif[0]
for i in x_dif:
    ans = gcd(ans,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()

diff=[0]*N

for i in range(N):
    diff[i]=x[i+1]-x[i]

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

print(g)

Solution (Python):
import fractions

n, x = [int(x) for x in input().split(' ')]
cities = [int(x) for x in input().split(' ')]

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

print(ans)

Solution (Python):
import functools
import fractions

n,x=map(int,input().split())
xx=[int(t) for t in input().split()]
buf=[]

for value in xx:
    buf.append(abs(value - x))

print(functools.reduce(fractions.gcd, buf))

Solution (Python):
from fractions import gcd

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

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

print(ans)

Solution (Python):
def gcd(a,b):
	while b>0:
		a,b = b,a%b
	return a 
N,X = input().split(" ")
N,X = int(N),int(X)

A = input().split(" ")

diff = []
for x in A:
	diff.append(abs(int(x)-X))

ans = diff[0]
for i in diff[1:]:
	ans = gcd(ans,int(i))
print(ans)

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

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.append(X)
x.sort()

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

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

print(ans)

Solution (Python):
import fractions

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

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

    if i == 0:
        ans = difs[0]
        continue

    ans = fractions.gcd(ans, difs[i])

print(ans)

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

x.sort()
def gcd(x,y):
    if y == 0:
        return x
    else:
        return gcd(y,x%y)
ans = abs(x[0]-X)
if len(x) == 1:
    print(ans)
else:
    for i in x[1:]:
        ans = gcd(abs(i-X),ans)
    print(ans)

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


def main():
    N, X = map(int, input().split(" "))
    x = list(map(int, input().split(" ")))
    abs_x = []
    for i in x:
        abs_x.append(abs(X - i))
    print(reduce(gcd, abs_x))


if __name__ == '__main__':
    main()

Solution (Python):
N,X=map(int,input().split())
x = list(map(int,input().split()))
if not X in x:
    x.append(X)
x.sort()
d = []
for i in range(len(x)-1):
    d.append( x[i+1] - x[i] )

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

g = d[0]
for i in range( len(d)-1 ):
    g = GCD(g,d[i+1])
print(g)

Solution (Python):
def solve(n, x0, X):

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

    X = [abs(x - x0) for x in X]
    g = X.pop()
    for x in X:
        g = gcd(g, x)
    return g

_n , _x0 = map(int, input().split())
_X = map(int, input().split())
print(solve(_n, _x0, _X))

Solution (Python):
from math import sqrt
x,y=map(int,input().split())
a=list(map(int,input().split()))
a.append(y)

p=set()

a.sort()
k=a[0]
for i in a[1:]:
    l=i-k
    s=set()
    for j in range(1,int(sqrt(l))+1):
        if l%j==0:
            
            s.add(l//j)
            s.add(j)
                
    if k==a[0]:
        k=i
        p=s
        
    else:
        k=i
        p=p.intersection(s)
    
print(max(p))

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

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

def int_X(x):
    return abs(int(x)-X)

ls=list(map(int_X,input().split()))

print(reduce(gcd,ls))

Solution (Python):
import fractions

n, x = map(int, input().split())
x_arr = [int(_) for _ in input().split()]

x_arr.append(x)
x_arr = sorted(x_arr)
distance = [x_arr[i+1] - x_arr[i] for i in range(0, n)]

if len(distance) == 1:
    print(distance[0])
    exit()

ans = 1000000000
for i in range(len(distance)-1):
    ans = min(ans, fractions.gcd(distance[i], distance[i+1]))

print(ans)

Solution (Python):
import fractions
from functools import reduce

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

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

numbers.append(X)
numbers = sorted(numbers)

diff_numbers = []

for i in range(len(numbers)-1):
    diff_numbers.append(abs(numbers[i] - numbers[i+1]))

gcd_num = gcd_list(diff_numbers)

print(gcd_num)

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

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



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


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


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

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

m = []
for aa in a:
  m.append(abs(X-aa))

ans = 0
import fractions
for i, g in enumerate(m):
  ans = fractions.gcd(ans, g)
  
print(ans)

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

mod = 1000000007
inf = 1 << 60
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

n, x = na()
a = na()

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

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

print(ans)

Solution (Python):

import math
import heapq
import bisect
import numpy as np
from collections import Counter
import fractions


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

x.append(X)
x.sort()

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

print(ans)

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

a=[]

x.append(m)
x.sort()
for i in range(n):
    a.append(x[i+1]-x[i])
count=a[0]

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

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

Solution (Python):
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.append(n)
  return divisors
n,x=map(int,input().split())
y=list(map(int,input().split()))
y.append(x)
y.sort()
z=[]
for i in range(n):
  z.append(y[i+1]-y[i])
z.sort()
p=make_divisors(z[0])
a=[]
for i in p:
  for j in z:
    if j%i:
      break
  else:
    a.append(i)
print(max(a))

Solution (Python):
from fractions import gcd

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

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

Solution (Python):
from fractions import gcd


def solve():
    N, X, *x = map(int, open(0).read().split())
    
    d = [abs(X - xi) for xi in x]
    ans = d[0]
    for di in d[1:]:
        ans = gcd(ans, di)
    print(ans)


if __name__ == '__main__':
    solve()

Solution (Python):

from fractions import gcd
from functools import reduce
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

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



def gcds(*numbers):
    return reduce(gcd, numbers)


print(gcds(*diff))

Solution (Python):

import sys
import math
import os
import itertools

class cin():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def mapInt():
        return [int(x) for x in cin.string().split()]
    def stringList(n):
        return [input() for i in range(n)]
    def intListList(n):
        return [cin.mapInt() for i in range(n)]

class Util():
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Util.round_up(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x
class Math():
    def gcd(a,b):
        if b == 0:
            return a
        return Math.gcd(b,a % b)

N,X = cin.mapInt()
A = cin.mapInt()
A.append(X)

def solve():
    A.sort()
    subs = [0] * (N)
    for i in range(N):
        subs[i] = A[i + 1] - A[i]
    ans = subs[0]
    for i in range(1,N):
        ans = Math.gcd(ans,subs[i])
    return ans
print(solve())

Solution (Python):
from functools import reduce

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

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

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

dx = [abs(i - x) for i in city]
print(gcd2(dx))

Solution (Python):
import numpy as np
n, x = map(int, input().split())
pos = [int(i) for i in input().split()]
pos.append(x)
pos = np.array(pos)
pos = pos - x
diff = np.abs(np.diff(pos))

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

print(gcd(diff))

Solution (Python):
import fractions


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



difflis = [0] * (n)

for i in range(n):
    difflis[i] = x[i+1] - x[i]

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

Solution (Python):
import sys
from fractions import gcd
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

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

if __name__ == '__main__':
    main()

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

tmp = [abs(X - p) for p in positions]
ans = reduce(lambda x, y: gcd(x, y), tmp)
print(ans)

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

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

Solution (Python):
import fractions
import functools

N, X = [int(i) for i in input().split()]
d = [abs(int(i) - X) for i in input().split()]
ans = functools.reduce(fractions.gcd, d)
print(ans)

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

Solution (Python):
from functools import reduce
import fractions
from warnings import simplefilter
simplefilter("ignore")
N, X = map(int, input().split())
xlist = list(map(int, input().split()))
sbn = [abs(x - X) for x in xlist]


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


print(gcd_list(sbn))

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

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

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

x.append(X)
x.sort()

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

print(ans)

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

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

X = np.abs(X - x)
X = np.sort(X)

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

Solution (Python):
import sys

INPUT = lambda: sys.stdin.readline().rstrip()
MAP = lambda: map(int, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))

sys.setrecursionlimit(10 ** 9)


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


def main():
    N, X = MAP()
    x = LIST()

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

    for d in make_divisors(max(x)-min(x)):
        for i in range(N):
            if abs(X - x[i]) % d != 0: break
        else:
            print(d)
            sys.exit()


if __name__ == '__main__':
    main()

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

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

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

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

answer = 0
for a in A:
  answer = gcd(answer, a)

print(answer)

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

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

D = []
for a in A:
  D.append(abs(X - a))

answer = 0
for d in D:
  answer = gcd(answer, d)

print(answer)

Solution (Python):
import fractions
import functools

N, X = map(int, input().split())
cities = []
for city in list(map(int, input().split())):
    cities.append(city - X)
gcd = functools.reduce(fractions.gcd, cities)
print(gcd if gcd > 0 else -gcd)

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

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

import functools
import fractions
gcd=functools.reduce(fractions.gcd,B)
print(gcd)

Solution (Python):
import fractions 

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

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

ans=10**10
if n==1:
    print(x[0])
    exit()
for g in range(1,n):
    ans=min(ans,fractions.gcd(x[g-1],x[g]))
print(ans)

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

import fractions as math
ans=x[0]
for j in range(1,N):
  ans=math.gcd(ans,x[j])
print(ans)

Solution (Python):
from fractions import gcd

N, X = map(int, input().split())
xlist = list(map(int, input().split()))
gaplist = []
for i in range(N):
    tmp = abs(xlist[i] - X)
    if tmp==0:
        tmp = 1
    gaplist.append(tmp)

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

print(ans)

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

Solution (Python):
from fractions import gcd
n,x = map(int,input().split())
a = list(map(int, input().split()))
a.append(x)
a = sorted(a)
b = [0]*n
for i in range(n):
    b[i]= a[i+1]-a[i]
c = 0
for j in b:
    c = gcd(c, j)
print(c)

Solution (Python):
import fractions

n, s = map(int, input().split())
x = list(map(int, input().split()))
x.append(s)
m = min(x)
xr = [e - m for e in x]
ans = xr[0]
for i in range(1, n+1):
    ans = fractions.gcd(ans, xr[i])
print(ans)

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

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


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

    x.append(X)
    x.sort()

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

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

    print(ans)


    
    


if __name__ == '__main__':
    main()

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

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

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

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(n-1):
    ans = gcd(ans,X[i+1])
print(ans)

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

Solution (Python):
import sys
from functools import reduce

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

n, X, *x = map(int, sys.stdin.read().split())

def main():
    x.append(X)
    for i in range(n):
        x[i] -= x[i+1]
    x[-1] -= X
    
    return reduce(gcd, x)

if __name__ == '__main__':
    ans = main()
    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())
y = list(map(int,input().split()))
dist = []
for b in y:
    dist.append(abs(b-x))
print(gcd_list(dist))

Solution (Python):
import fractions
from functools import reduce

def gcd_ls(num):
	return reduce(fractions.gcd, num)

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

ls_sa = [0] * n

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

print(gcd_ls(ls_sa))

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

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

Solution (Python):
import fractions
n,x=map(int, input().split())
*l,=map(int, input().split())
l.append(x)
l.sort(reverse=True)
ans=0
sa1=0
sa2=0
if n==1:
    print(abs(x-(abs(x-sum(l)))))
else:
    for i in range(n-1):
        sa1=l[i]-l[i+1]
        sa2=l[i+1]-l[i+2]
        ans=fractions.gcd(fractions.gcd(sa1,sa2),ans)
    print(ans)

Solution (Python):
import fractions

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

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

m = abs(d[0] - x)
for di in d:
  m = fractions.gcd(m, abs(di - x))

print(m)

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

X = [ abs(y-x) for y in X ]
ans = X[0]
for y in X[1:]:
    ans = gcd(ans, y)
print(ans)

Solution (Python):

import fractions
from functools import reduce

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

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

ans = reduce(fractions.gcd, xs)

print(ans)

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

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

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


def main():
    N, X, *xn = map(int, open(0).read().split())
    ans = abs(X - xn[0])
    for x in xn:
        df = abs(X - x)
        if df % ans:
            ans = gcd(ans, df)
    print(ans)
    return


main()

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


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


main()

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


def main():
    N, X, *xn = map(int, open(0).read().split())
    ans = abs(X - xn[0])
    for x in xn:
        div = abs(X - x)
        if div % ans:
            ans = gcd(ans, div)
    print(ans)
    return


main()

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


def main():
    N, X, *xn = map(int, open(0).read().split())
    ans = None
    for x in xn:
        if ans is None:
            ans = abs(X - x)
        else:
            div = abs(X - x)
            if div % ans:
                ans = gcd(ans, div)
    print(ans)
    return


main()

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


def main():
    N, X, *xn = map(int, open(0).read().split())
    ans = None
    for x in xn:
        div = abs(X - x)
        if ans is None:
            ans = div
        elif div % ans:
            ans = gcd(ans, div)
    print(ans)
    return


main()

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


def main():
    N, X, *xn = map(int, open(0).read().split())
    ans = None
    for x in xn:
        div = abs(X - x)
        if ans is None:
            ans = div
        elif abs(X - x) % ans:
            ans = gcd(ans, abs(X - x))
    print(ans)
    return


main()

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


def main():
    N, X, *xn = map(int, open(0).read().split())
    ans = None
    for x in xn:
        if ans is None:
            ans = abs(X - xn[0])
        elif abs(X - x) % ans:
            ans = gcd(ans, abs(X - x))
    print(ans)
    return


main()

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

B = []
for i in range(N):
    b = abs(A[i] - X)
    B.append(b)


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

B.sort()

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

print(ans)

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


def main():
    N, X, *xn = map(int, open(0).read().split())
    ans = None
    for x in xn:
        if ans is not None:
            if abs(X - x) % ans:
                ans = gcd(ans, abs(X - x))
        else:
            ans = abs(X - xn[0])
    print(ans)
    return


main()

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


def main():
    N, X, *xn = map(int, open(0).read().split())
    ans = None
    for x in xn:
        if ans is not None:
            ans = gcd(ans, abs(X - x))
        else:
            ans = abs(X - xn[0])
    print(ans)
    return


main()

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


def gcd_n(numbers):
    ret = numbers[0]
    for i in range(len(numbers)):
        ret = gcd(ret, numbers[i])
    return ret


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


main()

Solution (Python):
from functools import reduce


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


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


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


main()

Solution (Python):
from functools import reduce


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


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


def main():
    N, X, *x = map(int, open(0).read().split())
    x = [abs(X - int(i)) for i in x]
    print(gcd_n(x))
    return


main()