func_code_string: #include <bits/stdc++.h>   using namespace std;   int main() {     int n, a;     cin >> n >> a;     vector<int> checkpt;     for (int i = 0; i < n; i++) {       int t;       cin >> t;       checkpt.push_back(t);     }     sort(checkpt.begin(), checkpt.end());     long long distance = 0;     if (n == 1) {       cout << 0 << endl;       return 0;     }     if (checkpt[n - 1] <= a) {       distance += a - checkpt[1];       cout << distance << endl;       return 0;     } else if (a <= checkpt[0]) {       distance += checkpt[n - 2] - a;       cout << distance << endl;       return 0;     }     int pointer;     for (int i = 0; i < n - 1; i++) {       if (checkpt[i] <= a && checkpt[i + 1] >= a) {         checkpt.insert(checkpt.begin() + (i + 1), a);         pointer = i + 1;         break;       }     }     long long dis1 = 0;     long long dis2 = 0;     long long dis3 = 0;     long long dis4 = 0;     dis1 += checkpt[pointer] - checkpt[0];     if (pointer + 1 != n) {       dis1 += checkpt[n - 1] - checkpt[0];       dis3 += (checkpt[n - 1] - checkpt[pointer]) * 2;     }     dis3 += checkpt[pointer] - checkpt[0];     dis4 += checkpt[n] - checkpt[pointer];     if (pointer - 1 != 0) {       dis2 += (checkpt[pointer] - checkpt[1]) * 2;       dis4 += checkpt[n] - checkpt[1];     }     dis2 += checkpt[n] - checkpt[pointer];     long long min1 = min(dis1, dis2);     long long min2 = min(min1, dis3);     distance = min(min2, dis4);     cout << distance << endl;   }   