Problem:
 Score : 300 points    Problem Statement There are N cities on a number line. The i -th city is located at coordinate x_i .  Your objective is to visit all these cities at least once.  In order to do so, you will first set a positive integer D .  Then, you will depart from coordinate X and perform Move 1 and Move 2 below, as many times as you like:   Move 1 : travel from coordinate y to coordinate y + D .  Move 2 : travel from coordinate y to coordinate y - D .   Find the maximum value of D that enables you to visit all the cities.  Here, to visit a city is to travel to the coordinate where that city is located.      Constraints  All values in input are integers.  1 \leq N \leq 10^5  1 \leq X \leq 10^9  1 \leq x_i \leq 10^9  x_i are all different.  x_1, x_2, ..., x_N \neq X         Input Input is given from Standard Input in the following format:  N  X  x_1  x_2  ...  x_N       Output Print the maximum value of D that enables you to visit all the cities.        Sample Input 1 3 3
1 7 11      Sample Output 1 2  Setting D = 2 enables you to visit all the cities as follows, and this is the maximum value of such D .   Perform Move 2 to travel to coordinate 1 .  Perform Move 1 to travel to coordinate 3 .  Perform Move 1 to travel to coordinate 5 .  Perform Move 1 to travel to coordinate 7 .  Perform Move 1 to travel to coordinate 9 .  Perform Move 1 to travel to coordinate 11 .        Sample Input 2 3 81
33 105 57      Sample Output 2 24       Sample Input 3 1 1
1000000000      Sample Output 3 999999999

Solution (Python):
import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    N, X = MI()
    L = LI()
    L = [abs(i-X) for i in L]
    ans = L[0]
    for i in L:
        ans = math.gcd(ans, i)
    print(ans)
    
    
if __name__ == "__main__":
    main()

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

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

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

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


ans = 10**10
if len(xdst) == 1:
    print(xdst[0])
    exit()

for i in range(N-1):
    ans = min(math.gcd(xdst[i], xdst[i+1]),ans)
print(ans)

Solution (Python):
from math import gcd
n, x = map(int, input().split())
ls = sorted(list(map(int, input().split())))
if x == 1:
    print(abs(x-ls[0]))
    exit()
distant = []
for i in range(n):
    diff = abs(ls[i]-x)
    distant.append(diff)
distant.sort()
a = distant[0]
for i in distant:
    g = gcd(a, i)
    a = g
print(g)

Solution (Python):
import sys,math
n,x=map(int,sys.stdin.readline().split())
xl=[*map(int,sys.stdin.readline().split())]
yl=[abs(x-i) for i in xl]


d=yl[0]
for i in range(n):
    d=math.gcd(d,yl[i])

print(d)

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

import math
ans = a[0]
for i in range(n-1):
    ans = math.gcd(ans,a[i+1])
print(ans)

Solution (Python):
from math import gcd
def readinput():
    n,x=map(int,input().split())
    xx=list(map(int,input().split()))
    return n,x,xx

def main(n,x,xx):
    y=[0]*len(xx)
    for i in range(len(xx)):
        y[i] = abs(xx[i] - x)
    if len(y)==1:
        ans=y[0]
    else:
        ans=gcd(y[0],y[1])
        for i in range(2,n):
            ans=gcd(ans,y[i])
    return ans

if __name__=='__main__':
    n,x,xx=readinput()
    ans=main(n,x,xx)
    print(ans)

Solution (Python):
import sys
import math

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

gcd = abs(X - A[0])
for a_i in A:
    gcd = math.gcd(gcd, abs(X-a_i))

print(gcd)

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

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

print(ans)

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

xi.sort()
diff = []
for i in range(n):
    diff.append(abs(xi[i]-x))

import numpy
print(numpy.gcd.reduce(diff))

Solution (Python):
from math import gcd

n,x = map(int,input().split())
c = list(map(int,input().split()))
c.append(x)
c.sort()
arr = []
for i in range(n):
    arr.append(abs(c[i]-c[i+1]))
ans = arr[0]
if n>1:
    ans = gcd(arr[0],arr[1])
    for i in range(2,n):
        ans = gcd(ans,arr[i])
print(ans)

Solution (Python):
import math
from functools import reduce
def gcd(numbers):
    return reduce(math.gcd, numbers)
a = list(map(int,input().split()))
b = list(map(int,input().split()))
b.append(a[1])
c = sorted(b)
d = []
for i in range(a[0]):
  d.append(c[i+1]-c[i])
print(gcd(d))

Solution (Python):
import math
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=math.gcd(ans,diff[i])

print(ans)

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

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

Solution (Python):
from math import gcd

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

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

dis = []

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

res = 0

for i in range(N):
   res = gcd(res, dis[i])

print(res)

Solution (Python):





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






def solve(N, X, x):
    x_abs = [abs(X - xi) for xi in x]
    ans = x_abs[0]
    for xi in x_abs[1:]:
        ans = gcd(ans, xi)
    print(ans)


if __name__ == '__main__':
    N, X = map(int, input().split())
    x = [int(i) for i in input().split()]
    solve(N, X, x)

Solution (Python):
import sys
import math
from functools import reduce

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

l=[]

for i in x:
        b=abs(i-k)
        l.append(b)

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

ans=(gcd_list(l))

print(ans)

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

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

res = a[0]
for i in range(n):
  res = gcd(res,a[i])
print(res)

Solution (Python):
n,x=map(int,input().split())
xlist= list(map(int,input().split()))
if n == 1:
  print(abs(xlist[0]-x))
  exit()
ylist = []
for i in range(n):
  ylist.append(abs(xlist[i]-x))
from functools import reduce
from math import gcd
print(reduce(gcd,ylist))

Solution (Python):
import math

def gcd_list(nums):
  gcd = nums[0]
  for i in range(1,len(nums)):
    gcd = math.gcd(gcd,nums[i])
  return gcd

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

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

print(gcd_list(x))

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

def mapt(fn, *args):
    return list(map(fn, *args))
 
 
def Input():
    return mapt(int, input().split(" "))
 
def main():
    N, X = Input()
    x = Input()
 
    if N == 1:
        print(abs(x[0] - X))
        exit()
 
    x.append(X)
    x.sort()
    data = [abs(x[i] - x[i+1]) for i in range(N)]
 
    ans = data[0]
    for i in range(1, N):
        ans = gcd(data[i], ans)
    print(ans)
 
 
 
main()

Solution (Python):
import math

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

ans = []
for xx in X:
    ans.append(abs(x-xx))
    
a = ans[0]
for aa in ans:
    a = math.gcd(aa, a)
    
print(a)

Solution (Python):

"""
Created on Tue Sep 15 01:58:46 2020

@author: liang
"""

from math import gcd

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

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

Solution (Python):
from math import gcd

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

aX = list(map(lambda x: abs(x-X), xs))

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

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,x = inpl()
a = inpl()
now = abs(a[0]-x)
for i in range(1,n):
    now = math.gcd(abs(a[i] - x),now)
print(now)

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

n,x = map(int,input().split())
l = list(map(int,input().split()))
l.sort()
tmp = abs(l[0]-x)

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

print(tmp)

Solution (Python):
import fractions

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

l.append(x)
sl=sorted(l)

lis=[sl[i+1]-sl[i] for i in range(n)]

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

Solution (Python):
import math

N,X=map(int,input().split())
x=list(map(int,input().split()))
D=abs(x[0]-X)
for i in range(1,N):
    D=math.gcd(D,abs(x[i]-X))
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[i]-x)
from math import gcd
ans=X[0]
for i in range(1,n):
  ans=gcd(ans,X[i])

print(ans)

Solution (Python):

import sys
import math
import decimal
import itertools
from itertools import product
from functools import reduce

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

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

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

    print(gcd(*d))


def input():
    return sys.stdin.readline()[:-1]
def gcd(*numbers):
    return reduce(math.gcd, numbers)
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
def sort_zip(a:list, b:list):
    z = zip(a, b)
    z = sorted(z)
    a, b = zip(*z)
    a = list(a)
    b = list(b)
    return a, b

if __name__ == '__main__':
    main()

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

Solution (Python):
from math import gcd

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

now = a[0]
for i in a:
    now = gcd(now, i)

print(now)

Solution (Python):
import functools
import math

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

D = functools.reduce(lambda acc, x: math.gcd(acc, x), x_list, 0)

print(D)

Solution (Python):
import functools
import math

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

x_list.append(X)
num_list = sorted(x_list)
 
tmp = map(lambda x: abs(x[0] - x[1]),
          zip(num_list[:-1],num_list[1:]))

D = functools.reduce(lambda acc, x: math.gcd(acc, x), tmp, 0)

print(D)

Solution (Python):
import math
from functools import reduce

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

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

a = [abs(x - i) for i in xx]

print(gcd(*a))

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

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

ans=0
for x in x_list:
  ans=gcd(ans, x)
print(abs(ans))

Solution (Python):
import math
from functools import reduce

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

print(reduce(math.gcd,[X[i+1]-X[i] for i in range(n)]))

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

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

print(reduce(gcd, [abs(i-x) for i in c]))

Solution (Python):
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right 
from heapq import heapify, heappop, heappush
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)

N,X = mint()
x = lint()
x = [abs(i-X) for i in x]
D = x[0]
for i in x[1:]:
    D = gcd(D,i)
    if D==1:
        break
print(D)

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

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

Solution (Python):
import math


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

    if n == 1:
        minimum = abs(x_lst[0] - x)
    elif n == 2:
        minimum = abs(x_lst[1] - x_lst[0])
        lst = [abs(x_lst[1] - x), abs(x_lst[0] - x)]
        lst.sort()
        lst.reverse()
        for i in range(2):
            if minimum % lst[i] == 0:
                minimum = lst[i]
                break
    else:
        lst1 = []
        for i in range(n):
            if i != n - 1:
                lst1.append(abs(x_lst[i + 1] - x_lst[i]))

        minimum = math.gcd(lst1[0], lst1[1])
        for i in range(n - 1):
            if i != n - 2:
                minimum = min(minimum, math.gcd(lst1[i], lst1[i + 1]))

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

        lst2.sort()
        lst2.reverse()
        for i in range(n):
            if minimum % lst2[i] == 0:
                minimum = lst2[i]
                break

    print(minimum)


if __name__ == '__main__':
    main()

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

Solution (Python):
def resolve():
    from math import gcd
    _, X = [int(i) for i in input().split()]
    xx = [int(i) for i in input().split()]
    ans = abs(X - xx[0])
    for x in xx:
        ans = gcd(ans, abs(X - x))
    print(ans)


if __name__ == "__main__":
    resolve()

Solution (Python):

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

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

def solve(x_list):
	ans=0
	for x in x_list:
		ans=gcd(ans, x)
	return ans

N, X = map(int, input().split())
x_list=list(abs(int(x)-X) for x in input().split())

print(solve(x_list))

Solution (Python):
N,X=map(int,input().split())
import math
a=list(map(int,input().split()))
a.append(X)
a.sort()
S=[]
for i in range(N):
    S.append(a[i+1]-a[i])

    
ans=S[0]
for j in range(1,N):
    ans=math.gcd(ans,S[j])
    
print(ans)

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

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

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

Solution (Python):
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

import string

def main():
    N,X = i_map()
    x = i_list()
    l = []
    for i in x:
        l.append(abs(X-i))
    ans = l[0]
    for k in l[1:]:
        ans = gcd(ans,k)
    print(ans)



if __name__=="__main__":
    main()

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

Solution (Python):
from math import *

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

Solution (Python):
from math import gcd

n, X = map(int, input().split())
xlst = list(map(int, input().split()))
ans = X - xlst[0]
for x in xlst:
    ans = gcd(ans, X - x)
print(ans)

Solution (Python):
import math
from functools import reduce

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

N,X = map(int,input().split())
x_list = [X] + list(map(int,input().split()))
x_list.sort()

dist = [0] * (N + 1)
for i in range(N):
  dist[i] += x_list[i+1] - x_list[i]
  
ans = gcd_list(dist)
print(ans)

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

def gcd(a,b):
    while a%b!=0:
        a,b = b,a%b
    return b
    
from functools import reduce

a = reduce(gcd,li)
print(a)

Solution (Python):
import math
from functools import reduce

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

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

N, X = map(int, input().split())
if N>1: x = [int(_)-X for _ in input().split()]; print(gcd_list(x))
else: x = int(input()) - X; print(abs(x))

Solution (Python):

from math import gcd
from functools import reduce

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

res = reduce(gcd, [abs(v - X) for v in A])
print(res)

Solution (Python):

import bisect
import math
N,X = map(int,input().split())
x = list(map(int,input().split()))
x = sorted(x,reverse = False)

bisect.insort_left(x,X)

d_lis = []
for i in range(len(x)-1):
    d = x[i+1] - x[i]
    d_lis.append(d)
d_lis = sorted(d_lis,reverse = False)

ans = d_lis[0]
for j in range(1,len(d_lis)):
    ans = math.gcd(ans,d_lis[j])
print(ans)

Solution (Python):
import math

n, s = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
for i in a:
    ans = math.gcd(ans, abs(i - s))
print(ans)

Solution (Python):
import math
n,x = map(int, input().split()) 
num_list = list(map(int, input().split())) 
res = 0
for i in num_list:
    res = math.gcd(res, abs(i-x))

print(res)

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

def gcd(nums):
    if len(nums)==1:
        return nums[0]
    return functools.reduce(euclid, nums)



n,k=[int(i) for i in input().split()]
a=[int(i) for i in input().split()]
a.append(k)
a.sort()

sa=[]

for i in range(1,n+1):
    sa.append(a[i]-a[i-1])



print(gcd(sa))

Solution (Python):
import math
from functools import reduce

def gcd(list):
  return reduce(math.gcd, list)

n, x = map(int, input().split())
a = map(lambda b: abs(int(b) - x), input().split())
print(gcd(a))

Solution (Python):


import sys



def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def gcd(x: int, y: int) -> int:
    if x < y:
        x, y = y, x
    while y > 0:
        r = x % y
        x, y = y, r
    return x


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

    return


if __name__ == "__main__":
    main()

Solution (Python):
import math

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

res = 0
for i in xl:
    res = math.gcd(res, abs(i-x))

print(res)

Solution (Python):
import math
N,X= map(int,input().split())
x=list(map(int, input().split()))
x.append(X)
x.sort()
d=[]
if N==1:
  print(x[1]-x[0])
  exit()
for i in range(N):
  d.append(x[i+1]-x[i])
gc=math.gcd(d[0],d[1])
for i in range(N):
  gc=math.gcd(d[i],gc)
print(gc)

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

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

Solution (Python):
import math
N,X = map(int,input().split())
xl = [abs(x-X)for x in map(int,input().split())]
ans = xl[0]

for x in xl[1:]:
    ans = math.gcd(ans,x)
print(ans)

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

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

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

print(reduce(gcd, cnt))

Solution (Python):
'''
Created on 2020/08/28

@author: harurun
'''
def main():
  import math
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N,X=map(int,pin().split())
  x=list(map(int,pin().split()))
  m=abs(x[0]-X)
  for i in range(1,N):
    m=math.gcd(abs(x[i]-X),m)
  print(m)
  return
main()

Solution (Python):



from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement

from functools import reduce

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

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

if N != 1:
    ret = []
    x.append(X)
    now = x[0]

    for i in x[1:]:
        ret += [i - now]
        now = i

    ret = sorted(ret)

    print(gcd_list(ret))

else:
    print(abs(x[0] - X))

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

x.append(X)
from math import gcd
g = x[1] - x[0]
for i in range(N):
    g = gcd(g, (x[i+1] - x[i]))

print(abs(g))

Solution (Python):
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
    
a = [int(s) for s in input().split()]
N = a[0]
st = a[1]
mini = int(-1)
b = [int(s) for s in input().split()]

for i in range(N):
    if abs(b[i] - st) < mini or mini == -1:
        mini = abs(b[i] - st)

yakulist = make_divisors(mini)
gyakulist = sorted(yakulist, reverse=True)
kazu = len(gyakulist)
flag = int(0)

for i in range(kazu):
    for j in range(N):
        if abs(b[j] - st) % gyakulist[i] != 0:
            flag = 1
        else:
            pass
    if flag == 0:
        print(gyakulist[i])
        break
    else:
        flag = 0

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

y = x[0]
for  i in range(1,N):
    z = x[i]
    y,z = max(y,z),min(y,z)
    while z!=0:
        y,z = z,y%z
print(y)

Solution (Python):
import fractions
def gcdlist(a):
    ans = a[0]
    for i in range(1, len(a)):
        ans = fractions.gcd(ans, a[i])
    return ans

n,y=map(int,input().split())
x=list(map(int,input().split()))
x.append(y)
if y==1:
    print(abs(x[0]-1))
    exit()

l=[]
for i in range(n):
    l.append(abs(x[i+1]-x[i]))
print(gcdlist(l))

Solution (Python):
import fractions
def gcdlist(a):
    ans = a[0]
    for i in range(1, len(a)):
        ans = fractions.gcd(ans, a[i])
    return ans

n,y=map(int,input().split())
x=list(map(int,input().split()))
x.append(y)
if y==1:
    print(abs(x[0]-1))
    exit()

l=[]
for i in range(n):
    l.append(abs(x[i+1]-x[i]))
print(gcdlist(l))

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

temp = abs(x- al[0])

for i in range(1,n):
    y = al[i]-al[i-1]
    temp = math.gcd(temp,y)
 
print(temp)

Solution (Python):
from math import gcd
n,start = map(int,input().split())
x_ls = list(map(int, input().split()))
diff_ls = [0] * n

for i in range(n):
    diff_ls[i] = abs(start-x_ls[i])

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

print(ans)

Solution (Python):

import math
from functools import reduce

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

n,x = map(int,input().split())
a = list(map(int,input().split()))
tmp = []
for i in range(n):
    tmp.append(abs(a[i]-x))
    
print(gcd_list(tmp))

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

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

else:
  l=[]
  for i in range(N):
    l_=abs(X-x[i])
    l.append(l_)
  
  ans=l[0]
  for i in range(1,len(l)):
    ans=gcd(ans,l[i])

  print(ans)

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

xx = list()
for i in range(N):
    xx.append(abs(X-x[i]))
num = xx[0]
for i in range(1,N):
    num = gcd(num,xx[i])
print(num)

Solution (Python):
import fractions

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

    ans = dists[0]
    for d in dists[1:]:
        ans = fractions.gcd(ans, d)
    print(ans)


if __name__ == '__main__':
    main()

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

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


print(reduce(gcd, res))

Solution (Python):
from functools import reduce
import math

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

if len(a)==1:print(abs(a[0]));exit()
if len(a)==2:print(math.gcd(a[0],a[1]));exit()

l=[]
for y in range(n-1):
    l.append(a[y+1]-a[y])
    
print(reduce(lambda x,y:math.gcd(x,y),l))

Solution (Python):
import sys









MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return map(int, sys.stdin.readline().strip().split())
def read_ints2(x):   return map(lambda num: int(num) - x, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def GCD(a: int, b: int) -> int: return b if a%b==0 else GCD(b, a%b)
def LCM(a: int, b: int) -> int: return (a * b) // GCD(a, b)

def Main():
    n, x = read_ints()
    d = read_int_list()
    ans = abs(x - d[0])
    
    for i in range(1, n):
        ans = GCD(ans, abs(x - d[i]))
    print(ans)    

if __name__ == '__main__':
    Main()

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

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

Solution (Python):

n,x=list(map(int, input().split()))
pos = list(map(int, input().split()))
diff_pos = [abs(s-x) for s in pos]
min_diff = min(diff_pos)

ans = 0
def main():
    for i in range(min_diff,0,-1):
        for n in diff_pos:
            if n % i != 0:
                break
            if n == diff_pos[-1]:
                return i
    
    
print(main())

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

import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)
def gcd_list(numbers):
    return reduce(math.gcd, numbers)

print(gcd(*abs_List))

Solution (Python):
from math import *
def gcd2(array):
    temp = array[0]
    for a in array[1:]:
        temp = gcd(temp, a)
    return temp
N, X = map(int, input().split())
D = []
for x in map(int, input().split()):
    D.append(abs(x-X))
print(gcd2(D))

Solution (Python):
import  math
from functools import reduce

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

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

Solution (Python):
import math

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

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

Solution (Python):
from math import gcd
n, x = map(int, input().split())
m = [x]+list(map(int, input().split()))


m.sort()

if n==1:
  print(m[1]-m[0])
else:
  res = gcd(m[1]-m[0], m[2]-m[1])
  for i in range(1, n-1):
    a = m[i+1]-m[i]
    b = m[i+2]-m[i+1]
    if res >= gcd(a,b):
      if res%gcd(a,b)==0:
        res = gcd(a,b)
      else:
        res = gcd(res, gcd(a, b))
    else:
      if gcd(a,b)%res!=0:
        res = gcd(res, gcd(a, b))
  print(res)

Solution (Python):
import math
N, X = map(int, input().split())
x = list(map(int, input().split()))
x = list(map(lambda x: x - X, x))
ans = min(list(map(lambda x: abs(x), x)))
for num in x:
    ans = math.gcd(ans, num)
print(ans)

Solution (Python):
import math

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

absx = [abs(X - xx) for xx in x]
absx.sort()

divx0 = []

for i in range(math.ceil(math.sqrt(absx[0])), 0, -1):
    if absx[0] % i == 0:
        divx0.append(i)

t = []
for x in divx0:
    t.append(x)
    t.append(absx[0] // x)

divx0 = t
divx0.sort(reverse=True)

for dx0 in divx0:
    isok = True
    for xx in absx:
        if xx % dx0 != 0:
            isok = False
            break

    if isok:
        print(dx0)
        exit()

Solution (Python):
import math
from functools import reduce
N, X = map(int, input().split())
x = list(map(int, input().split()))
x.append(X)
x = [y - X for y in x]
print(reduce(math.gcd, x))