#include <bits/stdc++.h>
using namespace std;
int Set(int N, int pos) { return N = N | (1 << pos); }
int check(int N, int pos) { return N & (1 << pos); }
bool isLinier(int a, int b, int m, int n, int x, int y) {
  int t1, t2;
  t1 = (n - b) * (x - m);
  t2 = (y - n) * (m - a);
  if (t1 == t2)
    return true;
  else
    return false;
}
struct line {
  void values(double x, double y, double z) { a = x, b = y, c = z; }
  double a, b, c;
};
pair<double, double> sectionPoint(line l1, line l2) {
  double a1, b1, c1, a2, b2, c2, x, y, dx, dy, d;
  a1 = l1.a, b1 = l1.b;
  c1 = l1.c;
  a2 = l2.a;
  b2 = l2.b;
  c2 = l2.c;
  d = a1 * b2 - b1 * a2;
  if (d == 0) return make_pair(-1, -1);
  dx = c1 * b2 - c2 * b1;
  dy = a1 * c2 - a2 * c1;
  x = dx * 1.0 / d;
  y = dy * 1.0 / d;
  cout << x << endl << y << endl;
  return make_pair(x, y);
}
line equation(pair<double, double> point1, pair<double, double> point2) {
  double x1, x2, y1, y2;
  x1 = point1.first;
  y1 = point1.second;
  x2 = point2.first;
  y2 = point2.second;
  double kx, ky;
  line ret;
  kx = x1 - x2;
  ky = y1 - y2;
  ret.a = ky;
  ret.b = kx;
  ret.c = x1 * ky - y1 * kx;
  if (ret.a < 0) {
    ret.a *= -1;
    ret.b *= -1;
    ret.c *= -1;
  }
  cout << ret.a << "x+" << ret.b << "y=" << ret.c << endl;
  return ret;
}
double const eps = 1e-9;
long long manhattan(long long x1, long long y1, long long x2, long long y2) {
  return abs(x1 - x2) + abs(y1 - y2);
}
int bigPow(int a, int b, int m) {
  if (b == 1) return a % m;
  if (b == 0) return 1;
  long long res = bigPow(a, b / 2, m);
  res = (res * res) % (long long)m;
  if (b % 2) res = (res * a % m) % m;
  return res;
}
int MMI_Fermat(int a, int m) { return bigPow(a, m - 2, m); }
void ext_euclid(long long a, long long b, long long &x, long long &y,
                long long &g) {
  x = 0, y = 1, g = b;
  long long m, n, q, r;
  for (long long u = 1, v = 0; a != 0; g = a, a = r) {
    q = g / a, r = g % a;
    m = x - u * q, n = y - v * q;
    x = u, y = v, u = m, v = n;
  }
}
long long mod_inv(long long n, long long m) {
  long long x, y, gcd;
  ext_euclid(n, m, x, y, gcd);
  if (gcd != 1) return 0;
  return (x + m) % m;
}
long long crt(vector<long long> &a, vector<long long> &x) {
  long long z = 0;
  long long n = 1;
  for (int i = 0; i < x.size(); ++i) n *= x[i];
  for (int i = 0; i < a.size(); ++i) {
    long long tmp = (a[i] * (n / x[i])) % n;
    tmp = (tmp * mod_inv(n / x[i], x[i])) % n;
    z = (z + tmp) % n;
  }
  return (z + n) % n;
}
int nod(int n) {
  if (n == 1) return 1;
  int lim = sqrt(n);
  int gun = 1;
  for (int i = 2; i <= lim; i++) {
    if (n % i) continue;
    int c = 0;
    while (n % i == 0) {
      c++;
      n /= i;
    }
    gun *= (c + 1);
  }
  if (n != 1) gun *= 2;
  return gun;
}
long long sod(int n) {
  if (n == 1) return 1;
  int lim = sqrt(n);
  long long gun = 1;
  for (int i = 2; i <= lim; i++) {
    if (n % i) continue;
    long long temp = i;
    while (n % temp == 0) {
      temp *= i;
    }
    n /= (temp / i);
    gun *= (temp - 1) / (i - 1);
  }
  if (n != 1) gun *= n + 1;
  return gun;
}
long long points[(100000 + 12)];
long long cmDist(int start, int current, int last) {
  long long now = abs(points[start] - current);
  now += abs(points[start] - points[last]);
  return now;
}
int main() {
  long long testCase, m, l, k, c, z, n, b, d, start;
  long long xx, yy;
  cin >> n >> b;
  for (int i = 0; i < n; i++) {
    cin >> points[i];
  }
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  sort(points, points + n);
  long long s1, s2, s3, s4;
  s1 = cmDist(1, b, n - 1);
  s2 = cmDist(0, b, n - 2);
  s3 = cmDist(n - 1, b, 1);
  s4 = cmDist(n - 2, b, 0);
  long long mn = min(s1, min(s2, min(s3, s4)));
  cout << mn << endl;
  return 0;
}

### Prompt

Please provide a CPP coded solution to the problem described below:

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;
int Set(int N, int pos) { return N = N | (1 << pos); }
int check(int N, int pos) { return N & (1 << pos); }
bool isLinier(int a, int b, int m, int n, int x, int y) {
  int t1, t2;
  t1 = (n - b) * (x - m);
  t2 = (y - n) * (m - a);
  if (t1 == t2)
    return true;
  else
    return false;
}
struct line {
  void values(double x, double y, double z) { a = x, b = y, c = z; }
  double a, b, c;
};
pair<double, double> sectionPoint(line l1, line l2) {
  double a1, b1, c1, a2, b2, c2, x, y, dx, dy, d;
  a1 = l1.a, b1 = l1.b;
  c1 = l1.c;
  a2 = l2.a;
  b2 = l2.b;
  c2 = l2.c;
  d = a1 * b2 - b1 * a2;
  if (d == 0) return make_pair(-1, -1);
  dx = c1 * b2 - c2 * b1;
  dy = a1 * c2 - a2 * c1;
  x = dx * 1.0 / d;
  y = dy * 1.0 / d;
  cout << x << endl << y << endl;
  return make_pair(x, y);
}
line equation(pair<double, double> point1, pair<double, double> point2) {
  double x1, x2, y1, y2;
  x1 = point1.first;
  y1 = point1.second;
  x2 = point2.first;
  y2 = point2.second;
  double kx, ky;
  line ret;
  kx = x1 - x2;
  ky = y1 - y2;
  ret.a = ky;
  ret.b = kx;
  ret.c = x1 * ky - y1 * kx;
  if (ret.a < 0) {
    ret.a *= -1;
    ret.b *= -1;
    ret.c *= -1;
  }
  cout << ret.a << "x+" << ret.b << "y=" << ret.c << endl;
  return ret;
}
double const eps = 1e-9;
long long manhattan(long long x1, long long y1, long long x2, long long y2) {
  return abs(x1 - x2) + abs(y1 - y2);
}
int bigPow(int a, int b, int m) {
  if (b == 1) return a % m;
  if (b == 0) return 1;
  long long res = bigPow(a, b / 2, m);
  res = (res * res) % (long long)m;
  if (b % 2) res = (res * a % m) % m;
  return res;
}
int MMI_Fermat(int a, int m) { return bigPow(a, m - 2, m); }
void ext_euclid(long long a, long long b, long long &x, long long &y,
                long long &g) {
  x = 0, y = 1, g = b;
  long long m, n, q, r;
  for (long long u = 1, v = 0; a != 0; g = a, a = r) {
    q = g / a, r = g % a;
    m = x - u * q, n = y - v * q;
    x = u, y = v, u = m, v = n;
  }
}
long long mod_inv(long long n, long long m) {
  long long x, y, gcd;
  ext_euclid(n, m, x, y, gcd);
  if (gcd != 1) return 0;
  return (x + m) % m;
}
long long crt(vector<long long> &a, vector<long long> &x) {
  long long z = 0;
  long long n = 1;
  for (int i = 0; i < x.size(); ++i) n *= x[i];
  for (int i = 0; i < a.size(); ++i) {
    long long tmp = (a[i] * (n / x[i])) % n;
    tmp = (tmp * mod_inv(n / x[i], x[i])) % n;
    z = (z + tmp) % n;
  }
  return (z + n) % n;
}
int nod(int n) {
  if (n == 1) return 1;
  int lim = sqrt(n);
  int gun = 1;
  for (int i = 2; i <= lim; i++) {
    if (n % i) continue;
    int c = 0;
    while (n % i == 0) {
      c++;
      n /= i;
    }
    gun *= (c + 1);
  }
  if (n != 1) gun *= 2;
  return gun;
}
long long sod(int n) {
  if (n == 1) return 1;
  int lim = sqrt(n);
  long long gun = 1;
  for (int i = 2; i <= lim; i++) {
    if (n % i) continue;
    long long temp = i;
    while (n % temp == 0) {
      temp *= i;
    }
    n /= (temp / i);
    gun *= (temp - 1) / (i - 1);
  }
  if (n != 1) gun *= n + 1;
  return gun;
}
long long points[(100000 + 12)];
long long cmDist(int start, int current, int last) {
  long long now = abs(points[start] - current);
  now += abs(points[start] - points[last]);
  return now;
}
int main() {
  long long testCase, m, l, k, c, z, n, b, d, start;
  long long xx, yy;
  cin >> n >> b;
  for (int i = 0; i < n; i++) {
    cin >> points[i];
  }
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  sort(points, points + n);
  long long s1, s2, s3, s4;
  s1 = cmDist(1, b, n - 1);
  s2 = cmDist(0, b, n - 2);
  s3 = cmDist(n - 1, b, 1);
  s4 = cmDist(n - 2, b, 0);
  long long mn = min(s1, min(s2, min(s3, s4)));
  cout << mn << endl;
  return 0;
}

```