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: Wrong Answer

Solution code:
def main():
  n,m = input_list()
  x = input_list()
  if len(x) == 1:
    print(abs(x[0] - m))
    exit(0)
  diffs = []
  for i in range(len(x)):
    if i+1 > len(x)-1:
      break
    d = abs(x[i] - x[i+1])
    diffs.append(d)
  print(gcd_list(diffs))
  
def input_list():
  return list(map(int, input().split()))

def input_list_str():
  return map(str, input().split())

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

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

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

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

# 2で割り切れる回数
def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c 

import math
import fractions
import collections
from functools import reduce
main()

Submission status: Wrong Answer

Solution code:
import fractions
N,X = map(int,input().split())
x = list(map(int,input().split()))
x.append(X)
b = list(sorted(x))
c = list()
for i in range(N):
    c.append(b[i+1]-b[i])

t = c[0]
for i in range(N-1):
    t = fractions.gcd(t, c[i])
print(t)

Submission status: Wrong Answer

Solution code:
#ABC109C
def gcd(a,b):
    if a>=b:
        while b!=0:
            a,b=b,a%b
            return a
    else:
        while a!=0:
            b,a=a,b%a
            return b
n,x=map(int,input().split())
L=list(map(int,input().split()))
for i in range(n):
    L[i]=abs(L[i]-x)
ans=L[0]
for j in range(n):
        ans=gcd(ans,L[j])
print(ans)

Submission status: Wrong Answer

Solution code:
#ABC109C
def gcd(a,b):
    if a>=b:
        while b!=0:
            a,b=b,a%b
            return a
    else:
        while a!=0:
            b,a=a,b%a
            return b
n,x=map(int,input().split())
L=list(map(int,input().split()))
for i in range(n):
    L[i]=abs(L[i]-x)
ans=1
for j in range(1,n):
    if j==1:
        ans=gcd(L[0],L[1])
    else:
        ans=gcd(ans,L[j])
if n==1:
    ans=L[0]
print(ans)

Submission status: Wrong Answer

Solution code:
N, X = map(int, input().split())
x = list(map(int, input().split())) + [X]
x.sort()
print(x[1]-x[0])

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce

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

if n == 1:
    ans = xx[0]
else:
    dist = [xx[i + 1] - xx[i] for i in range(n - 1)]
    ans = reduce(fractions.gcd, dist)

print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce

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

if n == 1:
    ans = xx[0] - x
else:
    dist = [xx[i + 1] - xx[i] for i in range(n - 1)]
    ans = reduce(fractions.gcd, dist)

print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    n, x = map(int, input().split())
    L = list(set(map(int, input().split())))
    dist = sorted(set([abs(l-x) for l in L]))
    if n == 1:
        print(dist[0])
        return
    a = dist[0]
    mi = min([d - a for d in dist[1:]])
    print(min(a,mi))
main()

Submission status: Wrong Answer

Solution code:
N, X = map(int, input().split())
lens = [int(x)-X for x in input().split()]

import fractions
ans = lens[0]
for le in lens :
    ans = fractions.gcd(ans, le)

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
N, X = [int(i) for i in input().split()]
xn = np.array([int(i) for i in input().split()])
xn = abs(X-xn)

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
N, X = [int(i) for i in input().split()]
xn = np.array([int(i) for i in input().split()])

xn = abs(X-xn)

def gcd(a, b):
    if b > a :
        a, b = b, a 
    
    while b != 0:
        a = b
        b = a % b
    
    return a
  
for i in range(len(xn)):
    if i == 0:
        ans = xn[0]
    else:
        ans = gcd(ans, xn[i])

print(ans)

Submission status: Wrong Answer

Solution code:
n,X = map(int,input().split())
x = sorted(list(map(int,input().split())))
if max(x)>X: x = sorted(x+[X])
ans = 10**10
for i in range(len(x)-1):
    ans = min(ans,x[i+1]-x[i])
print(ans)

Submission status: Wrong Answer

Solution code:
n,X = map(int,input().split())
x = sorted(list(map(int,input().split()))+[X])
ans = 10**10
for i in range(n):
    ans = min(ans,x[i+1]-x[i])
print(ans)

Submission status: Wrong Answer

Solution code:
import fractions

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

y = []

x.sort()
for i in range(1, N):
    x1 = x[i] - x[i-1]
    y.append(x1)

if N == 1:
    d = abs(x[0] - X)
else:
    d = y[0]

for i in range(1, len(y)):
    d = fractions.gcd(y[i], d)

print(d)

Submission status: Wrong Answer

Solution code:
import fractions

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

y = []

x.sort()
for i in range(1, N):
    x1 = x[i] - x[i-1]
    y.append(x1)

if N == 1:
    d = x[0] - X
else:
    d = y[0]

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

print(d)

Submission status: Wrong Answer

Solution code:
import fractions

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

y = []

x.sort()
for i in range(1, N):
    x1 = x[i] - x[i-1]
    y.append(x1)

d = x[0] - X if N == 1 else y[0]

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

print(d)

Submission status: Wrong Answer

Solution code:
N,X=map(int,input().split())
x=list(map(int,input().split()))
for i in range(N):
  x[i]=abs(x[i]-X)
x.sort()
for i in range(N):
  if x[i]%x[0]!=0:
    x[0]=x[0]-1
print(x[0])

Submission status: Wrong Answer

Solution code:
import itertools as it
import collections as col
import fractions
from functools import reduce
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

n,x=map(int,input().split())
P=list(map(int,input().split()))
if(n==1):
    print(abs(P[0]-x))
    exit(0)
P.sort()
if(x<=P[0]):
    P.insert(0,x)
elif(x>=P[n-1]):
    P.append(x)
else:
    for i in range(1,n):
        if(P[i-1]<=x and x<=P[i]):
            P.insert(i,x)
D=[0]
for i in range(1,n):
    D.append(abs(P[i]-P[i-1]))
print(gcd_list(D))

Submission status: Wrong Answer

Solution code:
import itertools as it
import collections as col
import fractions
from functools import reduce
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

n,x=map(int,input().split())
P=list(map(int,input().split()))
if(n==1):
    print(abs(P[0]-x))
    exit(0)
P.sort()
if(x<=P[0]):
    P.insert(0,x)
elif(x>=P[n-1]):
    P.append(x)
else:
    for i in range(1,n):
        if(P[i-1]<=x and x<=P[i]):
            P.insert(i,x)
D=[0]
for i in range(1,n):
    D.append(P[i]-P[i-1])
print(gcd_list(D))

Submission status: Wrong Answer

Solution code:
import itertools as it
import collections as col

def List_gcd(a):
    import fractions
    ans = a[0]
    for i in range(1, len(a)):
        ans = fractions.gcd(ans, a[i])
    print(ans)


n,x=map(int,input().split())
P=list(map(int,input().split()))
if(n==1):
    print(abs(P[0]-x))
    exit(0)
P.sort()
if(x<=P[0]):
    P.insert(0,x)
elif(x>=P[n-1]):
    P.append(x)
else:
    for i in range(1,n):
        if(P[i-1]<=x and x<=P[i]):
            P.insert(i,x)
D=[0]
for i in range(1,n):
    D.append(P[i]-P[i-1])
List_gcd(D)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import fractions
N,X = map(int,input().split())
x = [int(i) for i in input().split()]
minus = []
if len(x)==1:
    ans = x[0]-X

else:
    ans = abs(x[0]-X)
    for i in range(len(x)-1):
        ans1 = abs(x[i+1]-x[i])
        ans = fractions.gcd(ans,ans1) 
print(ans)

Submission status: Wrong Answer

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

n, X = map(int, input().split())
x = list(map(int, input().split()))
if len(x) == 1:
  print(abs(x[0] - X))
else:
  x.sort()
  s = x[1] - x[0]
  for i in range(1, n-1):
    s = gcd(s, x[i+1]-x[i])
    print(s)
  a = 1
  for i in range(n):
    a = max(a, gcd(abs(X-x[i]), s))
  print(a)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
from fractions import gcd
N, X = map(int, input().split())
Xs = [int(i) for i in input().split()]

Xs.append(X)
dist = sorted(Xs)

i = dist[0]
# gcdは２数の最大公約数しか求めることができない。gcd(手前の２数の最大公約数,距離の値)とすれば全ての距離の最大公倍数が求められる。
for j in range(1, len(dist)):
    i = gcd(i, j)

print(i)

Submission status: Wrong Answer

Solution code:
N, X = map(int, input().split())
Xs = [int(i) for i in input().split()]

Xs.append(X)
dist = sorted(Xs)

diff = 10 ** 9
for i in range(1, len(dist)):
    tmp = dist[i] - dist[i-1]
    if tmp < diff:
        diff = tmp

print(diff)

Submission status: Wrong Answer

Solution code:
import fractions
n,x = map(int,input().split())

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

memo = []

for i in t:
    memo.append(abs(i-x))
ans = memo[0]
for i in range(n):
    ans = fractions.gcd(ans,memo[i])
    print(ans)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
n,k=map(int,input().split())
x=list(map(int,input().split()))
if n==1:
    print(x[0]-k)
    exit()

y=[]
for i in range(n):
    if i==0:
        y.append(abs(x[i]-k))
        continue
    y.append(abs(x[i]-x[i-1]))

ans=0
for i in range(len(y)):
    if i==0:
        ans=y[0]
        continue
    ans=gcd(y[i],ans)
print(ans)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
n,k=map(int,input().split())
x=list(map(int,input().split()))
if n==1:
    print(x[0]-k)
    exit()

y=[]
for i in range(1,n):
    y.append(abs(x[i]-x[i-1]))

ans=0
for i in range(len(y)):
    if i==0:
        ans=y[0]
        continue
    ans=gcd(y[i],ans)
print(ans)

Submission status: Wrong Answer

Solution code:
n, X = map(int, input().split())
x = list(map(int, input().split()))
x.append(X)
x = sorted(x)
y = [x[i+1]-x[i] for i in range(n)]

def eu(a, b):
    a, b = sorted([a,b])
    while a != 0:
        b, a = a, b%a
    return b
d = y[0]
for i in range(1, n-1):
    d = eu(d, y[i])
print(d)

Submission status: Wrong Answer

Solution code:
import numpy as np
import collections

def sumz(li):
    rt = 0
    for i in range(len(li)):
        rt += (li[i] == 0)
    return rt

n, x = map(int,input().split())
lx = np.array(list(map(int,input().split())))
lx.sort()
lx -= x


ans = 0
nums = 0

for i in range(len(lx)):
    d = abs(lx[i])
    lt = lx % d
    cup = sumz(lt)
    #cup += 1 if(j == 0 for j in lt) else 0
    if(cup > nums):
        nums = cup
        ans = d
print(ans)

#ls = [abs(lx[i]-x) for i in range(n)]

#print(min(ls))

Submission status: Wrong Answer

Solution code:
n, x = map(int, input().split())
l = list(map(int, input().split()))
sa = []
for i in range(n):
    t = abs(l[i] - x)
    sa.append(t)
sa = list(set(sa))
sa.sort()

# print(sa)

q = len(sa)


def ans(q, p):
    for i in range(q):
        if sa[i] % p != 0:
            p = sa[1]-sa[0]
            break
    else:
        print(p)


ans(q, sa[0])

Submission status: Wrong Answer

Solution code:

def gcd(p, q):
  a, b = (p, q) if p >= q else (q, p)
  c = a % b
  while c != 0:
    a, b = (b, c) if b >= c else (c, b)
    c = a % b
  return  a // b

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

diffs = []

if X < xn[0]:
  diffs.append(xn[0] -X)
for n in range(N-1):
  if xn[n] < X < xn[n+1]:
    diffs.append(X - xn[n])
    diffs.append(xn[n+1] - X)
  else:
    diffs.append(xn[n+1] - xn[n])
if X > xn[N-1]:
  diffs.append(X - xn[N-1])
if len(diffs) > 1:
  D = gcd(diffs[0], diffs[1])
  for i in range(N-2):
    D = gcd(D, diffs[i+2])
else:
  D = diffs[0]
print(D)

Submission status: Wrong Answer

Solution code:
def gcd(n,m):
    n,m = max(n,m),min(n,m)
    r = n % m
    while r > 0:
        n,m = m,r
        r = n % m
    return m
N,X = map(int,input().split())
x = [X - y for y in list(map(int,input().split()))]
ans = x[0]
for i in range(1,N):
    ans = gcd(ans, x[i])
print(abs(ans))

Submission status: Wrong Answer

Solution code:
def gcd(n,m):
    n,m = max(n,m),min(n,m)
    r = n % m
    while r > 0:
        n,m = m,r
        r = n % m
    return m
N,X = map(int,input().split())
x = sorted([X]+list(map(int,input().split())))
ans = x[1]-x[0]
for i in range(N-1):
    ans = gcd(ans, x[i+1]-x[i])
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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


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

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

x = np.array(x)

x.sort()

y = []

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


if len(x) == 1:
    ans = x[0]-1

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

print(ans)

Submission status: Wrong Answer

Solution code:
from functools import reduce

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

def gcd_lis(lis):
    return reduce(gcd, lis)

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

n, x = map(int, input().split())
X = list(map(int, input().split()))
X = [x_ - x for x_ in X]
X.sort()
dX = [0]*(n-1)
for i in range(n-1):
    dX[i] = X[i+1]-X[i]

if n>1:
    print(gcd_lis(dX))
else:
    print(abs(X[0]))

Submission status: Wrong Answer

Solution code:
import fractions
n,x = [int(x) for x in input().split()]
X = [int(x) for x in input().split()]
X.sort()

x_diff = [int(X[i+1] - X[i]) for i in range(n-1)]

if x_diff:
    ans = x_diff[0]
    for y in range(1,n-1):
        ans = fractions.gcd(ans, x_diff[y])
else:
    ans = X[0] - x

print(ans)

Submission status: Wrong Answer

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

d = max(a) - x
for i, j in zip(a, a[1:]):
  d = min(abs(i - x), d, j - i)
  
print(d)

Submission status: Wrong Answer

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

d = max(a)
for i in a:
  d = min(abs(i - x), d)
  
print(d)

Submission status: Wrong Answer

Solution code:
import fractions
N, X = map(int, input().split())
*x, = sorted(list(map(int, input().split())))
kyori = sorted([abs(X - xx) for xx in x])
ruisekiwa = [0] * (N+1)
for i in range(N):
    ruisekiwa[i+1] = fractions.gcd(ruisekiwa[i], kyori[i])
print(max(ruisekiwa))

Submission status: Wrong Answer

Solution code:
N, X = map(int, input().split())
*x, = sorted(list(map(int, input().split())))
kyori = [abs(X - xx) for xx in x]
print(min(kyori))

Submission status: Wrong Answer

Solution code:
N, X = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
if X in x:
    x.remove(X)
ans = max(x)
for i in x:
    ans = min(ans, abs(X - i))
print(ans)

Submission status: Wrong Answer

Solution code:
N, X = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
ans = max(x)
for i in x:
    ans = min(ans, abs(X - i))
print(ans)

Submission status: Wrong Answer

Solution code:
N, X = map(int,input().split())
xi = list(map(int,input().split()))
xi.append(X)
xi.sort()
mini = max(xi)
for i in range(N):
    mini = min(xi[i+1]-xi[i],mini)
print(mini)

Submission status: Wrong Answer

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

l.append(x)

l.sort()
sub = []
sub.append(abs(l[0] - l[1]))
for i in range(1, n - 1):
  sub.append(abs(l[i + 1] - l[i]))

# a,bの最大公約数を求めます。（ユークリッドの互除法）
def gcd(m, n):
  if n == 0:
    return m

  return gcd(n, m % n)

#gcd_複数の値の最大公約数を求める
def gcd_2(a):
  if len(a) == 1:
    return a[0]

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

ans = gcd_2(sub)
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
n,x = map(int,input().split())
a = list(map(int,input().split()))
def gcd(a,b):
    if b > a: a,b = b,a
    while b > 1:
        #print(a,b)
        a,b = b,a%b
    return a
cur_gcd = 1
a.sort()
for i in range(n):
    if x != a[i]:
        cur_gcd = gcd(cur_gcd,abs(x-a[i]))
        #print(cur_gcd)
print(cur_gcd)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
n,x = map(int,input().split())
a = list(map(int,input().split()))
def gcd(a,b):
    if b > a: a,b = b,a
    while b > 1:
        #print(a,b)
        a,b = b,a%b
    return a
cur_gcd = 0
for i in range(n):
    if x != a[i]:
        cur_gcd = gcd(cur_gcd,abs(x-a[i]))
        #print(cur_gcd)
print(cur_gcd)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
n,x = map(int,input().split())
a = list(map(int,input().split()))
def gcd(a,b):
    if b > a: a,b = b,a
    while b > 1:
        #print(a,b)
        a,b = b,a%b
    return a
cur_gcd = 1
for i in range(n):
    if x == a[i]: pass
    else:
        cur_gcd = gcd(cur_gcd,abs(x-a[i]))
        #print(cur_gcd)
print(cur_gcd)

Submission status: Wrong Answer

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

x.sort()

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

import fractions

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

print(ans)

Submission status: Wrong Answer

Solution code:
N, X = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
ans = 10e9
for i in range(N):
    ans = min(ans, abs(X - x[i]))
print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
import sys

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

if len(li) == 1:
  print(li[0] - X)
  sys.exit()
  
li.append(X)
li.sort(reverse=True)

ans = li[0] - li[1]

for index, i in enumerate(li):
  if index == 0:
    continue

  if index == len(li) - 1:
    break

  ans = fractions.gcd(ans, i - li[index+1])

print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
import sys

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

li.sort(reverse=True)

if len(li) == 1:
  print(li[0] - X)
  sys.exit()

ans = li[0] - li[1]

for index, i in enumerate(li):
  if index == 0:
    continue

  if index == len(li) - 1:
    break

  ans = fractions.gcd(ans, i - li[index+1])

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

x.append(xx)
x.sort()

dis = 10 ** 9
for i in range(n):
    dis = min(dis, x[i + 1] - x[i])

print(dis)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
N,X=map(int,input().split(' '))
x=sorted(list(map(int,input().split(' ')))+[X],reverse=True)
x_dif=[x[i]-x[i+1] for i in range(N)]
ans = x_dif[0]
for i in x_dif:
    ans = gcd(ans,i)
print(i)

Submission status: Wrong Answer

Solution code:
N,X=map(int,input().split())
x = list(map(int,input().split()))
if not X in x:
    x.append(X)
x.sort()
d = []
for i in range(len(x)-1):
    d.append( x[i+1] - x[i] )

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

g = d[0]
lcm = d[0]
for i in range( len(d)-1 ):
    lcm = g * d[i+1] // GCD(g,d[i+1])
print(lcm)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce

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

print(reduce(gcd,ls))

Submission status: Wrong Answer

Solution code:
import fractions
n , x = map(int,input().split())
X = list(map(int,input().split()))
Y =[]
for i in range(n):
    Y.append(abs(X[i]-x))
print(Y)
ans = Y[0]
for i in range(n):
    ans = fractions.gcd(ans, Y[i])
print(ans)

Submission status: Wrong Answer

Solution code:
N, X = map(int, input().split())
x = list(map(int, input().split()))
x = sorted(x)
D = [x[i + 1] - x[i] for i in range(len(x) - 1)]
# print(D)


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


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

ans = 0
for i in range(len(D)):
    if i == 0:
        ans = D[i]
    else:
        ans = gcd(D[i], ans)
print(ans)

Submission status: Wrong Answer

Solution code:
N, X = map(int, input().split())
a = list(map(int, input().split()))

if N == 1:
  print(a[0] - X)
  exit()
  
m = []
for aa in a:
  m.append(abs(X-aa))

ans = 0
import fractions
for i, g in enumerate(m):
  ans = fractions.gcd(ans, g)
  
print(ans)

Submission status: Wrong Answer

Solution code:
N, X = map(int, input().split())
a = list(map(int, input().split()))

if N == 1:
  print(a[0] - X)
  exit()
  
m = []
for aa in a:
  m.append(abs(X-aa))

gcds = []
import fractions
for i, g in enumerate(m):
  if i == len(m) - 1:
    break
  gcd = fractions.gcd(g, m[i+1])
  gcds.append(gcd)
  
  
print(max(gcds))

Submission status: Wrong Answer

Solution code:
N, X = map(int, input().split())
a = list(map(int, input().split()))

m = []
for aa in a:
  m.append(abs(X-aa))
  
print(min(m))

Submission status: Wrong Answer

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

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

a=[]

x.append(m)
x.sort()
for i in range(n-1):
    a.append(x[i+1]-x[i])
count=a[0]

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

for i in range(1,len(a)):
    count=gcd(count,a[i])
print(count)

Submission status: Wrong Answer

Solution code:
import fractions

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

ans = x[0]

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

print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce

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

print(reduce(fractions.gcd, x))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools

class cin():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def mapInt():
        return [int(x) for x in cin.string().split()]
    def stringList(n):
        return [input() for i in range(n)]
    def intListList(n):
        return [cin.mapInt() for i in range(n)]

class Util():
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Util.round_up(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x
class Math():
    def gcd(a,b):
        if b == 0:
            return a
        return Math.gcd(b,a % b)

N,X = cin.mapInt()
A = cin.mapInt()
A.append(X)

def solve():
    A.sort()
    subs = [0] * (N)
    for i in range(N):
        subs[i] = A[i + 1] - A[i]
    ans = subs[0]
    for i in range(1,N - 1):
        ans = Math.gcd(ans,subs[i])
    return ans
print(solve())

Submission status: Wrong Answer

Solution code:
import fractions


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

#print(x)

difflis = [0] * (n)

for i in range(n):
    difflis[i] = x[i+1] - x[i]

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

Submission status: Wrong Answer

Solution code:
import fractions
import math

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

#print(x)

difflis = [0] * (n)

for i in range(n):
    difflis[i] = math.fabs(x[i+1] - x[i])

ans = difflis[0]
for i in range(i,len(difflis)):
    ans = fractions.gcd(ans,difflis[i])
print(int(ans))

Submission status: Wrong Answer

Solution code:
import fractions
import math

n,X= map(int,input().split())
x = list(map(int, input().split()))
ins = 0
for i in range(n):
    if x[i] >=X:
        ins = i
        break
x.insert(ins,X)
x = sorted(x)

#print(x)

difflis = [0] * (n)

for i in range(n):
    difflis[i] = math.fabs(x[i+1] - x[i])

ans = difflis[0]
for i in range(i,len(difflis)):
    ans = fractions.gcd(ans,difflis[i])
print(int(ans))

Submission status: Wrong Answer

Solution code:
import fractions
import math

n,X= map(int,input().split())
x = list(map(int, input().split()))
ins = 0
for i in range(n):
    if x[i] >=X:
        ins = i
        break
x.insert(ins,X)
x = sorted(x)

print(x)

difflis = [0] * (n)

for i in range(n):
    difflis[i] = math.fabs(x[i+1] - x[i])

ans = difflis[0]
for i in range(i,len(difflis)):
    ans = fractions.gcd(ans,difflis[i])
print(int(ans))

Submission status: Wrong Answer

Solution code:
import fractions
import math

n,X= map(int,input().split())
x = list(map(int, input().split()))
ins = 0
for i in range(n):
    if x[i] >=X:
        ins = i
        break
x.insert(ins,X)

#print(x)

difflis = [0] * (n)

for i in range(n):
    difflis[i] = math.fabs(x[i+1] - x[i])

ans = difflis[0]
for i in range(i,len(difflis)):
    ans = fractions.gcd(ans,difflis[i])
print(int(ans))

Submission status: Wrong Answer

Solution code:
import fractions
import math

n,X= map(int,input().split())
x = list(map(int, input().split()))
ins = 0
for i in range(n):
    if x[i] >=X:
        ins = i
        break
x.insert(ins,X)

print(x)

difflis = [0] * (n)

for i in range(n):
    difflis[i] = math.fabs(x[i+1] - x[i])

ans = difflis[0]
for i in range(i,len(difflis)):
    ans = fractions.gcd(ans,difflis[i])
print(int(ans))

Submission status: Wrong Answer

Solution code:
import fractions
import math

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

difflis = [0] * (n)

for i in range(n):
    difflis[i] = math.fabs(x[i+1] - x[i])

ans = difflis[0]
for i in range(i,len(difflis)):
    ans = fractions.gcd(ans,difflis[i])
print(int(ans))

Submission status: Wrong Answer

Solution code:
N, X = map(int, input().split())
positions = [int(i) for i in input().split()]

ans = min([abs(X - p) for p in positions])
print(ans)

Submission status: Wrong Answer

Solution code:
n,x = map(int,input().split())
l = list(map(int,input().split()))
l.append(x)
l.sort()
sa = []
for i in range(n):
    sa.append(l[i+1]-l[i])
print(min(sa))

Submission status: Wrong Answer

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

x.append(X)
x.sort()

diff = [x[i+1] - x[i] for i in range(N)]
print(min(diff))

Submission status: Wrong Answer

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

x.append(X)
x.sort()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
from fractions import gcd
n, x = map(int, input().split())
X = np.array(list(map(int, input().split())))

X = np.abs(X - x)
X = np.sort(X)
print(X)

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

Submission status: Wrong Answer

Solution code:
import sys

INPUT = lambda: sys.stdin.readline().rstrip()
MAP = lambda: map(int, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))

sys.setrecursionlimit(10 ** 9)


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

    divisors.sort(reverse=True)
    return divisors


def main():
    N, X = MAP()
    x = LIST()

    if N == 1:
        print(max(1000000000 - X, X - 1))
        sys.exit()

    for d in make_divisors(max(x)-min(x)):
        for i in range(N):
            if abs(X - x[i]) % d != 0: break
        else:
            print(d)
            sys.exit()


if __name__ == '__main__':
    main()