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 math
from functools import reduce
N, X = map(int, input().split())
x = list(map(int, input().split()))
x = [y - X for y in x]
if len(x)==1:
    for y in x:
        print(abs(y))
else:
    print(reduce(math.gcd, x))

Solution (Python):
import math
from functools import reduce
from sys import setrecursionlimit
setrecursionlimit(10**6)

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

n,x = map(int,input().split())
xl = list(map(int,input().split()))
xl = list(map(lambda y: abs(y-x), xl))

ans = -1
if len(xl) == 1:
    ans = xl[0]
else:
    ans = gcd(*xl)

print(ans)

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

Solution (Python):
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
from math import gcd,ceil,floor,factorial

from functools import reduce
from pprint import pprint
from statistics import mean,median,mode

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input()) for _ in range(n) ]







n,s = MI()
x = RI()

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




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

ans = gcd3_list(l)
print(ans)

Solution (Python):
import math
from functools import reduce

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

print(ans)

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

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

t=[abs(c-X) for c in C]

import math
from functools import reduce
print(reduce(math.gcd, t))

Solution (Python):
from math import gcd
n, x0 = map(int, input().split())
x = [abs(_x-x0) for _x in list(map(int, input().split()))]
x.sort()

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

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())
a = list(map(int, input().split()))
a.append(x)
a.sort()
d = set()
for i in range(n):
  d.add(a[i + 1] - a[i])
d = list(d)
ans = gcd_list(d)
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 functools import reduce
from math import gcd

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

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

a = [abs(a-x) for a in A]

print(reduce(gcd,a))

Solution (Python):
import math

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

d =  abs(a[0] - x)

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

print(d)

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

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

import math
import functools
print(functools.reduce(math.gcd,xl_abs))

Solution (Python):
import math
from functools import reduce

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

a,b=map(int, input().split())
c=list(map(int, input().split()))
c = c + [b]
d = sorted(c)
l = []

for i in range(a):
    l += [d[i+1] - d[i]]

f=gcd_list(l)
print(f)

Solution (Python):
import math
from functools import reduce

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

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

num_list = [abs(x-xn[i]) for i in range(n)]

Ans = gcd_list(num_list)
print(Ans)

Solution (Python):
import math
import functools
N,X = map(int,input().split())
A = list(map(int,input().split()))
mylist=[abs(X-A[0])]

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

print(functools.reduce(math.gcd, mylist))

Solution (Python):
n,x,*l=map(int,open(0).read().split())
from math import *
a=0
for i in l: a=gcd(a,abs(i-x))
print(a)

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

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

Solution (Python):
f=lambda:[*map(int,input().split())]
n,x=f()
l=f()
d=[l[i+1]-l[i] for i in range(n-1)]
a=abs(x-l[0])
from math import *
for i in d:
  a=gcd(a,i)
print(a)

Solution (Python):
f=lambda:[*map(int,input().split())]
n,x=f()
l=f()
d=[x-l[0]]
for i in range(n-1):
  d+=[l[i+1]-l[i]]
a=d[0]
from math import *
for i in d:
  a=gcd(a,i)
print(a)

Solution (Python):
import math

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

diff = [0 for _ in range(n)]
for i in range(n):
    diff[i] = xL[i + 1] - xL[i]

ans = diff[0]
for d in diff:
    ans = math.gcd(ans, d)

print(ans)

Solution (Python):
from math import gcd

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

def lgcd(l):
    res = l[0]
    for i in range(1, len(l)):
        res = gcd(res, l[i])
        
    return res

x.append(X)
x.sort()
d = []
for i in range(n):
    d.append(x[i + 1] - x[i])
    
print(lgcd(d))

Solution (Python):
from functools import reduce
def gcd(a,b):
    if b>0:
        return gcd(b,a%b)
    else:
        return a

N,X=map(int,input().split())
x=[int(i)for i in input().split()]
dist=[abs(X-i)for i in x]
d=reduce(gcd,dist)
print(d)

Solution (Python):
n,x=map(int,input().split())
a=list(map(int,input().split()))
b=[]
if n==1 and x==a[0]:
    print(max(x,10**9-x))
    exit()
for i in range(n):
    b.append(abs(a[i]-x))
import math
c=0
for i in range(n):
    c=math.gcd(c,b[i])
    if c==1:
        break
print(c)

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

Solution (Python):
from functools import reduce
from math import gcd
n,x = map(int,input().split())
a = list(map(int,input().split()))
print(reduce(gcd,(abs(ai-x) for ai in a)))

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

Solution (Python):
import math
from functools import reduce
n, x = map(int, input().split())
l = list(map(int, input().split()))


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

l_map = list(map(lambda a:abs(a-x), l))
print(gcd_list(l_map))

Solution (Python):
import math

N, X = list(map(lambda n:int(n), input().split(" ")))
x = list(map(lambda y:int(y), input().split(" ")))
x.append(X)
x.sort()
d = list(filter(lambda r: r != 0, [abs(x[i + 1] - x[i]) for i in range(len(x) - 1)]))

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

print(gcd)

Solution (Python):
import math
n, X = map(int, input().split())
x = list(map(int, input().split()))
X_x = [0] * n

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

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

print(gcd)

Solution (Python):
import sys
import math


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n, x = inintm()
X = inintl()

if x not in X:
    X.append(x)
    n += 1

X.sort()

ans = X[1] - X[0]
prev = X[0]

for i in range(1,n):
    ans = min(math.gcd(ans, X[i]-prev), ans)
    prev = X[i]

print(ans)

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

_, X = map(int, input().split())
print(reduce(gcd, (abs(i - X) for i in set(map(int, input().split())))))

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

_, X = map(int, input().split())
x = set(map(int, input().split()))
x.add(X)
x = sorted(x)
print(reduce(gcd, (j - i for i, j in zip(x[:-1], x[1:]))))

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

Solution (Python):
import sys
from math import gcd

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, x, *X = map(int, read().split())

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

    print(ans)
    return


if __name__ == '__main__':
    main()

Solution (Python):
import math
from functools import reduce

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

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

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

print(gcd_list(l))

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

nums = [0]*n
for i in range(n): nums[i] = l[i+1] - l[i]

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

Solution (Python):
from math import gcd as g
n,x=map(int,input().split())
l=list(map(int,input().split()))
l=sorted(l)
if x<=l[0]:
    l.insert(0,x)
elif x>=l[-1]:
    l.append(x)
else:
    for i in range(n-1):
        if l[i]<=x<l[i+1]:
            l.insert(i+1,x)
            break
ans=0
for i in range(n):
    ans=g(ans,l[i+1]-l[i])
print(ans)

Solution (Python):
import fractions

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

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

print(e)

Solution (Python):
N,X=map(int,input().strip().split())
x=list(map(int,input().strip().split()))
x.append(X)
x.sort()
    
d=[]
for n in range(1,N+1):
    d.append(x[n]-x[n-1])
    
def gcd(a,b):
    x=max(a,b)
    y=min(a,b)
    tmp=x%y
    if tmp==0:
        return y
    else:
        return gcd(y,tmp)
    
if len(d)<=1:
    print(d[0])
else:
    D=d[0]
    for i in range(1,len(d)):
        D=gcd(D,d[i])
    print(D)

Solution (Python):
import numpy as np

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


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

s = np.array(x)
s = abs(s-X)

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

for i in range(1, len(s)):
    if i == 1:
        D = gcd(s[i],s[i-1])
    D = gcd(s[i], D)

print(D)

Solution (Python):
from math import gcd


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


if __name__ == "__main__":
    main()

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


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


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


def main():
    n, x = nm()
    X = nl()
    X.append(x)
    X = sorted(X)
    D = [X[i + 1] - X[i] for i in range(len(X) - 1)]
    ans = gcd_list(D)
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):

import numpy as np
import math
from functools import reduce

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

N,X = map(int,input().split())
City = np.array(list(map(int,input().split())))
City = np.sort(np.append(City,[X]))
kaisa = np.diff(City)
print(gcd_list(kaisa))

Solution (Python):
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, X = LI()
    x = LI()

    d = list(set([abs(i - X) for i in x]))
    gcd = d[0]
    for i in d:
        gcd = math.gcd(i, gcd)

    print(gcd)

if __name__ == '__main__':
    resolve()

Solution (Python):
import math
n,s=map(int,input().split())
X=list(map(int,input().split()))
for i in range(n):
  X[i]=abs(X[i]-s)
X.sort()
ans=10**100
for x in X:
  tmp=math.gcd(X[0],x)
  if tmp<ans:
    ans=tmp
print(ans)

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

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

A=[0]*N
for i in range(N):
    A[i]=abs(C[i]-X)

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

print(ans)

Solution (Python):
import math

N, X = 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 = math.gcd(res, dis[i])

print(res)

Solution (Python):
import math
from functools import reduce
N,X=map(int, input().split()) 
x = list(map(int, input().split()))
y=[0]*N
for i in range(N):
    y[i]=abs(x[i]-X)
def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)
D=y[0]
for i in range(N):
    D=gcd(y[i],D)        
print(D)

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

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


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


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

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

xi = [abs(xval - x) for xval in xi]

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

res = xi[0]
for i in range(1, len(xi)):
    res = gcd(res, xi[i])

print(res)

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

n,x=(int(i) for i in input().strip().split(" "))
from functools import reduce
ar=[int(i) for i in input().strip().split(" ")]
ar.sort()
from bisect import insort
insort(ar,x)
temp=[]
for i in range(1,len(ar)):
    temp.append(abs(ar[i]-ar[i-1]))

k=reduce(gcd,temp)
print(k)

Solution (Python):
import math
from functools import reduce


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

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

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


g = gcd(*dist)
print(g)

Solution (Python):
import math

n, x = map(int, input().split())
list_x = list(map(int, input().split()))
list_x.append(x)
list_x.sort()
delta_list = []
for i in range(len(list_x) - 1):
    delta_list.append(list_x[i+1] - list_x[i])
common = delta_list[0]
for num in delta_list:
    common = math.gcd(common, num)
print(common)

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

x_s.append(X)

list_s=sorted(x_s)

numbers=[]

for n in range(1,N+1):
    number=list_s[n]-list_s[n-1]
    numbers.append(number)

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

number=numbers[0]
for n in range(len(numbers)):
    number=gcd(number,numbers[n])

print(number)

Solution (Python):


import math

N, X = map(int, input().split())
A = sorted(list(map(int, input().split()))+[X])
B = []

for i in range(len(A)-1):
    B.append(A[i+1] - A[i])

g = B[0]

for b in B[1:]:
    g = math.gcd(b, g)

print(g)

Solution (Python):
import sys
import math
from functools import reduce
input = lambda: sys.stdin.readline().rstrip()

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

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

x.append(X)
x.sort()

diff = []

for i in range(1, len(x)):
    diff.append(x[i]-x[0])

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

print(gcd_list(diff))

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

Solution (Python):
import math
n,x=map(int,input().split());l=[abs(x-i) for i in list(map(int,input().split()))];r=0
for i in range(len(l)): r=math.gcd(r,l[i])
print(r)

Solution (Python):
import math
n,x=map(int,input().split());l=[abs(x-i) for i in list(map(int,input().split()))]
if len(l)>1:
  r=math.gcd(l[0],l[1])
  for i in range(1,len(l)):
    r=math.gcd(r,l[i])
else:
  print(l[0])
  exit()
print(r)

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

Solution (Python):
from math import gcd

n, x = map(int, input().split())
a = [int(i) for i in input().split()]
b = []
for i in a:
    b.append(abs(x - i))
g = b[0]
for i in b:
    g = gcd(g, i)
print(g)

Solution (Python):
import math

n,f = map(int,input().split())
x = list(map(int,input().split()))
x.append(f)
k = min(x)
ans = max(x)-k
for i in range(n+1):
    if math.gcd(ans, x[i]-k) < ans:
        ans = math.gcd(ans, x[i]-k)
print(ans)

Solution (Python):
import sys
import math


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

A.append(X)
A = sorted(A)

anslis = [0]*N
for i in range(N):
    anslis[i] = A[i+1] - A[i]

g = anslis.pop(0)
for c in anslis:
    g = math.gcd(g,c)

print(g)

Solution (Python):
import math

if __name__ == '__main__':
	n,x = map(int,input().split())
	A = list(map(int,input().split()))
	A.sort(reverse=True)

	B = []
	for i in range(0,n-1):
		tmp = A[i] - A[i+1]
		B.append(tmp)

	ans = abs(x-A[0])
	for j in B:
		ans = math.gcd(ans,j)
	print(ans)

Solution (Python):
import fractions
n,x = map(int,input().split())
a = list(map(int,input().split()))
res,ans = [],0
for i in range(n):
	res.append(abs(a[i]-x))
if len(res) > 3:
	D = fractions.gcd(res[0],res[1])
	for j in range(2,len(res)-2):
		D = fractions.gcd(D,res[j])
	ans = D
else:
	ans = min(res)
print(ans)

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

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

for i in range(1,N):
  if i == 1:
    total_gcd = gcd(diff[i],diff[i-1])
  else:
    total_gcd = gcd(diff[i],total_gcd)
    
print(total_gcd)

Solution (Python):
import math

def agcd(l):
    a=math.gcd(l[0],l[1])
    for i in range(2,len(l)):
        a=math.gcd(a,l[i])
    return a

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

print(agcd(x)if 1<N else x[0])

Solution (Python):
import math
N,X=map(int,input().split())
L=list(map(int,input().split()))
L.append(X)
L=sorted(L)
m=L[1]-L[0]
for i in range(N):
  m=math.gcd(m,L[i+1]-L[i])
print(m)

Solution (Python):
import math
def main():
    n,x=map(int,input().split())
    p=0
    for i in map(int,input().split()):
        p = math.gcd(p, i-x)
    print(p)

if __name__ == "__main__":
    main()

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

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

Solution (Python):









import os
import sys


def gcd(s, t):
    while t != 0:
        tmp = s % t
        s = t
        t = tmp
    return s


def main():
    N, X = map(int, input().split())
    x = list(map(int, input().split()))
    a = []
    for i, s in enumerate(x):
        if i == 0:
            a.append(abs(x[0]-X))
            continue
        a.append(abs(x[i]-x[i-1]))
    ans = a[0]
    for i in range(1, len(a)):
        ans = gcd(max(ans, a[i]), min(ans, a[i]))
        
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
def main():
    import math
    import functools
    n, x = map(int, input().split())
    inset = set(map(int, input().split()))
    inset2 = set()

    for num in inset:
        inset2.add(abs(num - x))

    gcd = functools.reduce(math.gcd, inset2)
    print(gcd)

            



if __name__ == "__main__":
    main()

Solution (Python):
import math

n, x = map(int, input().split())
a = list(map(int, input().split()))
b = []
for i in range(n):
  b.append(abs(x-a[i]))
ans = b[0]
for j in range(1, n):
  ans = math.gcd(ans, b[j])
print(ans)

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)

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

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

print(gcd(*x))

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

N,X = map(int,input().split())
a = list(map(int,input().split()))
print(reduce(gcd,(abs(a[i] - X) for i in range(N))))

Solution (Python):

from math import gcd

from functools import reduce







def solve(n,x,a):
    delta_a = (abs(a[i] - x) for i in range(n))
    return reduce(gcd,delta_a)



def main():
    
    N,X = map(int,input().split())
    a = list(map(int,input().split()))
    print(solve(N,X,a))
    return

if __name__ == '__main__':
    main()

Solution (Python):
import math
n,p=map(int,input().split())
a=list(map(int,input().split()))
x=[]
for i in a:
  x.append(abs(i-p))
  
if len(x)==1:
  print(x[0])
  
else:
  pin=x[0]
  for i in range(1,len(x)):
    pin=math.gcd(pin,x[i])
    
  print(pin)

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

Solution (Python):
from functools import reduce
import math
def main():
    n, s = map(int, input().split())
    X = list(map(lambda x:abs(int(x) - s), input().split()))
    ans = reduce(lambda x, y :math.gcd(x, y), X, X[0])
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
import math

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

nlis = []

for i in range(n):
    nlis.append(abs(lis[i]- x))

ans = nlis[0]

for j in range(1, n):
    ans = math.gcd(ans, nlis[j])

print(ans)

Solution (Python):
import math

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

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

u = 0
if X_lst[0] == X:
    u = float('inf')

for i, x in enumerate(X_lst[1:], start=1):
    if x == X:
        u = float('inf')

    if X_lst[i - 1] < X < x:
        u = [X - X_lst[-1], x - X]

    if i == 1:
        g = X_lst[1] - X_lst[0]
    else:
        g = math.gcd(g, x - X_lst[i - 1])


if u == 0:
    u = [X - X_lst[-1]]
elif u != float('inf'):
    g = max(math.gcd(g, u[0]), math.gcd(g, u[1]))

print(g)

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

Solution (Python):
import sys
import math
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

def gcd(a,b):
    return math.gcd(a,b)

if __name__ == "__main__":
    n,x = I2()
    a = Intl()
    ans = abs(a[0]-x)
    for i in range(1,n):
        ans = gcd(ans,abs(a[i]-x))
    print(ans)

Solution (Python):
import math
n, x = [int(w) for w in input().split()]
la = [int(w) for w in input().split()]+[x]
la.sort()
if la[0] < 0:
    m = la[0]
    la = [w+m for w in la]

diff = [0]*n
for i in range(n):
    diff[i] = la[i+1]-la[i]
g = diff[0]
for i in diff[1:]:
    g = math.gcd(g, i)

print(g)

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

import math
from functools import reduce

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

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

print(gcd_list(A))

Solution (Python):
































































def calculation(lines):
    
    N, X = list(map(int, lines[0].split()))
    values = list(map(int, lines[1].split()))
    values.append(X)
    mi = min(values)
    
    values = [value - mi for value in values]

    for _ in range(10):
        
        values = [value for value in values if value > 0]
        mi = min(values)
        
        values = list(set([value % mi for value in values]))
        if values == [0]:
            return [mi]



def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines



def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['3 3', '1 7 11']
        lines_export = [2]
    if pattern == 2:
        lines_input = ['3 81', '33 105 57']
        lines_export = [24]
    if pattern == 3:
        lines_input = ['1 1', '1000000000']
        lines_export = [999999999]
    return lines_input, lines_export



def get_mode():
    import sys
    args = sys.argv
    if len(args) == 1:
        mode = 0
    else:
        mode = int(args[1])
    return mode



def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(2)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    
    
    
    
    
    
    
    
    
    
    



if __name__ == '__main__':
    main()

Solution (Python):
import numpy as np
N,X = map(int,input().split())
Y = list(map(int,input().split()))
Z = [abs(y-X) for y in Y]
print(np.gcd.reduce(Z))

Solution (Python):
import math
from functools import reduce

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

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

distance = [abs(c - x) for c in city]

print(gcd(*distance))

Solution (Python):
import math
from functools import reduce

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

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

print(gcd(xn))

Solution (Python):

from functools import reduce
from math import gcd

n, X, *x = map(int, open(0).read().split())
x = [abs(i - X) for i in x]
print(reduce(gcd, x))

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

Solution (Python):

import math
from functools import reduce

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

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


import sys

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


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


if N ==1:
    ans =abs(x[0] -X)
else:
    ans =gcd_list(x_div)
print(ans)

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

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

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