Problem:
Score : 300 points

Problem Statement

There is a staircase with N steps. Takahashi is now standing at the foot of the stairs, that is, on the 0-th step.
He can climb up one or two steps at a time.

However, the treads of the a_1-th, a_2-th, a_3-th, \ldots, a_M-th steps are broken, so it is dangerous to set foot on those steps.

How many are there to climb up to the top step, that is, the N-th step, without setting foot on the broken steps?
Find the count modulo 1\ 000\ 000\ 007.

Constraints

1 \leq N \leq 10^5

0 \leq M \leq N-1

1 \leq a_1 < a_2 < ... < a_M \leq N-1

Input

Input is given from Standard Input in the following format:

N M
a_1
a_2
.
.
.
a_M

Output

Print the number of ways to climb up the stairs under the condition, modulo 1\ 000\ 000\ 007.

Sample Input 1

6 1
3

Sample Output 1

4

There are four ways to climb up the stairs, as follows:

0 \to 1 \to 2 \to 4 \to 5 \to 6

0 \to 1 \to 2 \to 4 \to 6

0 \to 2 \to 4 \to 5 \to 6

0 \to 2 \to 4 \to 6

Sample Input 2

10 2
4
5

Sample Output 2

0

There may be no way to climb up the stairs without setting foot on the broken steps.

Sample Input 3

100 5
1
23
45
67
89

Sample Output 3

608200469

Be sure to print the count modulo 1\ 000\ 000\ 007.

Solution in Rust (1.15.1) (judge verdict: Accepted)

#![allow(unused_imports)]
#[macro_use]
mod reader {






    #![allow(dead_code)]
    use std;
    macro_rules! read_line((  ) => {
                           {
                           let mut input = String :: new (  ) ; std :: io ::
                           stdin (  ) . read_line ( & mut input ) . unwrap (
                           ) ; input } } ;);
    pub fn read_to_vec<T: std::str::FromStr>() -> Vec<T> {
        read_line!().split_whitespace().map(|e|
                                                e.parse().ok().unwrap()).collect()
    }
    pub fn read_parse<T: std::str::FromStr>() -> T {
        read_line!().trim().parse().ok().unwrap()
    }
}
#[macro_use]
mod misc {
    #![allow(dead_code)]
    use std;
    #[macro_export]
    macro_rules! bind_from_vec((
                               $ ( $ variable : ident ) , + = $ vector : expr
                               ) => {
                               let mut v = $ vector . clone (  ) . into_iter (
                                ) ; $ (
                               let $ variable = v . next (  ) . unwrap (  ) ;
                               ) + } ;);
}
mod calc {
    #![allow(dead_code)]
    use std;
    macro_rules! impl_trait(( $ tr : ident for $ ( $ int : ty ) , + ) => {
                            $ ( impl $ tr for $ int {  } ) + } ;);
    pub trait Integer: Copy + Eq + Ord + std::ops::Add<Output = Self> +
     std::ops::AddAssign + std::ops::Sub<Output = Self> +
     std::ops::SubAssign + std::ops::Mul<Output = Self> +
     std::ops::MulAssign + std::ops::Div<Output = Self> +
     std::ops::DivAssign + std::ops::Rem<Output = Self> +
     std::ops::RemAssign + std::ops::BitAnd<Output = Self> +
     std::ops::BitAndAssign + std::ops::BitOr<Output = Self> +
     std::ops::BitOrAssign + std::ops::BitXor<Output = Self> +
     std::ops::BitXorAssign + std::ops::Shl<usize, Output = Self> +
     std::ops::ShlAssign<usize> + std::ops::Shr<usize, Output = Self> +
     std::ops::ShrAssign<usize> {
    }
    impl_trait! (Integer for isize , i8 , i16 , i32 , i64 , usize , u8 , u16 ,
                 u32 , u64);
    pub trait UnsignedIndex<I: Into<u64>>: std::ops::Index<usize> {
        type
        Output: Copy;
        fn nth(&self, n: I)
        -> <Self as UnsignedIndex<I>>::Output;
    }
    impl <I: Into<u64>, T: Copy> UnsignedIndex<I> for Vec<T> {
        type
        Output
        =
        <Self as std::ops::Index<usize>>::Output;
        fn nth(&self, n: I) -> <Self as UnsignedIndex<I>>::Output {
            self[n.into() as usize]
        }
    }
    pub struct Factorial<T: Integer> {
        pub modulo: T,
        factorial: Vec<T>,
        inverse: Vec<T>,
        fac_inv: Vec<T>,
    }
    impl Factorial<u64> {
        pub fn init(max_init: u64, prime: u64) -> Factorial<u64> {
            let mut instance =
                Factorial{modulo: prime,
                          factorial: vec!(1 , 1),
                          inverse: vec!(0 , 1),
                          fac_inv: vec!(1 , 1),};
            instance.renew_max(max_init);
            instance
        }
        pub fn fac(&self, n: u64) -> u64 { self.factorial.nth(n) }
        pub fn fac_inv(&self, n: u64) -> u64 { self.fac_inv.nth(n) }
        pub fn max(&self) -> u64 { (self.factorial.len() - 1) as u64 }
        pub fn renew_max(&mut self, mut max: u64) {
            let prime = self.modulo;
            let max_old = self.max();
            if max <= max_old {
                return;
            } else if max >= prime { max = prime - 1; }
            let factorial = &mut self.factorial;
            let mut pred;
            let inverse = &mut self.inverse;
            let mut rem_inv;
            let fac_inv = &mut self.fac_inv;
            let mut pred_finv;
            for i in (max_old + 1)..(max + 1) {
                pred = factorial.nth(i - 1);
                rem_inv = inverse.nth(prime % i);
                pred_finv = fac_inv.nth(i - 1);
                factorial.push(pred * i % prime);
                inverse.push(((rem_inv + i - 1) / i * prime -
                                  prime / i * rem_inv) % prime);
                fac_inv.push(pred_finv * inverse.nth(i) % prime);
            }
        }
    }
    pub fn combination(fac: &Factorial<u64>, n: u64, k: u64) -> Option<u64> {
        if n >= k {
            Some(fac.fac(n) * fac.fac_inv(k) % fac.modulo * fac.fac_inv(n - k)
                     % fac.modulo)
        } else { None }
    }
}
use reader::*;
use misc::*;
use calc::*;
fn main() {
    const MOD: u64 = 1000000000 + 7;
    bind_from_vec!(n , m = read_to_vec :: < u64 > (  ));
    let mut steps: Vec<u64> = Vec::new();
    let mut pred: u64 = 0;
    let mut input: u64;
    for _ in 0..m {
        input = read_parse();
        if let Some(diff) = (input - 1).checked_sub(pred) {
            steps.push(diff);
        } else { println!(0); return; }
        pred = input + 1;
    }
    steps.push(n - pred);
    let fac = Factorial::init(100000, MOD);
    println!("{}" , steps . iter (  ) . fold (
             1 , | x , diff | x * ( 0 .. ( diff + 2 ) / 2 ) . fold (
             0 , | y , two | (
             y + combination ( & fac , diff - two , two ) . unwrap (  ) ) %
             MOD ) % MOD ));
}