n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
v=[a[0]-1]
ans=1

def x(z):
    if z>1:
        return x(z-1)+z-2
    else:
        return 2
if m==1:
    v.append(n-a[0]-1)
    
else:
    for i in range(m-1):
        v.append(a[i+1]-a[i]-1)
    v.append(n-a[m-1]-1)
    
if v[1:].count(0)>=1:
    print(0)
    exit()

for i in range(m+1):
    if v[i]==1 or v[i]==0:
        pass
    else:
        ans*=x(v[i])
        if ans>=1000000007: 
            ans=ans%1000000007
print(ans)