#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using std::cerr;
using std::cin;
using std::cout;
using std::endl;

// This class is an obstacle class.
// You have to inherit it and override Compare() and QueryCompare().
template <typename T>
class SegmentTree {
private:
  // the size of original data.
  int range_;
  // initializer.
  T initializer_;
  // the data of SegTree. implemented as array.
  std::vector<T> tree_;
  // call Compare(int,int,int) recursively.
  void Merge(const int &parent);
  // return LeftChild's position from parent's position.
  int LeftChild(const int &parent);
  // RightChild version

  int RightChild(const int &parent);
  // return parent's position from left/right child's position.
  int Parent(const int &child);

  // The function which is used to answer a query internally.
  T PrivateQuery(const int &query_left, const int &query_right, const int &node,
                 const int &node_left, const int &node_right);

  // Compare two query and return the result.
  // This function is used to answer a query.
  // You must override this function.
  virtual T CompareQuery(const T &left, const T &right) = 0;
  // Compare LeftChild and RightChild,and update parent.
  // You must override this function.
  virtual T Compare(const T &left, const T &right) = 0;

public:
  // call Initialize().
  SegmentTree(const int &n, const T &initializer);
  // resize tree_ and initialize tree_ as initializer.
  void Initialize(const int &n, const T &initializer);
  // update pos and its parent, grandparent,
  // great grangparent, great great grandparent, and more...
  void Update(int pos, const T &data);
  // Throw query and get answer.
  // Range is [left,right).
  T Query(const int &left, const int &right);
  // output tree(for debugging).
  void OutputTree(void);
};

template <typename T>
int SegmentTree<T>::LeftChild(const int &parent) {
  if (range_ == 1) return 0;
  return parent * 2 + 1;
}
template <typename T>
int SegmentTree<T>::RightChild(const int &parent) {
  if (range_ == 1) return 0;
  return parent * 2 + 2;
}
template <typename T>
int SegmentTree<T>::Parent(const int &child) {
  if (range_ == 1) return 0;
  return (child - 1) / 2;
}

template <typename T>
SegmentTree<T>::SegmentTree(const int &n, const T &initializer) {
  Initialize(n, initializer);
}

template <typename T>
void SegmentTree<T>::Initialize(const int &n, const T &initializer) {
  int64_t temp = 1;
  while (temp < n) temp *= 2;  //要素数を2のべき乗にするといいらしい
  range_       = temp;
  initializer_ = initializer;

  tree_.resize(range_ * 2 - 1);
  for (int i = 0; i < tree_.size(); i++) {
    tree_[i] = initializer;
  }
}

template <typename T>
void SegmentTree<T>::Update(int pos, const T &data) {
  pos += range_ - 1;
  tree_[pos] = data;
  Merge(Parent(pos));
}

template <typename T>
void SegmentTree<T>::Merge(const int &parent) {
  tree_[parent] = Compare(tree_[LeftChild(parent)], tree_[RightChild(parent)]);
  if (parent > 0) Merge(Parent(parent));
}

template <typename T>
T SegmentTree<T>::Query(const int &left, const int &right) {
  return PrivateQuery(left, right, 0, 0, range_);
}
template <typename T>
T SegmentTree<T>::PrivateQuery(const int &query_left, const int &query_right,
                               const int &node, const int &node_left,
                               const int &node_right) {
  // cerr << query_left << "\t" << query_right << "\t" << node << "\t" <<
  // node_left
  //  << "\t" << node_right << endl;
  if (query_left <= node_left && node_right <= query_right) {
    // cerr << "return " << tree_[node] << endl;
    return tree_[node];
  }

  else if (node_right <= query_left || query_right <= node_left) {
    // cerr << "return " << initializer_ << endl;
    return initializer_;
  } else {
    T temp_l = PrivateQuery(query_left, query_right, LeftChild(node), node_left,
                            (node_left + node_right) / 2);
    T temp_r = PrivateQuery(query_left, query_right, RightChild(node),
                            (node_left + node_right) / 2, node_right);
    return CompareQuery(temp_l, temp_r);
  }
}

template <typename T>
void SegmentTree<T>::OutputTree(void) {
  cerr << "NodeNumber\tData" << endl;
  for (int i = 0; i < tree_.size(); i++) {
    cerr << i << "\t" << tree_[i] << endl;
  }
}

class RMQTree : public SegmentTree<int64_t> {
 private:
  int64_t CompareQuery(const int64_t &left, const int64_t &right)override;
  int64_t Compare(const int64_t &left, const int64_t &right)override;

 public:
  RMQTree(const int64_t &n, const int64_t &initializer) : SegmentTree(n,
  initializer){};
};
int64_t RMQTree::CompareQuery(const int64_t &left, const int64_t &right) {
  if (left < right)
    return left;
  else
    return right;
}
int64_t RMQTree::Compare(const int64_t &left, const int64_t &right) {
  if (left < right)
    return left;
  else
    return right;
}



int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int64_t n,q,a,b;
  cin>>n>>q>>a>>b;
  std::vector<int64_t> query(q+1);
  for(int i=1;i<=q;i++){
    cin>>query[i];
  }
  const int64_t INF=INT64_MAX/3;

  RMQTree dp_l(n+1,INF),dp_r(n+1,INF);

  for(int j=1;j<=n;j++){
    // //aをx1に, bをjに  aをjに，bをx1に
    // int v=std::min(abs(a-query[1])+abs(b-j),abs(a-j)+abs(b-query[1]));
    // dp_l.Update(j,v-j);
    // dp_r.Update(j,v+j);
    // dp_l.Update(j,-j);
    // dp_r.Update(j,j);
  }
  dp_l.Update(b,-b);
  dp_r.Update(b,b);
  query[0]=a;

  for(int i=0;i<q;i++){
    int64_t updater=std::min(dp_l.Query(1,query[i+1])+query[i+1],dp_r.Query(query[i+1],n+1)-query[i+1]);
    dp_l.Update(query[i],updater-query[i]-std::abs(query[i+1]-query[i]));
    dp_r.Update(query[i],updater+query[i]-std::abs(query[i+1]-query[i]));
  }

  int64_t result1=INF,result2=INF;
  int64_t cum=0;
  for(int i=0;i<=q-1;i++){
    cum+=std::abs(query[i]-query[i+1]);
  }
  for(int i=1;i<=n;i++){
    result1=std::min(result1,dp_l.Query(i,i+1)+i+cum);
    result2=std::min(result1,dp_r.Query(i,i+1)-i+cum);

  }
  assert(result1==result2);
  cout<<result1<<endl;


  return 0;
}

Measured memory_bytes: 9984