#include <bits/stdc++.h>
using namespace std;

#define int long long
#define inf 1000000007LL

#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define trep(i, n) for(int i = 0; i <= (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define mfor(i, s, t) for(int i = (s); i < (t); i++)
#define tfor(i, s, t) for(int i = (s); i <= (t); i++)

class Dinic {
public:
  vector<vector<pair<int, int>>> v;
  vector<int> e;

  vector<int> k;
  vector<int> j;

  void init(int n) {
    v = vector<vector<pair<int, int>>>(n);
    e = vector<int>();
    k = vector<int>(n);
    j = vector<int>(n);
  }
  void add_edge(int a, int b, int atob, int btoa = 0) {
    v[a].push_back(make_pair(b, e.size()));
    e.push_back(atob);
    v[b].push_back(make_pair(a, e.size()));
    e.push_back(btoa);
  }
  void dyk(int s) {
    for(auto& i : k) {
      i = inf;
    }
    queue<pair<int, int>> pq;
    pq.push(make_pair(0, s));
    while(!pq.empty()) {
      int w = pq.front().first;
      int b = pq.front().second;
      pq.pop();
      if(k[b] > w) {
        k[b] = w;
        for(auto i : v[b]) {
          if(e[i.second] > 0) {
            pq.push(make_pair(w + 1, i.first));
          }
        }
      }
    }
  }
  int dfs(int s, int t, int p, int c) {
    if(p == t) {
      return c;
    }
    int all = 0;
    while(c > all && j[p] < v[p].size()) {
      if(k[v[p][j[p]].first] == k[p] + 1) {
        int r = dfs(s, t, v[p][j[p]].first, min(c - all, e[v[p][j[p]].second]));
        e[v[p][j[p]].second] -= r;
        e[v[p][j[p]].second ^ 1] += r;
        if(r < c - all) {
          j[p]++;
        }
        all += r;
      }
      else {
        j[p]++;
      }
    }
    return all;
  }
  int solve(int s, int t) {
    int all = 0;
    while(1) {
      dyk(s);
      for(auto& i : j) {
        i = 0;
      }
      int r = dfs(s, t, s, inf);
      if(r == 0) {
        return all;
      }
      all += r;
    }
  }
};

class Rmq {
public:
  vector<int> d;
  int n;

  void init(int nw) {
    n = 1;
    while(n < nw) {
      n *= 2;
    }
    d.resize(n * 2);
    rep(i, n * 2) {
      d[i] = inf * inf;
    }
  }
  void set_(int b, int x, int p, int nb, int ne) {
    if(nb <= b && b < ne) {
      if(nb == ne - 1) {
        d[p] = min(d[p], x);
      }
      else {
        int m = (nb + ne) / 2;
        set_(b, x, p * 2 + 1, nb, m);
        set_(b, x, p * 2 + 2, m, ne);
        d[p] = min(d[p * 2 + 1], d[p * 2 + 2]);
      }
    }
  }
  void set(int b, int x) {
    set_(b, x, 0, 0, n);
  }
  int get_(int b, int e, int p, int nb, int ne) {
    if(b <= nb && ne <= e) {
      return d[p];
    }
    else if(ne <= b || e <= nb) {
      return inf * inf;
    }
    else {
      int m = (nb + ne) / 2;
      return min(get_(b, e, p * 2 + 1, nb, m), get_(b, e, p * 2 + 2, m, ne));
    }
  }
  int get(int b, int e) {
    return get_(b, e, 0, 0, n);
  }
};

int d[334334];

signed main() {
  int n, q, a, b;
  cin >> n >> q >> a >> b;
  vector<int> v;
  v.push_back(a);
  v.push_back(b);
  rep(i, q) {
    cin >> d[i];
    v.push_back(d[i]);
  }
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  Rmq fr, ba;
  fr.init(v.size());
  ba.init(v.size());
  int wa = lower_bound(v.begin(), v.end(), a) - v.begin();
  fr.set(wa, a - v.front());
  ba.set(wa, v.back() - a);
  int p = b;
  int all = 0;
  rep(i, q) {
    int wb = lower_bound(v.begin(), v.end(), d[i]) - v.begin();
    int w = min(ba.get(0, wb) - (v.back() - d[i]), fr.get(wb, v.size()) - (d[i] - v.front())) - abs(p - d[i]);
    int wq = lower_bound(v.begin(), v.end(), p) - v.begin();
    fr.set(wq, w + (p - v.front()));
    ba.set(wq, w + (v.back() - p));
    all += abs(p - d[i]);
    p = d[i];
  }
  int ans = inf * inf;
  rep(i, v.size()) {
    ans = min(ans, fr.get(i, i + 1) - (v[i] - v.front()) + all);
    ans = min(ans, ba.get(i, i + 1) - (v.back() - v[i]) + all);
  }
  cout << ans << endl;
}


Measured memory_bytes: 7664