Vasya takes part in the orienteering competition. There are n checkpoints located along the line at coordinates x1, x2, ..., xn. Vasya starts at the point with coordinate a. His goal is to visit at least n - 1 checkpoint in order to finish the competition. Participant are allowed to visit checkpoints in arbitrary order.

Vasya wants to pick such checkpoints and the order of visiting them that the total distance travelled is minimized. He asks you to calculate this minimum possible value.

Input

The first line of the input contains two integers n and a (1 ≤ n ≤ 100 000,  - 1 000 000 ≤ a ≤ 1 000 000) — the number of checkpoints and Vasya's starting position respectively.

The second line contains n integers x1, x2, ..., xn ( - 1 000 000 ≤ xi ≤ 1 000 000) — coordinates of the checkpoints.

Output

Print one integer — the minimum distance Vasya has to travel in order to visit at least n - 1 checkpoint.

Examples

Input

3 10
1 7 12


Output

7


Input

2 0
11 -10


Output

10


Input

5 0
0 0 1000 0 0


Output

0

Note

In the first sample Vasya has to visit at least two checkpoints. The optimal way to achieve this is the walk to the third checkpoints (distance is 12 - 10 = 2) and then proceed to the second one (distance is 12 - 7 = 5). The total distance is equal to 2 + 5 = 7.

In the second sample it's enough to visit only one checkpoint so Vasya should just walk to the point  - 10.
from collections import Counter
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192
import math

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
def divs(n, start=2):
    divisors = []
    for i in range(start, int(math.sqrt(n) + 1)):
        if n % i == 0:
            if n / i == i:
                divisors.append(i)
            else:
                divisors.extend([i, n // i])
    return divisors
##########################################################
#it=iter(t)
#if all(c in it for c in s):
#ls.sort(key=lambda x: (x[0], x[1]))
# ls.sort(key=lambda x: (x[0], x[1]))
import sys

inf = float("inf")
mod = 1000000007


def array(): return list(map(int, sys.stdin.readline().split()))
def intt(): return map(int, sys.stdin.readline().split())
from bisect import bisect_left
import sys
n, k = map(int, sys.stdin.readline().split())
arr = list(map(int, sys.stdin.readline().split()))

arr.sort()

if n==1:
    print(0)
    exit()
elif n==2:
    if k>arr[1]:
        print(k-arr[1])
        exit()
    elif k<arr[0]:

        print(arr[0]-k)
        exit()
    else:
        print(min(k-arr[0],arr[1]-k))
        exit()

fr=arr[1]-arr[0] if k>=arr[1] else k-arr[0]
ba=arr[-1]-arr[-2] if k<=arr[-2] else arr[-1]-k
if k<=arr[0]:
    print(abs(arr[-2]-k))
elif k>=arr[-1]:
    print(abs(k-arr[1]))
else:
    d1=k-arr[0]
    d2=arr[-1]-k
    var=2*d1
    var2 = 0
    if arr[-2]>k:
        var+=arr[-2]-k
        var2 = 2 * (arr[-2] - k)
    v1=min(var,var2+d1)
    var=2*d2
    var2=0
    if k>arr[1]:
        var+=k-arr[1]
        var2+=2*(k-arr[1])
    v2=min(var,var2+d2)
    print(min(v1,v2))
#arr=[(int(x),i) for i,x in enumerate(input().split())]
# ls=list(map(int,input().split()))
# for i in range(m):
#print(s[i],end="")
#n=int(sys.stdin.readline())

#n = int(sys.stdin.readline())
#arr = list(map(int, sys.stdin.readline().split()))
