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.
import java.util.*;
import java.io.*;
import java.math.*;
public class CF709B{
	public static void main(String args[]) {

		String name = "input";
		String path = "/media/remedy441/Study/Codes/Java/InputOutput/";
		Locale.setDefault(Locale.US);
		//FileInputStream fileIn = new FileInputStream(path + name + ".in");
		//File fileOut = new File(path + name + ".out");

		//InputReader in = new InputReader(fileIn);
		//PrintWriter out = new PrintWriter(path + name + ".out");

		InputReader in = new InputReader(System.in);
		PrintWriter out = new PrintWriter(System.out);

		//My Code Starts Here

		int n=in.nextInt();
		int p=in.nextInt();
		int ar[]=new int[n];
		for(int i=0;i<n;i++)
			ar[i]=in.nextInt();
		
		int ans=0;
		if(n==2)
		{
			ans=Math.min(Math.abs(p-ar[0]), Math.abs(p-ar[1]));
		}
		else if(n==3)
		{
			Arrays.sort(ar);
			int a1=ar[0];
			int a2=ar[1];
			int b1=ar[2];
			if(p>=b1)
				ans=p-a2;
			else if(p<=a1)
				ans=a2-p;
			else if(p<=a2)
			{
				int x=Math.abs(b1-p);
				int y=p-a1+a2-a1;
				int z=a2-p+a2-a1;
				ans=Math.min(x,Math.min(y, z));
			}
			else {

				int x=Math.abs(p-a1);
				int y=p-a2+b1-a2;
				int z=b1-p+b1-a2;
				ans=Math.min(x,Math.min(y, z));
			}
		}
		else if(n>3){
			Arrays.sort(ar);
			int a1=ar[0];
			int a2=ar[1];
			
			int b1=ar[n-1];
			int b2=ar[n-2];
			
			if(p<=a1)
				ans=b2-p;
			else if(p>=b1)
				ans=p-a2;
			else{
				int w=Math.abs(b2-a1)+Math.abs(p-a1);
				int x=Math.abs(b2-a1)+Math.abs(p-b2);
				int y=Math.abs(a2-b1)+Math.abs(p-a2);
				int z=Math.abs(a2-b1)+Math.abs(p-b1);
				
				ans=Math.min(w, Math.min(x, Math.min(y, z)));
				
			}
		}
		out.println(ans);
		
		//EndsHere

		out.close();

	}

	int sieveOfEratosthenes(int n) {
		// Create a boolean array "prime[0..n]" and initialize
		// all entries it as true. A value in prime[i] will
		// finally be false if i is Not a prime, else true.
		boolean prime[] = new boolean[n + 1];
		for (int i = 0; i <= n; i++)
			prime[i] = true;

		for (int p = 2; p * p <= n; p++) {
			// If prime[p] is not changed, then it is a prime
			if (prime[p] == true) {
				// Update all multiples of p
				for (int i = p * 2; i <= n; i += p)
					prime[i] = false;
			}
		}
		int c = 0;
		for (int i = 2; i <= n; i++) {
			if (prime[i] == true)
				c++;
		}
		return c;
		// Print all prime numbers
		/* for(int i = 2; i <= n; i++)
		{
		    if(prime[i] == true)
		        System.out.print(i + " ");
		}*/
	}

	static class Pair implements Comparable<Pair> {
		int u;
		int v;
		BigInteger bi;

		public Pair(int u, int v) {
			this.u = u;
			this.v = v;
		}

		public int hashCode() {
			int hu = (int) (u ^ (u >>> 32));
			int hv = (int) (v ^ (v >>> 32));
			return 31 * hu + hv;
		}

		public boolean equals(Object o) {
			Pair other = (Pair) o;
			return u == other.u && v == other.v;
		}

		public int compareTo(Pair other) {
			return Long.compare(u, other.u) != 0 ? Long.compare(u, other.u) : Long.compare(v, other.v);
		}

		public String toString() {
			return "[u=" + u + ", v=" + v + "]";
		}
	}

	static long modulo(long a, long b, long c) {
		long x = 1;
		long y = a;
		while (b > 0) {
			if (b % 2 == 1) {
				x = (x * y) % c;
			}
			y = (y * y) % c; // squaring the base
			b /= 2;
		}
		return x % c;
	}

	long factorial(long n, long M) {
		long ans = 1;
		while (n >= 1) {
			ans = (ans * n) % M;
			n--;
		}
		return ans;
	}

	static long gcd(long x, long y) {
		if (x == 0)
			return y;
		if (y == 0)
			return x;
		long r = 0, a, b;
		a = (x > y) ? x : y; // a is greater number
		b = (x < y) ? x : y; // b is smaller number
		r = b;
		while (a % b != 0) {
			r = a % b;
			a = b;
			b = r;
		}
		return r;
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream inputstream) {
			reader = new BufferedReader(new InputStreamReader(inputstream));
			tokenizer = null;
		}

		public String nextLine() {
			String fullLine = null;
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					fullLine = reader.readLine();
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
				return fullLine;
			}
			return fullLine;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}
	}
}