#atcoder3
N,M = map(int,input().split())
a = []
for i in range(M):
    a.append(int(input()))

a.insert(0,-10)
a.append(-10)
route = True

abefore = -10
for i in range(M):
    if (abefore+1) == a[i]:
        route = False
    abefore = a[i] 

if route:
    ibefore = 0
    ans = 1
    for i in range(M):
        if(a[i+1] - ibefore - 1) != 0:
            ans = ans*(a[i+1] - ibefore - 1) 
        ibefore = a[i+1]
    if(N - a[M] - 1) != 0:
        ans = ans * (N - a[M] - 1)
    print(ans%1000000007)
else:
    print(0)
