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):
from fractions import gcd
from functools import reduce
n, x = map(int, input().split())
X = list(map(int, input().split()))
X.append(x)
minn = min(X)

def rgcd(nums):
  return reduce(gcd, nums)
arr_X = [X[i]-minn for i in range(n+1)]
print(rgcd(arr_X))

Solution (Python):
from sys import stdin
from fractions import gcd
n, x, *xs = map(int, stdin.read().split())
result = abs(xs[0] - x)
for i in range(1, n):
  result = gcd(result, abs(xs[i] - x))
print(result)

Solution (Python):
import numpy as np

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

def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
    return g
n,x = map(int,input().split())
arr = list(map(int,input().split()))
arr = np.array(arr)
arr -= x
arr = np.abs(arr)


if len(arr) == 1:
    print(arr[0])
else:
    print(gcd(arr))

Solution (Python):
import fractions
import sys
n,X=map(int,input().split())
x=list(map(int,input().split()))
y=[]
if n==1:
  print(abs(x[0]-X))
  sys.exit()
for i in range(n):
  y.append(abs(x[i]-X))
G=100000000000
for j in range(n-1):
  G=min(G,fractions.gcd(y[j],y[j+1]))
print(G)

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

Solution (Python):
from fractions import gcd
import sys

N, X = map(int,input().split())
lis = list(map(int,input().split()))
diff = []


for i in range(N):
	diff.append(abs(X-lis[i]))

x=diff[0]
for j in range(N-1):
	x = gcd(x,diff[j+1])
print(x)

Solution (Python):

import sys
import math
from collections import defaultdict


sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]


mod = 10**9 + 7


def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))



import fractions
from functools import reduce

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

N,X = II()
x = III()

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

print(abs(gcd_list(x)))

Solution (Python):
n,x = map(int,input().split())
lst = sorted([x] + list(map(int,input().split())))

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

for i in range(n):
    if i==0:
        ans = lst[i+1] - lst[i]
    else:
        ans = gcd(ans,(lst[i+1]-lst[i]))
print(ans)

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

d = [abs(e - X) for e in x]

import fractions
from functools import reduce





print(reduce(fractions.gcd, d))

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

d = [abs(e - X) for e in x]

import fractions
g=0
for e in d:
  g=fractions.gcd(e,g)
print(g)

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


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

D = set()
for p in P:
    D.add(abs(p - X))

S = sorted(D)

ans = S[0]
for s in S:
    ans = gcd(ans, s)

print(ans)

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):
N, X=map(int, input().split())
x=[abs(int(i)-X) for i in input().split()]

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

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

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

for i in range(N):
  subx.append(abs(listx[i] - X))
if N == 1:
  subx.append(subx[0])

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

ans = gcd(subx[0], subx[1])

if N > 2:
  for i in range(2, N):
    ans = gcd(ans, subx[i])
  
print(ans)

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

ans = lcm_list(subx)

print(ans)

Solution (Python):
def gcd(a, b):
    while a > 0:
        if a < b:
            a, b = b, a
        a = a % b
    return b
def resolve():
    N,x=map(int,input().split())
    X=list(map(int,input().split()))
    X.append(x)
    X=list(set(X))
    X.sort()
    D=[]
    for i in range(len(X)-1):
        D.append(X[i+1]-X[i])
    ans=D[0]
    for d in D:
        if d%ans!=0:
            ans=gcd(ans,d)
    print(ans)
resolve()

Solution (Python):


import fractions

n, m = list(map(int, input().split()))
x_list = list(map(int, input().split()))

x_list = sorted(x_list + [m])
work_list = x_list[1:]
diff_list = [b - a for a, b in zip(x_list[:-1], x_list[1:])]


work = diff_list[0]
if len(diff_list) > 1:
    for a in diff_list[1:]:
        work = fractions.gcd(work, a)
d = work

print(d)

Solution (Python):
from numpy import*;N,X=input().split();x=array(list(map(int,input().split())));g=lambda x,y:g(y%x,x)if y%x else x;print(abs(frompyfunc(g,2,1).reduce(x-int(X))))

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

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

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

    distance = (abs(x-y) for y in town)
    res = next(distance)
    for d in distance:
        if d % res != 0:
            res = gcd(res, d)

    print(res)

if __name__ == "__main__":
    main()

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

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

    distance = (abs(x-y) for y in town)
    res = next(distance)
    for d in distance:
        if d % res != 0:
            res = gcd(res, d)

    print(res)

if __name__ == "__main__":
    main()

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

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

    distance = (abs(x-y) for y in town)
    res = next(distance)
    for d in distance:
        if d % res != 0:
            res = gcd(res, d)

    print(res)

if __name__ == "__main__":
    main()

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

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

distance = (abs(x-y) for y in town)
res = next(distance)
for d in distance:
    if d % res != 0:
        res = gcd(res, d)

print(res)

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

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

distance = (abs(x-y) for y in town)
res = next(distance)
for d in distance:
    res = gcd(res, d)

print(res)

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

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

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

    distance = map(lambda y: abs(x-y), town)
    res = next(distance)
    for d in distance:
        if d % res != 0:
            res = gcd(res, d)

    print(res)

if __name__ == "__main__":
    main()

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

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

def main():
    n, x = (int(i) for i in input().split())
    town = (int(i) for i in input().split())

    distance = (abs(x-y) for y in town)
    res = next(distance)
    for d in distance:
        if d % res != 0:
            res = gcd(res, d)

    print(res)

if __name__ == "__main__":
    main()

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

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

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

    distance = (abs(x-y) for y in town)
    res = next(distance)
    for d in distance:
        if d % res != 0:
            res = gcd(res, d)

    print(res)

if __name__ == "__main__":
    main()

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

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

def main():
    n, x = map(int, input().split())
    distance = (abs(x - int(y)) for y in input().split())

    res = next(distance)
    for d in distance:
        res = gcd(res, d)

    print(res)

if __name__ == "__main__":
    main()

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

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

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

    distance = (abs(x-y) for y in town)
    res = next(distance)
    for d in distance:
        res = gcd(res, d)

    print(res)

if __name__ == "__main__":
    main()

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

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

distance = (abs(x-y) for y in town)
res = next(distance)
for d in distance:
    res = gcd(res, d)

print(res)

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
    
if n == 1:
    print(abs(li[0]))
    
elif n == 2:
    print(gcd(li[0],li[1]))
    
elif n >= 3:

    c = gcd(li[0],li[1])
    
    for i in range(2,len(li)-1):
        c = gcd(c,li[i])
    print(c)

Solution (Python):
import fractions

n, x = map(int, input().split())
cities = [int(x) for x in input().split()]
cities.append(x)
cities = sorted(cities)

gaps = []

for c in range(len(cities)-1):
    gaps.append(cities[c+1] - cities[c])

A = 0

for g in sorted(gaps):
    A = fractions.gcd(A, g)

print(A)

Solution (Python):
from functools import reduce

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

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

d = map(lambda z: abs(z - x), town)
res = reduce(gcd, d)

print(res)

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

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

res = abs(town[0] - x)
for t in town[1:]:
    d = abs(t - x)
    res = gcd(res, d)

print(res)

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

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

res = abs(town[0] - x)
for t in town[1:]:
    d = abs(t - x)
    res = gcd(res, d)

print(res)

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

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

res = abs(town[0] - x)
for t in town[1:]:
    d = abs(t - x)
    res = gcd(res, d)

print(res)

Solution (Python):
from fractions import gcd

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

res = abs(town[0] - x)
for t in town[1:]:
    d = abs(t - x)
    res = gcd(res, d)

print(res)

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

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

dist = map(lambda y: abs(x - y), town)
res = reduce(gcd, dist)
print(res)

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

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

print(ans)

Solution (Python):
def main():
    N, X = map(int, input().split())
    p = [int(x) for x in input().split()]
    d = [abs(X-p[i]) for i in range(len(p))]
    v = d[0]
    for u in d[1:]:
        v = gcd(u, v)
    return v

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

if __name__ == '__main__':
    print(main())

Solution (Python):
import fractions

N, X = map(int, input().split())
Xs = list(map(int, input().split()))
Xsc, ans = [abs(x - X) for x in Xs], 0

for x in Xsc:
    ans = fractions.gcd(ans, x)
print(ans)

Solution (Python):
import fractions
import functools

def main():
    N, X = map(int, input().split())
    x = [X] + list(map(int, input().split()))
 
    sort_x = sorted(x)
    diff = [0] * N
    for i in range(N):
        diff[i] = sort_x[i + 1] - sort_x[i]

    ans = functools.reduce(fractions.gcd, diff)

    print(ans)

    


main()

Solution (Python):

from fractions import gcd

'''
https://img.atcoder.jp/abc109/editorial.pdf
答えは gcd(|X − x1|, |X − x2|, ..., |X − xN |)
'''


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



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




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

S.pop()
print(min(S))

Solution (Python):
a=list(map(int,input().split()))
x=[]
for i in input().split():
  x.append(abs(int(i)-a[1]))
def ucl(a,b):
  if a%b==0:
    return b
  else:
    return ucl(b,a%b)
while len(x) > 1:
  x2 = []
  mn_x = min(x)
  for n in range(len(x)):
    mod = x[n] % mn_x
    if mod != 0:
      x2.append(mod)
  x2.append(mn_x)
  x = x2
print(x[0])

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

while len(x) > 1:
  x2 = []
  mn_x = min(x)
  for n in range(len(x)):
    mod = x[n] % mn_x
    if mod != 0:
      x2.append(mod)
  x2.append(mn_x)
  x = x2
  
ans = x[0]
print(ans)

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


from functools import reduce
from fractions import gcd
def greatest_common_divisor(iter):
    '''
    最大公約数を返す
    '''
    return reduce(gcd, iter)


print(greatest_common_divisor(x))

Solution (Python):
import fractions

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

ans = 0
for x in Xsc:
    ans = fractions.gcd(ans, x)
print(ans)

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

if __name__ == "__main__":
    N, X = map(int, input().split())
    L = list(map(int, input().split()))
    L.append(X)
    D = [abs(x2 - x1) for x1, x2 in zip(L, L[1::])]
    print(reduce(gcd, D))

Solution (Python):
import math
import sys
import queue
from collections import Counter
from itertools import accumulate
from fractions import gcd
from functools import reduce


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

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

sys.setrecursionlimit(10000)

mod = 1000000007

"""

a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654


char_list = list("abcd") 



    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())


    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

if __name__ == "__main__":
    N, X = map(int, sys.stdin.readline().split())
    L = list(map(int, sys.stdin.readline().split()))
    L.append(X)
    L.sort()
    D = [abs(x2 - x1) for x1, x2 in zip(L, L[1::])]
    print(reduce(gcd, D))

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

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

if len(x) > 1:
    for i in range(1, n):
        y.append(x[i] - x[i-1])
else:
    print(abs(x[0] - X))
    sys.exit()


gcd = reduce(lambda x, y: fractions.gcd(x, y), y)

temp = 10**10

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

gcd = fractions.gcd(gcd, temp)
print(gcd)

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

x.append(X)
x.sort()
z=[]
for i in range(n):
    z.append(x[i+1]-x[i])
ans=z[0]
import fractions
for j in range(1,n):
    ans=fractions.gcd(ans,z[j])
print(ans)

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

Solution (Python):
import sys

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


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

if len(x) == 2:
    print(x[1]- x[0])
    sys.exit()

xx = [x[i+1] -x[i] for i in range(len(x)-1)]

g = gcd(xx[0],xx[1])

if len(xx) >= 3:
    for i in range(2,n):
        g = gcd(g,xx[i])

print(g)

Solution (Python):
from functools import reduce
import fractions


def solve():
    n, X = map(int, input().split())
    xs = list(map(int, input().split()))
    diffs = [abs(x - X) for x in xs]
    return reduce(fractions.gcd, diffs)


if __name__ == "__main__":
    print(solve())

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

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

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

if(ans<0):
    ans=-ans
    

print(ans)

Solution (Python):
from sys import stdin

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

N, X = [int(x) for x in stdin.readline().rstrip().split()]
x_lst = sorted(set([abs(int(x)-X) for x in stdin.readline().rstrip().split()]))

if len(x_lst) == 1:
  print(x_lst[0])
else:
  prev_x = x_lst[0]
  for x in x_lst[1:]:
    prev_x = gcd(prev_x, x)
    if prev_x == 1: break
  print(prev_x)

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

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

N, X = [int(x) for x in stdin.readline().rstrip().split()]
x_lst = sorted(set([abs(int(x)-X) for x in stdin.readline().rstrip().split()]))

if len(x_lst) == 1:
  print(x_lst[0])
else:
  prev_x = x_lst[0]
  for x in x_lst[1:]:
    prev_x = gcd(prev_x, x)
    if prev_x == 1: break
  print(prev_x)

Solution (Python):
from fractions import gcd

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

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

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 fractions import gcd
if N==1:
    a=x[0]
else:
    a=gcd(x[0],x[1])
    if N!=2:
      for i in range(2,N):
         a=gcd(a,x[i])
print(a)

Solution (Python):
import fractions as math

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

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

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

N, X = map(int, input().split())
V = list(map(int, input().split()))
V.append(X)
V.sort()
vD = {V[i+1]-V[i] for i in range(len(V)-1)}

res = min(vD)
for d in vD:
    res = gcd(res, d)
    if res <= 1:
        break
print(res)

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

N, X = map(int, input().split())
V = list(map(int, input().split()))
V.append(X)
V.sort()
vD = {V[i+1]-V[i] for i in range(len(V)-1)}

res = min(vD)
for d in vD:
    res = gcd(res, d)
    if res <= 1:
        break
print(res)

Solution (Python):



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

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

res = vD[0]
for d in vD:
    res = gcd(res, d)
    if res <= 1:
        break
print(res)

Solution (Python):

gcd = __import__("fractions").gcd

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

res = vD[0]
for d in vD:
    res = gcd(res, d)
print(res)

Solution (Python):
N,X=map(int,input().split())
def gcd(a,b):
    if a<b:
        a,b=b,a
    c=a%b
    if c==0:
        return b
    return gcd(b,c)

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

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


diff = [abs(i-x) for i in city_list]

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


fact = diff[-1]
for i in diff[:-1]:
    fact = gcd(fact, i)


print(fact)

Solution (Python):
N, X = map(int, input().split())
cities = [int(i) for i in input().split()]
cities.sort()
dist = [int(abs(i-X)) for i in cities]
dist.sort()
 
if N==1:
    print(max(dist))
else:
    while len(dist)>0:
        m = min(dist)
        dist = [int(i%m) for i in dist]
        dist.sort()
        while len(dist)>0 and dist[0]==0:
            dist.remove(0)
        if len(dist)==0:
            break
        else:
            dist.append(m)
    print(m)

Solution (Python):
from functools import reduce

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

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

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

Solution (Python):
from fractions import gcd

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

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

print(ans)

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


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


def resolve():
    n, x = list(map(int, input().split()))
    xxx = list(map(int, input().split()))
    xxx = [abs(i-x) for i in xxx]
    print(gcd_list(xxx))
resolve()

Solution (Python):
N,X = map(int,input().split())
x = list(map(int,input().split()))
x.append(X)
x = sorted(x)
dist = []
from fractions import gcd
for i in range(1,N+1):
    dist.append(x[i] - x[i-1])
    if i == 1:
        ans = dist[0]
    elif i > 1:
        ans = gcd(ans, dist[i-1])
print(ans)

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

import fractions

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

d = []
for i in a:
    d.append(abs(i-x))
ans = d[0]
for i in d:
    ans = fractions.gcd(i,ans)
print(ans)

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

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

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

m = 10**9
for i in a:
    m = min(m, abs(i-x))

d = make_divisors(m)
d.reverse()
for i in d:
    b = True
    for j in a:
        if abs(j-x) % i != 0:
            b = False
            break
    if b:
        print(i)
        break

Solution (Python):
import fractions
from functools import reduce

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


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

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

print(gcd(*xs))

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

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

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

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

Solution (Python):
def euqlid(a,b):
    if a < b :
        tmp = a
        a = b
        b = tmp

    while b != 0:
        rem = a % b
        a = b
        b = rem

    return a
N,X = list(map(int, input().split()))
x = list(map(int, input().split()))
x.append(X)
x.sort()
l = []
for i in range(N):
    l.append(x[i + 1] - x[i])
if len(l)  == 1:
    print(l[0])
    exit()
else:
    ans = euqlid(l[0],l[1])

for i in range(2,N - 1):
    ans = euqlid(ans,l[i])
print(ans)

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

N, X = map(int,input().split()) 
nums=list(map(int,input().split()))
nums=list(map(lambda i: abs(i - X),nums))
 
D = reduce(gcd, nums)
print(D)

Solution (Python):
import fractions
from functools import reduce


def gcd(L):
    return reduce(fractions.gcd, L)

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

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

ans = gcd(x_gap)
print(ans)

Solution (Python):
from fractions import gcd

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

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

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

for i in range(len(l)):
    diff.append(abs(l[i] - x))

gcd_1 = gcd(diff[0], diff[1])
if n == 2:
    print(gcd_1)
    exit()

for i in range(2, len(diff)-1):
    gcd_1 = gcd(gcd_1, diff[i])

print(gcd_1)

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


n, x0 = map(int, input().split())
x = [x0] + list(map(int, input().split()))
x.sort()
d = [x2 - x1 for x1, x2 in zip(x, x[1:])]

ans = d[0]
for d1, d2 in zip(d, d[1:]):
    ans = min(ans, gcd(d1, d2))

print(ans)

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

ans = abs(axis[0] - X)

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

for a in axis :
    ans = gcd(ans, abs(a - X))

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.append(X)
x.sort()
diffs = set()
for i in range(N):
    diffs.add(x[i + 1] - x[i])
if len(diffs) == 1:
    ans = diffs.pop()
else:
    ans = reduce(gcd, diffs)
print(ans)

Solution (Python):
import fractions

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

ans = tmp[0]

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

print(ans)

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

x = np.array(list(map(int, input().split())))
x -= X

x = np.abs(x)
D = 0
from fractions import gcd

for d in x:
  D = gcd(D,d)

print(D)

Solution (Python):
import sys
input = sys.stdin.readline
from operator import itemgetter

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

def gcd_ary(ary, n):
	for i in range(n-1):
		ary[i+1] = gcd(ary[i], ary[i+1])
	return ary[n-1]

def main():
	n, x = map(int, input().strip().split())
	v = list(map(int, input().strip().split()))
	d = [0] * n
	for i in range(n):
		d[i] = abs(x - v[i])
	print(gcd_ary(d, n))

if __name__ == '__main__':
	main()

Solution (Python):
n,X = map(int,input().split())
x = list(map(int,input().split()))
x.append(X)
x.sort()
diff = []
for i in range(n):
  diff.append(x[i+1] - x[i])
gcd = diff[0]
for i in range(1,n):
  big = diff[i]
  small = gcd
  while small != 0:
    tmp1 = big % small
    tmp2 = small
    big = tmp2
    small = tmp1
  gcd = big
print(gcd)

Solution (Python):


from fractions import gcd

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

Solution (Python):
import fractions

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

l.append(x)
l.sort()

l_dif = [l[i+1]-l[i] for i in range(n)]

ans = l_dif[0]

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

print(ans)

Solution (Python):

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

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

n,x=getints()
xs=getints()

res = abs(x-xs[0])

for i in range(n):
    d = abs(x - xs[i])
    res = gcd(res, d)

print(res)

Solution (Python):
import sys
from collections import deque

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def _euclid(x, y):
    if x > y:
        large = x
        small = y
    else:
        large = y
        small = x

    if small == 0:
        return large

    return _euclid(small, large % small)


def euclid_multi(nums):
    if len(nums) == 1:
        return nums[0]

    e = -1
    for i in range(1, len(nums)):
        if e == -1:
            e = _euclid(nums[0], nums[1])
        else:
            e = _euclid(e, nums[i])
    return e


def solve(inputs):
    [N, X] = string_to_int(inputs[0])
    x = string_to_int(inputs[1])
    x.append(X)
    x.sort()
    diffs = []
    for i in range(len(x)-1):
        diffs.append(x[i+1] - x[i])

    e = euclid_multi(diffs)
    return e


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(2))
    print(ret)

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

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


x.sort()



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

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


print(ans)