#!/usr/bin/python3
# -*- coding: utf-8 -*-

N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
way = []

k = ((a[0]-1) - 0) - 1
tmp = 1 # noskip
for i in range(k//2+1):
    #print(i)
    tmp += k - 2*i
way.append(tmp)

for i in range(1, M):
    if a[i] - a[i-1] == 1:
        print(0)
        exit()
    else:
        k = ((a[i]-1) - (a[i-1]+1)) - 1
        tmp = 1 # noskip
        for i in range(k//2+1):
            tmp += k - 2*i
        way.append(tmp)

k = (N - (a[M-1]+1)) - 1
tmp = 1 # noskip
for i in range(k//2+1):
    tmp += k - 2*i
way.append(tmp)

#print(way)
res = 1
for tmp in way:
    res *= tmp
res = res % 1000000007
print(res)