#include <algorithm>
#include <iostream>
#include <vector>

int main()
{
    unsigned long long n, x;
    std::cin >> n >> x;

    std::vector<unsigned long long> neighbors(n);
    for (unsigned long long i = 0; i < n; i++)
    {
        std::cin >> neighbors[i];
    }

    std::sort(neighbors.begin(), neighbors.end());
    unsigned long long time = std::abs((long long)(x - neighbors[0]));
    for (unsigned long long i = 1; i < n; i++)
    {
        time += (neighbors[i] - neighbors[i - 1]);
    }

    std::cout << time;

    return 0;
}