// ---------- begin Lazy Segment Tree ----------
pub trait TE {
    type T: Clone;
    type E: Clone;
    fn fold(l: Self::T, r: Self::T) -> Self::T;
    fn eval(x: Self::T, f: Self::E) -> Self::T;
    fn merge(g: Self::E, h: Self::E) -> Self::E;
    fn e() -> Self::T;
    fn id() -> Self::E;
}

pub struct LazySegmentTree<R: TE> {
    size: usize,
    bit: usize,
    a: Vec<(R::T, R::E)>,
}

impl <R: TE> LazySegmentTree<R> {
    pub fn new(n: usize) -> LazySegmentTree<R> {
        let mut bit = 0;
        while (1 << bit) < n {
            bit += 1;
        }
        LazySegmentTree {
            size: 1 << bit,
            bit: bit,
            a: vec![(R::e(), R::id()); 2 << bit],
        }
    }
    pub fn build_by(z: &[R::T]) -> LazySegmentTree<R> {
        let n = z.len();
        let mut bit = 0;
        while (1 << bit) < n {
            bit += 1;
        }
        let mut a = vec![(R::e(), R::id()); 2 << bit];
        for (a, z) in a[(1 << bit)..].iter_mut().zip(z.iter()) {
            a.0 = z.clone();
        }
        for i in (1..(1 << bit)).rev() {
            let l = R::eval(a[2 * i].0.clone(), a[2 * i].1.clone());
            let r = R::eval(a[2 * i + 1].0.clone(), a[2 * i + 1].1.clone());
            a[i].0 = R::fold(l, r);
        }
        LazySegmentTree {
            size: 1 << bit,
            bit : bit,
            a: a,
        }
    }
    fn eval(&self, k: usize) -> R::T {
        R::eval(self.a[k].0.clone(), self.a[k].1.clone())
    }
    fn propagate(&mut self, x: usize) {
        let x = x + self.size;
        for i in (1..(self.bit + 1)).rev() {
            let k = x >> i;
            self.a[2 * k].1 = R::merge(self.a[2 * k].1.clone(), self.a[k].1.clone());
            self.a[2 * k + 1].1 = R::merge(self.a[2 * k + 1].1.clone(), self.a[k].1.clone());
            self.a[k].1 = R::id();
            self.a[k].0 = R::fold(self.eval(2 * k), self.eval(2 * k + 1));
        }
    }
    fn save(&mut self, x: usize) {
        let x = x + self.size;
        for i in 1..(self.bit + 1) {
            let k = x >> i;
            self.a[k].0 = R::fold(self.eval(2 * k), self.eval(2 * k + 1));
        }
    }
    pub fn update(&mut self, l: usize, r: usize, op: R::E) {
        self.propagate(l);
        self.propagate(r - 1);
        let mut x = l + self.size;
        let mut y = r + self.size;
        while x < y {
            if x & 1 == 1 {
                self.a[x].1 = R::merge(self.a[x].1.clone(), op.clone());
                x += 1;
            }
            if y & 1 == 1 {
                y -= 1;
                self.a[y].1 = R::merge(self.a[y].1.clone(), op.clone());
            }
            x >>= 1;
            y >>= 1;
        }
        self.save(l);
        self.save(r - 1);
    }
    pub fn find(&mut self, l: usize, r: usize) -> R::T {
        self.propagate(l);
        self.propagate(r - 1);
        let mut x = l + self.size;
        let mut y = r + self.size;
        let mut p = R::e();
        let mut q = R::e();
        while x < y {
            if x & 1 == 1 {
                p = R::fold(p, self.eval(x));
                x += 1;
            }
            if y & 1 == 1 {
                y -= 1;
                q = R::fold(self.eval(y), q);
            }
            x >>= 1;
            y >>= 1;
        }
        R::fold(p, q)
    }
}
// ---------- end Lazy Segment Tree ----------

use std::cmp::*;
use std::io::Read;

struct Negative;
impl TE for Negative {
    type T = (i64, i64);
    type E = i64;
    fn fold(l: Self::T, r: Self::T) -> Self::T {
        if l.0 + l.1 <= r.0 + r.1 {
            l
        } else {
            r
        }
    }
    fn eval(x: Self::T, f: Self::E) -> Self::T {
        (x.0 + f, x.1)
    }
    fn merge(g: Self::E, h: Self::E) -> Self::E {
        g + h
    }
    fn e() -> Self::T {
        (std::i64::MAX / 3, std::i64::MAX / 3)
    }
    fn id() -> Self::E {
        0
    }
}

struct Positive;
impl TE for Positive {
    type T = (i64, i64);
    type E = i64;
    fn fold(l: Self::T, r: Self::T) -> Self::T {
        if l.0 + r.1 <= r.0 + l.1 {
            l
        } else {
            r
        }
    }
    fn eval(x: Self::T, f: Self::E) -> Self::T {
        (x.0 + f, x.1)
    }
    fn merge(g: Self::E, h: Self::E) -> Self::E {
        g + h
    }
    fn e() -> Self::T {
        (std::i64::MAX / 3, 0)
    }
    fn id() -> Self::E {
        0
    }
}

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let q: usize = it.next().unwrap().parse().unwrap();
    let a: usize = it.next().unwrap().parse().unwrap();
    let b: usize = it.next().unwrap().parse().unwrap();
    let mut z: Vec<(i64, i64)> = (0..n).map(|k| (std::i64::MAX / 3, k as i64)).collect();
    z[a - 1].0 = 0;
    let mut pos = LazySegmentTree::<Positive>::build_by(&z);
    let mut neg = LazySegmentTree::<Negative>::build_by(&z);
    let mut now = b - 1;
    for _ in 0..q {
        let x: usize = it.next().unwrap().parse().unwrap();
        let x = x - 1;
        let d = (max(x, now) - min(x, now)) as i64;
        let l = pos.find(0, x + 1);
        let r = neg.find(x, n);
        neg.update(0, n, d);
        pos.update(0, n, d);
        let v = neg.find(now, now + 1);
        let u = min(l.0 + x as i64 - l.1, r.0 + r.1 - x as i64);
        if u < v.0 {
            neg.update(now, now + 1, u - v.0);
            pos.update(now, now + 1, u - v.0);
        }
        now = x;
    }
    let mut ans = std::i64::MAX;
    for i in 0..n {
        let v = pos.find(i, i + 1);
        ans = min(ans, v.0);
    }
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 35068