func_code_string: #include <bits/stdc++.h>   using namespace std;   const double pi(3.14159265358979);   int a[100010], d[100010];   int main() {     int x, i, j, n;     scanf( %d , &n);     scanf( %d , &x);     for (i = 0; i < n; i++) cin >> a[i];     sort(a, a + n);     for (i = 0; i < n; i++) d[i] = abs(a[i] - x);     int ans = 0;     if (n == 1)       ans = 0;     else if (x >= a[n - 1])       ans = d[1];     else if (x <= a[0])       ans = d[n - 2];     else if (n == 2)       ans = min(d[0], d[1]);     else if (x > a[0] && x <= a[1])       ans = min(d[n - 1], min(2 * d[0] + d[n - 2], 2 * d[n - 2] + d[0]));     else if (x < a[n - 1] && x >= a[n - 2])       ans = min(d[0], min(2 * d[n - 1] + d[1], 2 * d[1] + d[n - 1]));     else       ans = min(2 * d[0] + d[n - 2],                 min(2 * d[n - 2] + d[0],                     min(2 * d[n - 1] + d[1], 2 * d[1] + d[n - 1])));     cout << ans;     return 0;   }   