import fs = require('fs')
const input = fs.readFileSync('/dev/stdin', 'utf8').split('\n')

const run = (n: number, m: number, a: number[]): void => {

    // 連番があれば解はない
    for (let i = 0; i < a.length - 1; i++) {
        if (a[i + 1] === a[i] + 1) {
            console.log(0)
            return
        }
    }
    // console.log(N, M, a)

    let cur = 0
    let pr = 1
    for (const next of a) {
        // calc cur to next-1
        const t = calc(cur, next - 1)
        // console.log(t)
        pr *= t

        cur = next + 1
    }
    // calc cur to N
    const as = calc(cur, n)
    // console.log(as)
    pr *= as
    // console.log(pr)
    console.log(pr % 1000000007)
}

const calc = (from: number, to: number): number => {
    const diff = to - from
    if (diff === 0 || diff === 1) return 1

    // let sum = 0
    // for (let i = diff; i <= diff / 2; i--) {

    // }
    return fibonacci(diff)
}

// const fibonacci = (p: number, n: number, max_num: number, index = 0): number => {
//     if (n > max_num) {
//         return n;
//     }
//     // console.log(n);
//     return fibonacci(n, n + p, max_num, index + 1);
// }
const fibonacci = (n: number): number => n === 0 || n === 1 ? 1 : fibonacci(n-1) + fibonacci(n-2);



const [N, M] = input[0].split(' ').map(Number)
const a = input.slice(1).map(Number)
run(N, M, a)

