#include <bits/stdc++.h>
using namespace std;
typedef vector<pair<long long int, long long int> > pairsvector;
void printvictor(vector<long long int> v) {
  for (long long int i = 0; i < v.size(); i++) cout << v[i] << " ";
  cout << endl;
}
void printPQ(priority_queue<long long int> pq) {
  while (!pq.empty()) {
    cout << pq.top() << " ";
    pq.pop();
  }
  std::cout << '\n';
}
template <class T>
string toStr(const T &x) {
  stringstream s;
  s << x;
  return s.str();
}
template <class T>
long long int toInt(const T &x) {
  stringstream s;
  s << x;
  long long int r;
  s >> r;
  return r;
}
bool isprime(long long int n) {
  if (n == 2) return true;
  if (n < 2 || n % 2 == 0) return false;
  for (long long int i = 3; i * i <= n; i += 2) {
    if (n % i == 0) return false;
  }
  return true;
}
vector<long long int> generate_divisors(long long int n) {
  vector<long long int> v;
  long long int i;
  for (i = 1; i <= n; ++i)
    if (n % i == 0) v.push_back(i);
  return v;
}
long long int BinaryToDec(string binary) {
  long long int arr[binary.length()];
  long long int sum = 0;
  for (long long int i = 0; i < binary.length(); i++) arr[i] = pow(2, i);
  reverse(binary.begin(), binary.end());
  for (long long int i = 0; i < binary.length(); i++)
    if (toInt(binary[i]) == 1) sum += arr[i];
  return sum;
}
string DecToBinary(long long int decimal) {
  string binary = "";
  while (true) {
    if (decimal % 2 == 0)
      binary += '0';
    else
      binary += '1';
    if (decimal == 1) break;
    decimal /= 2;
  }
  reverse(binary.begin(), binary.end());
  return binary;
}
long long int gcd(long long int a, long long int b) {
  return b == 0 ? a : gcd(b, a % b);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int n, a;
  cin >> n >> a;
  std::vector<long long int> yvector(n);
  for (long long int i = 0; i < n; i++) cin >> yvector[i];
  sort(yvector.begin(), yvector.end());
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  if (a == yvector[0]) {
    if (n > 1)
      cout << abs(a - yvector[n - 2]) << "\n";
    else
      cout << 0 << "\n";
  } else if (a == yvector[n - 1]) {
    if (n > 1)
      cout << abs(a - yvector[1]) << "\n";
    else
      cout << 0 << "\n";
  } else {
    long long int result =
        abs(a - yvector[n - 2]) + abs(yvector[n - 2] - yvector[0]);
    result =
        min(result, abs(a - yvector[0]) + abs(yvector[0] - yvector[n - 2]));
    result =
        min(result, abs(a - yvector[n - 1]) + abs(yvector[n - 1] - yvector[1]));
    result =
        min(result, abs(a - yvector[1]) + abs(yvector[1] - yvector[n - 1]));
    cout << result << endl;
  }
  return 0;
}

### Prompt

Construct a cpp code solution to the problem outlined:

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.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
typedef vector<pair<long long int, long long int> > pairsvector;
void printvictor(vector<long long int> v) {
  for (long long int i = 0; i < v.size(); i++) cout << v[i] << " ";
  cout << endl;
}
void printPQ(priority_queue<long long int> pq) {
  while (!pq.empty()) {
    cout << pq.top() << " ";
    pq.pop();
  }
  std::cout << '\n';
}
template <class T>
string toStr(const T &x) {
  stringstream s;
  s << x;
  return s.str();
}
template <class T>
long long int toInt(const T &x) {
  stringstream s;
  s << x;
  long long int r;
  s >> r;
  return r;
}
bool isprime(long long int n) {
  if (n == 2) return true;
  if (n < 2 || n % 2 == 0) return false;
  for (long long int i = 3; i * i <= n; i += 2) {
    if (n % i == 0) return false;
  }
  return true;
}
vector<long long int> generate_divisors(long long int n) {
  vector<long long int> v;
  long long int i;
  for (i = 1; i <= n; ++i)
    if (n % i == 0) v.push_back(i);
  return v;
}
long long int BinaryToDec(string binary) {
  long long int arr[binary.length()];
  long long int sum = 0;
  for (long long int i = 0; i < binary.length(); i++) arr[i] = pow(2, i);
  reverse(binary.begin(), binary.end());
  for (long long int i = 0; i < binary.length(); i++)
    if (toInt(binary[i]) == 1) sum += arr[i];
  return sum;
}
string DecToBinary(long long int decimal) {
  string binary = "";
  while (true) {
    if (decimal % 2 == 0)
      binary += '0';
    else
      binary += '1';
    if (decimal == 1) break;
    decimal /= 2;
  }
  reverse(binary.begin(), binary.end());
  return binary;
}
long long int gcd(long long int a, long long int b) {
  return b == 0 ? a : gcd(b, a % b);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int n, a;
  cin >> n >> a;
  std::vector<long long int> yvector(n);
  for (long long int i = 0; i < n; i++) cin >> yvector[i];
  sort(yvector.begin(), yvector.end());
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  if (a == yvector[0]) {
    if (n > 1)
      cout << abs(a - yvector[n - 2]) << "\n";
    else
      cout << 0 << "\n";
  } else if (a == yvector[n - 1]) {
    if (n > 1)
      cout << abs(a - yvector[1]) << "\n";
    else
      cout << 0 << "\n";
  } else {
    long long int result =
        abs(a - yvector[n - 2]) + abs(yvector[n - 2] - yvector[0]);
    result =
        min(result, abs(a - yvector[0]) + abs(yvector[0] - yvector[n - 2]));
    result =
        min(result, abs(a - yvector[n - 1]) + abs(yvector[n - 1] - yvector[1]));
    result =
        min(result, abs(a - yvector[1]) + abs(yvector[1] - yvector[n - 1]));
    cout << result << endl;
  }
  return 0;
}

```