use std::str::FromStr;
use std::io::Read;
use std::ops::Sub;
use std::convert::From;
use std::ops::Div;
use std::ops::Mul;
use std::ops::Add;

const MODULO: u64 = 1_000_000_007;

#[derive(Copy, Clone)]
pub struct M64 {
    v: u64,
}

pub struct CombTable {
    factorial: Vec<M64>,
    fact_inv: Vec<M64>,
}

impl CombTable {
    pub fn new(val: u64) -> Self {
        let n = val as usize;
        let mut v = Vec::with_capacity(n + 1);
        v.push(M64::new(1));
        for i in 0..n {
            let prev = v[i];
            v.push(prev * M64::new((i + 1) as u64));
        }

        let mut vi = vec![M64::new(0); n + 1];
        vi[n] = v[n].pow(MODULO - 2);
        for i in 0..n {
            vi[n - i - 1] = vi[n - i] * M64::new((n - i) as u64);
        }
        CombTable {
            factorial: v,
            fact_inv: vi,
        }
    }

    pub fn comb(&self, n: u64, r: u64) -> M64 {
        let nu = n as usize;
        let ru = r as usize;
        self.factorial[nu] * self.fact_inv[ru] * self.fact_inv[nu - ru]
    }
}

pub trait Modulo {
    fn new(x: u64) -> Self;
    fn pow(&self, n: u64) -> M64;
    fn to_u64(&self) -> u64;
}

impl Modulo for M64 {
    fn new(x: u64) -> Self {
        M64 { v: x }
    }

    fn pow(&self, n: u64) -> M64 {
        let mut remain_multiple_count = n;
        let mut base_square = M64 { v: self.v };
        let mut current = M64 { v: 1 };
        while remain_multiple_count > 0 {
            if remain_multiple_count & 1 == 1 {
                current = current * base_square;
            }
            base_square = base_square * base_square;
            remain_multiple_count /= 2;
        }
        current
    }

    fn to_u64(&self) -> u64 {
        self.v
    }
}

impl Div for M64 {
    type Output = Self;
    fn div(self, other: Self) -> Self::Output {
        self * other.pow(MODULO - 2)
    }
}

impl Mul for M64 {
    type Output = Self;
    fn mul(self, other: Self) -> Self::Output {
        M64 { v: (self.v * other.v) % MODULO }
    }
}

impl Add for M64 {
    type Output = Self;
    fn add(self, other: Self) -> Self::Output {
        M64 { v: (self.v + other.v) % MODULO }
    }
}

pub trait AsZeroOrigin {
    fn as_zero_origin(self) -> Self;
}

pub trait AsZeroOriginWithMatrix {
    fn as_zero_origin(self) -> Self;
}

impl<T> AsZeroOrigin for Vec<T>
where
    T: Sub<T, Output = T> + From<u8>,
{
    fn as_zero_origin(self) -> Self {
        self.into_iter().map(|i| i - T::from(1)).collect()
    }
}

impl<T> AsZeroOriginWithMatrix for Vec<Vec<T>>
where
    T: Sub<T, Output = T> + From<u8>,
{
    fn as_zero_origin(self) -> Self {
        self.into_iter()
            .map(|v| v.into_iter().map(|i| i - T::from(1)).collect())
            .collect()
    }
}

pub trait Convert<T>
where
    T: FromStr,
{
    fn read_one(&mut self) -> T;
    fn to_vec(&mut self, n: usize) -> Vec<T>;
    fn to_matrix(&mut self, n: usize, m: usize) -> Vec<Vec<T>>;

    fn to_tuples<U>(&mut self, n: usize) -> Vec<(T, U)>
    where
        U: FromStr;
}

impl<'a, T> Convert<T> for ::std::str::SplitWhitespace<'a>
where
    T: FromStr,
{
    fn read_one(&mut self) -> T {
        let word = self.next().unwrap();
        word.parse().ok().unwrap()
    }

    fn to_vec(&mut self, n: usize) -> Vec<T> {
        (0..n)
            .map(|_| self.next().unwrap().parse().ok().unwrap())
            .collect::<Vec<_>>()
    }

    fn to_matrix(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.to_vec(m)).collect::<Vec<_>>()
    }

    fn to_tuples<U>(&mut self, n: usize) -> Vec<(T, U)>
    where
        U: FromStr,
    {
        (0..n)
            .map(|_| {
                let a = self.next().unwrap().parse().ok().unwrap();
                let b = self.next().unwrap().parse().ok().unwrap();
                (a, b)
            })
            .collect::<Vec<_>>()
    }
}

pub fn read_stdin() -> String {
    let mut s = String::new();
    ::std::io::stdin().read_to_string(&mut s).unwrap();
    s
}

trait Count {
    fn count(&self, n: u64) -> M64;
}

impl Count for CombTable {
    fn count(&self, n: u64) -> M64 {
        let mut sum = M64::new(n);
        for r in 2..(n / 2 + 1) {
            sum = sum + self.comb(n - r, r);
        }
        sum
    }
}

fn to_operations(n: u64, v: Vec<u64>) -> Vec<u64> {
    if v.is_empty() {
        return vec![n];
    }

    let mut out = Vec::new();
    out.push(v[0] - 1);
    if v.len() >= 2 {
        for w in v.windows(2) {
            out.push(w[1] - w[0] - 2);
        }
    }
    out.push(n - *v.last().unwrap() - 1);
    out.into_iter().filter(|&x| x > 0).collect()
}

fn evaluate(n: u64, v: Vec<u64>) -> u64 {
    if v.windows(2).any(|w| w[0] + 1 == w[1]) {
        return 0;
    }

    let table = CombTable::new(n);

    to_operations(n, v)
        .into_iter()
        .fold(M64::new(1), |st, x| st * table.count(x))
        .to_u64()
}

fn main() {
    let source = read_stdin();
    let mut iter = source.split_whitespace();
    let n = iter.read_one();
    let m = iter.read_one();
    let v: Vec<u64> = iter.to_vec(m);

    println!("{}", evaluate(n, v));
}


Measured memory_bytes: 6524