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 numpy as np
import math
from functools import reduce
from fractions import gcd


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

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

x.append(X)
sort_x = np.array(sorted(x))

kaisa = np.diff(sort_x, n=1).tolist()

print(gcd_list(kaisa))

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

def GCD(A):
    if len(A) == 1:
        return A[0]
    elif len(A) == 2:
        g = gcd(A[0],A[1])
    else:
        g = gcd(A[0],A[1])
        for i in range(2,len(A)):
            g = gcd(g,A[i])
    return g

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

x.sort()
for i in reversed(range(N+1)):
    x[i] -= x[0]

ans = GCD(x)
print(ans)

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

Solution (Python):
import fractions
n,x0=map(int,input().split())
d=list(map(lambda a:abs(int(a)-x0),input().split()))
ans=d[0] if len(d)==1 else fractions.gcd(d[0],d[1])
i=1
while i < n-1 and ans !=1:
    ans=min(ans,fractions.gcd(d[i],d[i+1]))
    i+=1
print(ans)

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

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

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

Solution (Python):
import fractions
from functools import reduce

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

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

X.append(K)
diff = []
for i,x in enumerate(X):
    if i != 0:
        diff.append(abs(X[i-1] - x))

print(gcd_list(diff))

Solution (Python):
from fractions import gcd
from bisect import insort

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


X.sort()
insort(X, x)
diff = []
for a,b in zip(X, X[1:]):
    diff.append(b - a)

ans = diff[0]
for num in diff[1:]:
    ans = gcd(ans, num)

print(ans)

Solution (Python):
import sys
import fractions
def input(): return sys.stdin.readline().rstrip()
import math

def main():
    n,x=map(int,input().split())
    X=[int(_) for _ in input().split()]
    X.append(x)
    X.sort()
    ans=X[1]-X[0]
    for i in range(1,n):
        ans=fractions.gcd(ans,X[i+1]-X[i])
    print(ans)

if __name__=='__main__':
    main()

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

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

x.append(y)
x.sort()
d = []
for i in range(n):
    d.append(x[i+1]-x[i])
if len(d) !=1:
    ans = fractions.gcd(d[0],d[1])
    for i in range(n-1):
        ans = fractions.gcd(ans,d[i])
    print(ans)
else:
    ans = d[0]
    print(ans)

Solution (Python):
from fractions import gcd

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

dX = [abs(X - x) for x in X_list]
if len(dX) == 1:
    print(dX[0])
    exit(0)

D = [abs(X_list[i] - X_list[i + 1]) for i in range(0, N - 1)]
res = D[0]
for x in D[1:]:
    res = gcd(res, x)

ans = 0
for d in dX:
    ans = max(gcd(res, d), ans)
print(ans)

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

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


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

ans = xl[0]
for x in xl:
    ans = gcd(ans, x)

print(ans)

Solution (Python):
import sys

def gcd(a, b): return gcd(b, a % b) if b else abs(a)
def lcm(a, b): return abs(a // gcd(a, b) * b)

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

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

if __name__ ==  '__main__':
    main()

Solution (Python):





mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    import fractions
    n,x = readInts()
    X = readInts()
    ans = abs(X[0] - x)
    for i in range(1,n):
        ans = fractions.gcd(ans,abs(X[i] - x))
    print(ans)

if __name__ == '__main__':
  main()

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

Solution (Python):
import numpy as np
N,X=map(int, input().split())

A=np.array(list(map(int, input().split())))
B=A-X
if N==1:
  print(abs(B[0]))
  exit()

from fractions import gcd
GCD=gcd(abs(B[0]),abs(B[1]))

if N>2:
  for i in range(2,N):
    GCD=gcd(GCD, abs(B[i]))
    
  
print(GCD)

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

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

A=[abs(int(i)-x) for i in input().split()]

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

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

def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)
ans = abs(X-x[0])

for k in range(1,N):
    ans = gcd(ans,abs(x[k]-x[k-1]))
print(ans)

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

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

while len(diff) > 1:
    a, b = diff.pop(), diff.pop()
    diff.append(gcd(a, b))

print(diff[0])

Solution (Python):
from fractions import gcd

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

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

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






def mygcd(a, b):
    
    if a < b: return mygcd(b, a)
    elif b == 0: return a
    else: return mygcd(b, a % b)

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

print(ans)

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

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.insert(0, X)
distance = []
for i in range(1, len(x)):
    distance.append(abs(x[i] - x[i - 1]))

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

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

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

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

    from functools import reduce
    from fractions import gcd
    print(abs(reduce(gcd,L)))


resolve()

Solution (Python):

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


def main():
    N, X = (int(i) for i in input().split())
    A = [int(i) for i in input().split()] + [X]
    A.sort()
    diff = [A[i+1] - A[i] for i in range(N)]
    ans = diff[0]
    for d in diff:
        ans = 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()))

n = []
for i in range(N):
    n.append(abs(X - x[i]))
print(reduce(gcd, n))

Solution (Python):
from fractions import gcd

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

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

print(ans)

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

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

import fractions

from functools import reduce

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

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

print(gcd_list(l))

Solution (Python):
import sys

def gcd(a,b):
    a, b = max(a,b), min(a,b)
    while a % b > 0:
        a, b = b, a % b
    return b

def solve():
    input = sys.stdin.readline
    N, X = map(int, input().split())
    A = [int(a) for a in input().split()]
    Ans = abs(A[0] - X)
    for a in A:
        Ans = gcd(Ans, abs(a - X))
    print(Ans)
    return 0

if __name__ == "__main__":
    solve()

Solution (Python):
from itertools import accumulate


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


N, K = map(int, input().split())
A = list(map(int, input().split()))
B = [abs(a-K) for a in A]

ans = list(accumulate(B, func=gcd))[-1]
print(ans)

Solution (Python):
import numpy as np
from fractions import gcd
def main():
    n, X = map(int, input().split())
    x = list(map(int, input().split()))
    x.append(X)
    x.sort()
    x = np.array(x)
    dif = np.diff(x)
    ans = 0
    for v in dif:
        ans = gcd(ans, int(v))
    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)
def solve():
    n,x = map(int,input().split())
    l = list(map(int,input().split()))
    d = abs(x-l[0])
    for i in range(1,n):
        d = gcd(d,abs(x-l[i]))
    print(d)
if __name__=='__main__':
    solve()

Solution (Python):
from fractions import gcd
N,X = map(int,input().split())
xs = list(map(int,input().split()))
g = X-xs[0]
for a,b in zip(xs,xs[1:]):
    g = gcd(g, a-b)
print(abs(g))

Solution (Python):
from functools import reduce
from fractions import gcd
N,X = map(int,input().split())
W = list(map(int,input().split())) + [X]
W = sorted(W)
sa_w = [W[i+1] - W[i] for i in range(N)]
ans = reduce(gcd, sa_w)
print(ans)

Solution (Python):
N,X = map(int,input().split())
W = list(map(int,input().split())) + [X]
W = sorted(W)
dist = 10**18
if len(W) == 2:
  print(W[1]-W[0])
  exit()
for i in range(1,N+1):
  dist = min(dist, W[i]-W[i-1])
  while (W[i]-W[i-1])%dist != 0:
    dist -= 1
  if dist == 1:
    break
print(dist)

Solution (Python):
N,X = map(int,input().split())
W = list(map(int,input().split())) + [X]
W = sorted(W)
dist = 10**18
if len(W) == 2:
  print(W[1]-W[0])
  exit()
for i in range(1,N+1):
  dist = min(dist, W[i]-W[i-1])
  while (W[i]-W[i-1])%dist != 0:
    dist -= 1
  if dist == 1:
    break
print(dist)

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

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from fractions import gcd

n, x = map(int, readline().split())
xx = list(map(int, readline().split()))
gcd_ans = abs(x - xx[0])
for i in range(1, n):
    gcd_ans = gcd(gcd_ans, abs(x - xx[i]))
print(gcd_ans)

Solution (Python):
import fractions
from fractions import gcd


def solve():

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

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

    print(d)


if __name__ == "__main__":
    solve()

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






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

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

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

ans = gcd_list(dif)
print(ans)

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

Solution (Python):
from functools import reduce
from fractions import gcd
N, K = map(int, input().split())
X = sorted(list(map(int, input().split())) + [K])

S = [X[i+1] - X[i] for i in range(N)]

D = reduce(gcd, S, S[0])
print(D)

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

Solution (Python):
import fractions

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

ans = z[0]
for i in range(1, n):
    ans = fractions.gcd(ans, z[i])
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())
print(gcd_list([abs(int(i)-x) for i in input().split()]))

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

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

Solution (Python):
N,X = map(int,input().split())
Alist = list(map(int,input().split()))
for i in range(len(Alist)):
    Alist[i] = abs(Alist[i]-X)
Alist.sort()
p = []
q = 1
for i in range(1,len(Alist)):
    if Alist[i] % Alist[0] != 0:
        p.append(Alist[i] % Alist[0])
        q = q*0
p.sort()
r = 1
s = []
if p != []:
    for i in range(0,len(Alist)):
        s.append(Alist[i] % p[0])
        if Alist[i] % p[0] != 0:
            p[0] = Alist[i] % p[0]
if len(Alist) > 1:
    if q == 0 and r == 1:
        print(p[0])
    if q == 0 and r == 0:
        print(1)
    if q == 1:
        print(Alist[0])
else:
    print(Alist[0])

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

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

ans = abs(X - x[0])

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

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

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

n, X = list(map(int, input().split()))
x = list(map(int, input().split()))
print(gcds([abs(i - X) for i in x]))

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

Solution (Python):
import sys
from fractions import gcd

input = sys.stdin.readline

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

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

x.append(X)
x.sort()
diff = []
ans = []

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

for i in range(N-1):
    ans.append(gcd(diff[i], diff[i+1]))

print(min(ans))

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

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

Solution (Python):

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


import fractions



res=0

for i in range(n):
    res=fractions.gcd(res,abs(x-xl[i]))

print(res)

Solution (Python):
n,x=map(int,input().split())
z=list(map(int,input().split()))
z.sort()
def gcd(a,b):
    if b==0:
        return a 
    return gcd(b,a%b)
ans=abs(x-z[0])

for i in range(n-1):
    sa=z[i+1]-z[i]
    ans=gcd(sa,ans)
print(ans)

Solution (Python):
import fractions
from functools import reduce

n,x = map(int,input().split())
base = list(map(int,input().split()))
base_1 = [0]*n

for i in range(n):
  base_1[i] = base[i] - x
  
ans = reduce(fractions.gcd,base_1)
print(abs(ans))

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

Solution (Python):
def gcd(a, b):
    if b==0: return a
    else: return gcd(b, a%b)
n, x = map(int, input().split())
L = list(map(int, input().split()))
d = 0
for l in L:
    d = gcd(d, abs(x-l))
print(d)

Solution (Python):
from fractions import gcd

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

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

print(d)

Solution (Python):
from fractions import gcd

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

x.sort()

if X < x[0]:
    d = x[0] - X
elif X > x[N - 1]:
    d = X - x[N - 1]
else:   
    ok = 0      
    ng = N - 1  
    while ng - ok > 1:
        mid = (ok + ng) // 2
        if x[mid] <= X:
            ok = mid
        else:
            ng = mid
    d = gcd(X - x[ok], x[ok + 1] - X)

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

print(d)

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

import fractions
from functools import reduce
print(reduce(fractions.gcd, n))

Solution (Python):
import fractions
import sys

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

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

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

Solution (Python):
n,x=map(int,input().split())
a=list(map(int,input().split()))
if n==1:
    print(abs(a[0]-x))
    exit()
def gcd(m,n):
    x,y=max(m,n),min(m,n)
    if x%y==0:
        return y
    else:
        while x%y!=0:
            z=x%y
            x=y
            y=z
        else:
            return z
b=[]
for i in range(n):
    b.append(abs(a[i]-x))
c=gcd(b[0],b[1])
for i in range(n-2):
    c=gcd(c,b[i+2])
print(c)

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

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

from fractions import gcd
from functools import reduce
ans = reduce(gcd, dist)
print(ans)

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

def Skip(n , x , xl):

    xl = map(lambda i: abs(i - x), xl)
    return reduce(gcd , xl)

def main():
    n , x = map(int , input().split())
    xl = list(map(int , input().split()))
    print(Skip(n , x , xl))

if __name__ == '__main__':
    main()

Solution (Python):
import math
from fractions import gcd
from functools import reduce
n,x = map(int, input().split())
y_ls = list(map(int, input().split()))
y_ls.sort()
d_ls = [0] * (n-1)

if n != 1:
    first_ls = []
    for i in range(n):
        first = abs(x - y_ls[i])
        first_ls.append(first)

    for i in range(n-1):
        distance = y_ls[i+1] - y_ls[i] 
        d_ls.append(distance)

    points_gcd = reduce(gcd, d_ls)
    ans = 0
    for i in range(n):
        D = gcd(points_gcd, first_ls[i])
        if D > ans:
            ans = D

else:
    ans = abs(x - y_ls[0])

print(ans)

Solution (Python):
n, x = map(int,input().split())
City = list(map(int, input().split()))
Distance = [0] * n

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

Distance.sort()
ans = Distance[0]

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

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

print(ans)

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

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    
    from itertools import combinations, permutations, accumulate, groupby
    
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    

    
    

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

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

    for i in range(n):
        a[i] = abs(a[i] - x)
    
    def gcd(a, b):
        if b == 0:
            return a
        else:
            return gcd(b, a % b)
    
    def gcd_group(arr):
        g = gcd(arr[0], arr[1])
        for i in range(2, len(arr)):
            g = gcd(g, arr[i])
        return g
    
    def lcm(a, b):
        g = gcd(a, b)
        return (a*b)//g
    
    def lcm_group(arr):
        l = lcm(arr[0], arr[1])
        for i in range(2, len(arr)):
            l = lcm(l, arr[i])
        return l
    
    print(gcd_group(a))
    

if __name__ == '__main__':
    main()

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    
    from itertools import combinations, permutations, accumulate, groupby
    
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    

    
    

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

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

    for i in range(n):
        a[i] = abs(a[i] - x)
    
    def gcd(a, b):
        if b == 0:
            return a
        else:
            return gcd(b, a % b)
    
    def gcd_group(arr):
        g = gcd(arr[0], arr[1])
        for i in range(2, len(arr)):
            g = gcd(g, arr[i])
        return g
    
    def lcm(a, b):
        g = gcd(a, b)
        return (a*b)//g
    
    def lcm_group(arr):
        l = lcm(arr[0], arr[1])
        for i in range(2, len(arr)):
            l = lcm(l, arr[i])
        return l
    
    print(gcd_group(a))
    

if __name__ == '__main__':
    main()

Solution (Python):
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
from functools import reduce

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

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

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

N, X = i_l()
x = i_l()

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

x = gcd_list(arr + [abs(x-X) for x in x])

print(x)

Solution (Python):
n,X= list(map(int, input().split()))
x= list(map(int, input().split()))
x.append(X)
x.sort()
init=x.pop(0)
li=[]
for i in x:
    li.append(i-init)
    init=i
li.sort()
flag=0
mini=li[0]

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

    divisors.sort(reverse=True)
    return divisors

for i in make_divisors(mini):
    if flag==0:
        check=0
        for j in li:
            ans=i
            if j%i==0:
                check+=1
        if check==len(li):
            print(ans)
            exit(0)

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

Solution (Python):

from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
import numpy as np
from functools import reduce

from collections import deque, Counter, defaultdict
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7

def main():
  n, X = map(int, readline().split())
  x = np.array(readline().split(), dtype='int64')
  x -= X
  if len(x) == 1:
    ans = x[0]
  else:
    ans = reduce(gcd, x)
  print(abs(ans))
  
  
  
  
  
  
if __name__ == '__main__':
  main()

Solution (Python):
import fractions
from functools import reduce

N, X = map(int, input().split())
a = list(map(int, input().split()))
y = []

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

for i in a:
    y.append(abs(X-i))

print(gcd_list(y))

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

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

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

n,x = map(int,input().split())
l = list(map(int,input().split()))
t = [abs(i-x) for i in l]
print(reduce(gcd,t))

Solution (Python):

import sys
import fractions

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

    print(ans)

if __name__ == '__main__':
    main()

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):
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)


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

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

xl.append(X)
xl.sort()

k = []
for i in range(1, N+1):
    tmp = xl[i]-xl[i-1]
    if not(tmp in k):
        k.append(tmp)

if len(k) == 1:
    print(k[0])
elif len(k) == 2:
    ans = gcd(k[0], k[1])
    print(ans)
else:
    ans = gcd(k[0], k[1])
    for i in range(2, len(k)):
        ans = gcd(ans, k[i])
    print(ans)

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

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

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

def gcds(x):
    ans = x[0]
    for i in x:
        ans = gcd(ans, i)
    return ans


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

bx = X
tmp = [0 for _ in range(n)]
for i in range(n):
    tmp[i] = abs(x[i] - bx)
    bx = x[i]
print(gcds(tmp))

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

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

res = 0
for i in a:
    res = gcd(res, abs(i - x))
print(res)

Solution (Python):
from math import sqrt
from copy import deepcopy


def Calc_Divisors(num):
    divisors = []
    for i in range(1, int(sqrt(num)) + 1):
        if num % i == 0:
            divisors.append(i)
            if i != num // i:
                divisors.append(num//i)
    divisors.sort(reverse=True)
    return divisors


if __name__ == "__main__":
    n, start = map(int, input().split())
    x = list(map(int, input().split()))

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

    
    div = Calc_Divisors(x[0])

    
    for i in range(n):
        tmp = deepcopy(div)
        for d in tmp:
            if x[i] % d != 0:
                div.remove(d)

    print(div[0])

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

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

print(reduce(fractions.gcd, ans))

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

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

B = [abs(a - A[0]) for a in A]
ans = 0
for d in B:
    ans = gcd(ans, d)
print(ans)

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

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


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


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