N, M = map(int, input().split())

A = [int(input()) for i in range(M)]

for i in range(1, len(A)):
    if A[i]-A[i-1]==1:
        print(0)
        exit()

ans = 0

m = []
now = 0
rlt = 0
for a in A:
    n = a-now
    if n==1 or n==2: s = 1
    else: s = int((float(1)/2)*(pow(n-2,2)-n+2+4))

    m.append(s)
    now = a

n = N-now
if n==1 or n==2: s = 1
else: s = int((float(1)/2)*(pow(n-2,2)-n+2+4))
m.append(s)

ans = 1

for i in m:
    ans *= i

print(ans%1000000007)

