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



Sample input:
3 3
1 7 11


Sample output:
2

Submission status: Runtime Error

Solution code:
n,x = map(int, input().split())
city = []
sub = []
city = list(map(int, input().split()))

for i in range(len(city)):
	sub.append(abs(x - city[i]))

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

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

Submission status: Runtime Error

Solution code:
n,x = map(int, input().split())
city = []
sub = []
city = list(map(int, input().split()))

for i in range(len(city)):
	sub.append(abs(x - city[i]))

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

p = gcd(sub[0], sub[1])
for i in range(2,len(sub)):
	ans = gcd(p,sub[i])
	p = ans

print(p)

Submission status: Runtime Error

Solution code:
n,x = map(int, input().split())
city = []
sub = []
city = list(map(int, input().split()))

for i in range(len(city)):
	sub.append(abs(x - city[i]))

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

p = gcd(sub[0], sub[1])
for i in range(2,len(sub)):
	ans = gcd(p,sub[i])

print(ans)

Submission status: Runtime Error

Solution code:
n,x = map(int, input().split())
city = []
sub = []
city = list(map(int, input().split()))

for i in range(len(city)):
	sub.append(abs(x - city[i]))

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

for i in range(1,len(sub)):
	ans = gcd(sub[i-1], sub[i])

print(ans)

Submission status: Runtime Error

Solution code:
import math
#from functools import reduce

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

dist = [abs(X - x) for x in xi]
print(reduce(math.gcd, dist))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

dist = [abs(X - x) for x in xi]
print(reduce(math.gcd, dist))

Submission status: Runtime Error

Solution code:
from itertools import permutations
import math
from functools import reduce

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

dist = [abs(X - x) for x in xi]
print(reduce(math.gcd, dist))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
def gcd(arg_list):
    return reduce(math.gcd, arg_list)

N, X = tuple(map(int, input().split(" ")))
Xs = list(map(int, input().split(" ")))
r = gcd(Xs)
print(r)

Submission status: Runtime Error

Solution code:
N, X = list(map(int, input().split())) # 整数
list_temp = []
list_temp.append(list(map(int, input().split())))

list = list_temp[0]
list_dev = []

#公約数の関数作成
def devisor(x):
    list_div = []
    for i in range(1,x+1):
        if x % i == 0:
            list_div.append(i)
    return list_div

#xiとXの絶対値をとって、各絶対値の最大公約数を算出
for i in list:
    abs_temp = abs(i - X)
    list_dev += devisor(abs_temp)

l_dupli = [i for i in set(list_dev) if list_dev.count(i) > 2]
print(l_dupli[-1])

Submission status: Runtime Error

Solution code:
n, x =  map(int, input().split())
xi = map(int, input().strip().split())
c = [x] * n
xi = [x - y for (x,y) in zip(xi,c)]
def gcd(a, b):
  
  if b == 0: return a
  return gcd(b, a % b)
d0 = xi[0]
for i in range(n-1):
    d = gcd(xi[i+1],d0)
    d0 = d
print(abs(d))

Submission status: Runtime Error

Solution code:
n, x =  map(int, input().split())
xi = map(int, input().strip().split())
c = [1] * x
xi = [x - y for (x,y) in zip(xi,c)]
def gcd(a, b):
  if b == 0: return a
  return gcd(b, a % b)
d0 = xi[0]
for i in range(n-1):
    d = gcd(xi[i+1],d0)
    d0 = d
print(d)

Submission status: Runtime Error

Solution code:
n, x =  map(int, input().split())
xi = list(map(int, input().strip().split()))
c = [1] * x
xi = [x - y for (x,y) in zip(xi,c)]
def gcd(a, b):
  if b == 0: return a
  return gcd(b, a % b)
d0 = xi[0]
for i in range(n-1):
    d = gcd(xi[i+1],d0)
    d0 = d
print(d)

Submission status: Runtime Error

Solution code:
import math
n, fx = map(int, input().split())
x = list(map(int, input().split()))
x.append(fx)
x.sort()

ans = x[1]-x[0]
for i in range(2, len(x)):
  v = x[i]-x[i-1]
  ans = max(ans, math.gcd(ans, v))

print(ans)

Submission status: Runtime Error

Solution code:
import fractions

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

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

t = abs(x[0] - X)
for a in x:
  t = fractions.gcd(t, abs(a - X))
 
print(t)

Submission status: Runtime Error

Solution code:
import math
N, X = map(int, input().split())

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

t = abs(x[0] - X)
for a in x:
    t = math.gcd(t, abs(a - X))
print(t)

Submission status: Runtime Error

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

n, x = map(int, input().split())
num = list(map(int,input().split()))
d = num[0]-x
for nn in num:
    d=gcd(t,n-x)
print(d)

Submission status: Runtime Error

Solution code:
# math.gcd()を使う
import math
N, X = map(int, input().split())
# 一行の入力をリストxに入れる
x = list(map(int, input().split()))
# すべての(x[i]-X)の最大公約数が答え
# 最初の最大公約数
t = abs(x[0] - X)
for a in x:
    # 最大公約数を更新
    t = math.gcd(t, abs(a - X))
print(t)

Submission status: Runtime Error

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

n, x = map(int, input().split())
num = list(map(int,input().split()))
d = abs(num[0]-x)
for nn in num:
    d=gcd(t,abs(n-x))
print(d)

Submission status: Runtime Error

Solution code:
import math

n, x = map(int, input().split())
num = list(map(int,input().split()))
d = abs(num[0]-x)
for nn in num:
    d=math.gcd(t,abs(n-x))
print(d)

Submission status: Runtime Error

Solution code:
import numpy as np
import math
from functools import reduce

n, x = map(int, input().split())
num = list(map(int,input().split()))
nxx = np.array([x] * n)
nnum = np.array(num)
diff = nnum-nxx
d = reduce(math.gcd, diff)
print(d)

Submission status: Runtime Error

Solution code:
def gcd(a,b):
    if b > 0:
        c = a % b
        print(gcd(b,c))
    elif b == 0:
        print(a)

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

Submission status: Runtime Error

Solution code:
def gcd(a,b):
    if b > 0:
        c = a % b
        gcd(b,c)
    elif b == 0:
        print(a)

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

Submission status: Runtime Error

Solution code:
N, X = map(int,input().split())
x = list(input().split())
x = sorted([int(i) for i in x])
diff = []
res = 10**10
for i in x:
    if i !=x[0]:
        diff.append(i-old)
    res = min(abs(X-i),res)
    old = i
res = min(min(diff),res)
print(res)

Submission status: Runtime Error

Solution code:
N=int(input())
last = input()
wds = set([last])
res = "Yes"
for i in range(N-1):
    wd = input()
    if wd in wds or last[-1]!=wd[0]: 
        ans = "No"
        break
    last = wd
    wds.add(wd)
print(ans)

Submission status: Runtime Error

Solution code:
import fractions
N, X = map(int, input().split())
x = map(int, input().split())
r = abs(X-next(x))
for i in x:
    r = fractions.gcd(r, i-X))
print(r)

Submission status: Runtime Error

Solution code:
import math
N, X = map(int, input().split())
x = map(int, input().split())
r = next(x)-X
for i in x:
    r = math.gcd(r, i-X)
print(r)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
import math

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

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

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

print(gcd)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
import math
from functools import reduce

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

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

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

print(gcd(d))

Submission status: Runtime Error

Solution code:
import math
N, X = map(int, input().split())
x = list(map(int, input().split()))
t = abs(x[0] - X)
for a in x:
    t = math.gcd(t, a - X)
print(t)

Submission status: Runtime Error

Solution code:
def gcd(a, b):
    if b == 0:
        return a
    return(b, a % b)
n, x = map(int, raw_input().split())
d = map(int, raw_input().split())
g = abs(x - d[0])
for z in d:
    g = gcd(g, abs(z - x))
print g

Submission status: Runtime Error

Solution code:
def gcd(a, b):
	if(a > b):
		a -= b
		return gcd(a, b)
	elif(a < b):
		b -= a
		return gcd(a, b)
	else:
		return a

import numpy as np
n, x = map(int, input().split())
a = np.abs(np.array(list(map(int, input().split())))-x)

if(a.shape[0] == 1):
	r = a[0]
else:
	r = gcd(a[0], a[1])
	for i in range(n-2):
		r = gcd(r, a[i+2])
print(r)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

for i in range(len(a)):
	a[i] = abs(a[i] - x)

print(reduce(math.gcd, a))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

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

print(reduce(math.gcd, ans))

Submission status: Runtime Error

Solution code:
def lcm(a, b):
  if b > a:
    a, b = b, a
  
  while b != 0:
    a, b = b, a % b
  
  return a

city_num, start = map(int, input().split())

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

for i in range(len(cities)):
  cities[i] = abs(start - cities[i])

cities.sort()
  
a = reduce(lcm, cities)  

print(a)

Submission status: Runtime Error

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

import fraction

def gcd(*numbers):
	ret = numbers[0]
	for n in numbers[1:]:
		ret = fraction.gcd(ret, n)
	return ret

xi = map(lambda y:abs(y-x), xi)
print(gcd(*xi))

Submission status: Runtime Error

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

import fraction

def gcd(*numbers):
	ret = numbers[0]
	for n in numbers[1:]:
		ret = fraction.gcd(ret, n)
    return ret

xi = map(lambda y:abs(y-x), xi)
print(gcd(*xi))

Submission status: Runtime Error

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

import fraction
import functools

def gcd(*numbers):
    return functools.reduce(fraction.gcd, numbers)

xi = map(lambda y:y-x, xi)
print(gcd(*xi))

Submission status: Runtime Error

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

import fraction
import reduce

def gcd(*numbers):
    return functools.reduce(fraction.gcd, numbers)

xi = map(lambda y:y-x, xi)
print(gcd(*xi))

Submission status: Runtime Error

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

import math
import fraction
from functools import reduce

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

xi = map(lambda y:y-x, xi)
print(gcd(*xi))

Submission status: Runtime Error

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

import math
from functools import reduce

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

xi = map(lambda y:y-x, xi)
print(gcd(*xi))

Submission status: Runtime Error

Solution code:
from functools import reduce
import math
n,x=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(lambda c:abs(c-x),a))
print(reduce(math.gcd,b))

Submission status: Runtime Error

Solution code:
from functools import reduce
import fraction
n,x=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(lambda c:abs(c-x),a))
print(reduce(fraction.gcd,b))

Submission status: Runtime Error

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

inp = input().split()
inp = [int(x) for x in inp]

p = input().split()
p = [int(x) for x in p]

ans = gcd(abs(inp[1]-p[0]), abs(inp[1]-p[1]))
for i in range(len(p)):
    ans = gcd(ans, abs(inp[1]-p[i]))

print(ans)

Submission status: Runtime Error

Solution code:
import math

n, x = map(int, input().split())
a = list(map(int, input().split()))
arr = [abs(i-x) for i in a]
ans = arr.pop(0)
for i in arr:
    ans = math.gcd(ans, i)
print(ans)

Submission status: Runtime Error

Solution code:
import math

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

Submission status: Runtime Error

Solution code:
import math

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

Submission status: Runtime Error

Solution code:
n, x = map(int, input().split())
c = list(map(int, input().split()))
dis = set()
for i in range(1, n):
    dis.add(abs(c[i] - c[i-1]))
l = min(dis)
for i in range(l, 0, -1):
    d = True
    for item in dis:
        if item % i != 0:
            d = False
    if d:
        print(i)
        break

Submission status: Runtime Error

Solution code:
from functools import reduce
from math import gcd

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

lis=[abs(j-X) for j in x]

print(reduce(gcd,lis))

Submission status: Runtime Error

Solution code:
from functools import reduce
from math import gcd
 
N,X=[int(i) for i in input().split()]
x=[int(i) for i in input().split()]

lis=[abs(j-X) for j in x]

print(reduce(gcd,lis))

Submission status: Runtime Error

Solution code:
from functools import reduce
from math import gcd
 
N,X=[int(i) for i in input().split()]
x=[int(i) for i in input().split()]

lis=[abs(x[j]-X) for j in range(N)]

print(reduce(gcd,lis))

Submission status: Runtime Error

Solution code:
N, X = map(int, input().split())
x_lst = [int(i) for i in input().split()]
# N, X = map(int, '3 81'.split())
# x_list = [abs(int(i) - X) for i in '33 105 57'.split()]
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
res = [x_list[0]]
for i in range(1, N):
    res.append(gcd(res[i-1], x_list[i]))
print(min(res))

Submission status: Runtime Error

Solution code:
# coding: utf-8

import math
from functools import reduce


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


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

    diffs = []
    for i in xi:
        diffs.append(abs(x - i))

    print(gcd_list(diffs))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
# coding: utf-8


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

    diffs = []
    for i in xi:
        diffs.append(abs(x - i))

    for diff in diffs:
        if diff % min(diffs)) != 0:
            print('1')
            return

    print(min(diffs))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import fractions

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

b=[]
for i in a:
    b.append(abs(x-i))

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

else:
    ans=fractions.gcd(b[0],b[1])

    for i in range(2,n):
        ans = math.gcd(ans ,b[i])

    print(ans)

Submission status: Runtime Error

Solution code:
import sys
import functools
import math
if __name__ == '__main__':
    NX = [int(n) for n in input().split()]
    X = [int(n) for n in input().split()]
    if len(X) == 1:
        print(abs(X[0]-NX[1]))
        sys.exit(0)
    X.append(NX[1])
    X.sort()
    diff = [X[i] - X[i-1] for i in range(1, len(X))]
    D = functools.reduce(math.gcd, diff)
    print(D)
    # D = min(diff)
    # while any(np.array(diff)%D):
    #     D -= 1
    # print(D)

Submission status: Runtime Error

Solution code:
import sys
import numpy as np
if __name__ == '__main__':
    NX = [int(n) for n in input().split()]
    X = [int(n) for n in input().split()]
    if len(X) == 1:
        print(abs(X-NX[1]))
        sys.exit(0)

    X.sort()
    diff = [X[i] - X[i-1] for i in range(1, len(X))]
    D = min(diff)
    while any(np.array(diff)%D):
        D -= 1
    print(D)

Submission status: Runtime Error

Solution code:
import math
n,x=map(int,input().split())
xlist=list(map(int,input().split()))
xlist.sort(key=lambda xx:abs(xx-x))
for i in range(n):
    xlist[i]-=x
    xlist[i]=abs(xlist[i])
m=xlist[-1]
while xlist!=[0]*n:
    for i in range(n):
        
        xlist[i]%=m
        if xlist[i]>0:
            m=math.gcd(m,xlist[i])
print(m)

Submission status: Runtime Error

Solution code:
from math import gcd

[n, x] = map(int, input().split(" "))
xs = list(map(int, input().split(" ")))

xs.append(x)
xs.sort()

gc = xs[1] - xs[0]

for i in range(1, n + 1):
    gc = gcd(gc,  xs[i] - xs[i - 1])

print(gc)

Submission status: Runtime Error

Solution code:
import math

[n, x] = map(int, input().split(" "))
xs = list(map(int, input().split(" ")))

xs.append(x)
xs.sort()
gc = xs[1] - xs[0]

for i in range(1, n):
    gc = math.gcd(gc,  xs[i] - xs[i - 1])

print(gc)

Submission status: Runtime Error

Solution code:
n,x=map(int,input().split())
xlist=list(map(int,input().split()))
xlist.sort(key=lambda xx:abs(xx-x))
m=abs(xlist[0]-x)
for i in range(n):
    xlist[i]-=x
    xlist[i]=abs[xlist[i]]
while xlist==[0]*n:
   for i in range(n):
        xlist[i]%=m
        if xlist[i]>0:
            m=min((m,xlist[i]))
print(m)

Submission status: Runtime Error

Solution code:
import math

[n, x] = map(int, input().split(" "))
xs = list(map(int, input().split(" ")))
xs.append(x)
xs.sort()
gcd =  xs[1] - xs[0]

for i in range(1, n + 1):
    gcd = math.gcd(gcd,  xs[i] - xs[i - 1])

print(gcd)

Submission status: Runtime Error

Solution code:
import math

[n, x] = map(int, input().split(" "))
xs = list(map(int, input().split(" ")))
xs.append(x)
xs.sort()
gcd =  xs[1] - xs[0]

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

print(gcd)

Submission status: Runtime Error

Solution code:
import math

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

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

xs.sort()
gcd =  xs[1] - xs[0]

for i in range(1, len(xs)):
    gcd = math.gcd(gcd,  xs[i] - xs[i - 1])

print(gcd)

Submission status: Runtime Error

Solution code:
#encoding utf-8

import math
from functools import reduce

#複数の最大コゥ約数
def gcd(numbers):
    return reduce(math.gcd, numbers)

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

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

x.append(X)

x.sort()

minus=[]

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

D = gcd(minus)

print(int(D))

Submission status: Runtime Error

Solution code:
n,shoki=[int(x) for x in input().split()]
x=[int(x) for x in input().split()]
x.append(shoki)
x=sorted(x)
diff=set()
for i in range(n):
    diff.add(x[i+1]-x[i])
import math
diff=list(diff)
ans=diff[0]
for num in diff:
    ans=math.gcd(ans,num)
print(ans)

Submission status: Runtime Error

Solution code:
#encoding utf-8

import math
from functools import reduce


#複数の最大コゥ約数
def gcd(numbers):
    return reduce(math.gcd, numbers)

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

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

x.append(X)

x.sort()

minus=[]

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

D = gcd(minus)

print(int(D))

Submission status: Runtime Error

Solution code:
#encoding utf-8

import math
from functools import reduce


#複数の最大コゥ約数
def gcd(numbers):
    return reduce(math.gcd, numbers)

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

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

x.append(X)

x.sort()

minus=[]

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

D = gcd(minus)

print(D)

Submission status: Runtime Error

Solution code:
#encoding utf-8

import math
from functools import reduce


#複数の最大コゥ約数
def gcd(numbers):
    return reduce(math.gcd, numbers)

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

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

x.append(X)

x.sort()

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

D = gcd(minus)

print(D)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from math import gcd

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

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

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

print(tmp)

Submission status: Runtime Error

Solution code:
import numpy as np
from math import gcd

def LGcd(l):
    a = l[0]
    for i in range(1,len(l)):
        a = gcd(a,l[i])
    return a
N, X = map(int,input().split())
k = np.array(input().split())
k = k.astype(np.int64)
k -= X
if N == 1:
    print(str(abs(k[0])))
else:
    print(str(LGcd(k)))

Submission status: Runtime Error

Solution code:
import numpy as np
from math import gcd

def LGcd(l):
    a = l[0]
    for i in range(1,len(l)):
        a = gcd(a,l[i])
    return a
N, X = map(int,input().split())
k = np.array(input().split())
k = k.astype(np.int32)
k -= X
if N == 1:
    print(str(abs(k[0])))
else:
    print(str(LGcd(k)))

Submission status: Runtime Error

Solution code:
import numpy as np
from math import gcd
from functools import reduce
def LGcd(l):
    a = l[0]
    for i in range(1,len(l)):
        a = gcd(a,l[i])
    return a
N, X = map(int,input().split())
k = np.array(input().split())
k = k.astype(np.int32)
k -= X
if N == 1:
    print(str(abs(k[0])))
else:
    print(str(LGcd(k)))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy as np
from math import gcd
from functools import reduce
def LGcd(l):
    return reduce(gcd,l)
N, X = map(int,input().split())
k = np.array(input().split())
k = k.astype(np.int32)
k -= X
if N == 1:
    print(str(abs(k[0])))
else:
    print(str(LGcd(k)))

Submission status: Runtime Error

Solution code:
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)

n, x = map(int, input().split())
xlist = list(map(int, input().split()))
for i in range(n):
    xlist[i] = abs(xlist[i]-x)
    
if len(xlist)==1:
    print(xlist[0])
else:
    maxgcd = gcd(xlist[0], xlist[1])
    for i in range(2,n):
        maxgcd = gcd(maxgcd, xlist[i])
    
    
print(maxgcd)

Submission status: Runtime Error

Solution code:
# -*- coding:utf-8 -*-
import itertools

def main():
    """RE"""
    N, X = list(map(int, input().split()))
    xs = list(map(int, input().split()))

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

    low = 0
    high = 10**9+1
    for x in xs:
        if x < X:
            low = max(x, low)
            continue
        if x > X:
            high = min(x, high)
            continue

    Ds = []
    if low != 0: Ds.append(X - low)
    if high != 10**9+1: Ds.append(high - X)
    for d in Ds:
        failed = False
        for x in xs:
            if abs(X-x)%d == 0:
                continue
            else:
                failed = True
                break
        if failed:
            continue
        else:
            print(d)
            exit()
    print(1)


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

    import math
    from functools import reduce
    N, X = list(map(int, input().split()))
    xs = list(map(int, input().split()))

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

    diffs = []
    for x in xs:
        diffs.append(abs(x-X))
    print(gcd(*diffs))

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

    import math
    from functools import reduce
    N, X = list(map(int, input().split()))
    xs = list(map(int, input().split()))

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

    xs.append(X)
    xs.sort()
    diffs = []
    for i in range(len(xs)-1):
        diffs.append(xs[i+1] - xs[i])
    print(gcd(*diffs))

def main4():
    import math
    N, X = list(map(int, input().split()))
    xs = list(map(int, input().split()))

    diffs = []
    for x in xs:
        diffs.append(abs(X-x))

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

    ans = 10**9+1
    for i in range(len(diffs)-1):
        ans = min(math.gcd(diffs[i], diffs[i+1]), ans)
    print(ans)

if __name__ == "__main__":
    main4()

Submission status: Runtime Error

Solution code:
import math
import functools

n, x = map(int, input().split())
xlist = list(map(int, input().split()))
for i in range(n):
    xlist[i] = abs(xlist[i]-x)
    
gcd = functools.reduce(math.gcd, xlist)
    
print(gcd)

Submission status: Runtime Error

Solution code:
from math import gcd
n,x = map(int,input().split())
l = [int(ele) for ele in input().split()]
l.append(x)
l.sort()
g = 0 
for i in range(1,n+1):
    g = gcd(g,l[i]-l[i-1])
print(g)

Submission status: Runtime Error

Solution code:
import math

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

Submission status: Runtime Error

Solution code:
from functools import reduce
import math
n,x=map(int,input().split())
l=list(map(int,input().split()))
if n==1: ans=abs(l[0]-x)
else: ans=reduce(math.gcd,[abs(x-c) for c in l if abs(c)!=abs(x)])
print(ans)

Submission status: Runtime Error

Solution code:
from functools import reduce
import math
n,x=map(int,input().split())
l=list(map(int,input().split()))
ans=abs(l[0]-x)
ans=reduce(math.gcd,[abs(x-c) for c in l if c!=abs(x)])
print(ans)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

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

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

print(reduce(math.gcd, L))

Submission status: Runtime Error

Solution code:
from functools import reduce

def euclid(a, b):
    if a < b:
        a, b = (b, a)

    while True:
        r = a % b
        if r == 0:
            break
        a, b = (b, r)

    return b


if __name__ == '__main__':
    n, x = tuple(map(int, input().split()))
    points = [int(x) for x in input().split()]
    if not x in points:
        points.append(x)

    buf = [abs(points[i + 1] - points[i]) for i in range(len(points) - 1)]
    print(reduce(lambda a,b: euclid(a, b), bur))

Submission status: Runtime Error

Solution code:
    def euclid(a, b):
        if a < b:
            a, b = (b, a)
     
        while True:
            r = a % b
            if r == 0:
                break
            a, b = (b, r)
     
        return b
     
     
    if __name__ == '__main__':
        n, x = tuple(map(int, input().split()))
        points = [int(x) for x in input().split()]
        if not x in points:
            points.append(x)
     
        buf = [abs(points[i + 1] - points[i]) for i in range(len(points) - 1)]
        while len(buf) > 1:
            buf = [euclid(buf[i + 1], buf[i]) for i in range(len(buf) - 1)]
     
        print(buf[0])

Submission status: Runtime Error

Solution code:
"""
C - Skip
Xを含めた与えられた数列をソートする
最小値を基準０にする
隣同士の差を取る
数列の最大公約数を求める
"""

import math
from functools import reduce

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

numbers = [X]
for part in input().split():
    numbers.append(int(part))

numbers.sort()

# 最小値を基準0とする（ノーマライズ）
min_num = min(numbers)
normal_numbers = []
for num in numbers:
    normal_numbers.append(num - min_num)

# 隣との距離を出す
dist_numbers = []
for i in range(1, len(normal_numbers)):
    # 重複なしで隣との距離を数える
    dist_temp = normal_numbers[i] - normal_numbers[i-1]
    if dist_temp not in dist_numbers:
        dist_numbers.append(dist_temp)

# 最大公約数を求める
def gcd_list(numbers):
    return reduce(math.gcd, numbers)

print(gcd_list(dist_numbers))

Submission status: Runtime Error

Solution code:
# コンテスト時にトライしていたアルゴリズム
# その後の検証でアルゴリズムは正しそうなのでコードエラーを探す

n, x = map(int, input().split())
city_list = list(map(int, input().split()))
 
import numpy as np
 
def getNearestValue(list, num):
    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return list[idx]

nearest_city = getNearestValue(city_list, x)
# Dとなり最大値はXと最も近い都市との距離に等しい
max_D = abs(nearest_city-x)

# TLE対策 都市との距離は事前に計算
dist_list = []
for city in city:
    dist_list.append(abs(city - x))


for xx in reversed(range(1, max_D+1)):
    flag = True
    for dist in dist_list:
        if (dist % xx) != 0:
            flag = False
            break
    if flag:
        break
print(xx)

Submission status: Runtime Error

Solution code:
import numpy as np
import math
from functools import reduce

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

N, X = map(int, input().split(' '))
city = np.array(list(map(int, input().split(' '))))

city -= X
print(gcd(*city))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
def g(x):return reduce(math.gcd,x)
print(g([int(input().split()[1])]+list(map(int,input().split()))))

Submission status: Runtime Error

Solution code:
from functools import reduce
from math import gcd
n, x = map(int, input().split())
y = [int(v) - x for v in input().split()]
y.append(0)
g = reduce(gcd, y)
print(g)

Submission status: Runtime Error

Solution code:
num_str=input().split()
num=list(map(int, num_str))
n=num[0]
x=num[1]
num2_str=input().split()
distance=list(map(int, num2_str))

first_distance=list(map(lambda y:abs(y-x),distance))
min_distance=min(first_distance)

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

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

Submission status: Runtime Error

Solution code:
num_str=input().split()
num=list(map(int, num_str))
n=num[0]
x=num[1]
num2_str=input().split()
distance=list(map(int, num2_str))

first_distance=list(map(lambda y:abs(y-x),distance))
min_distance=min(first_distance)

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

Submission status: Runtime Error

Solution code:
from math import gcd

Submission status: Runtime Error

Solution code:
from math import gcd
from functools import reduce
N, X = map(int, input().split())