a,b=map(int,input().split())
l=[]
m=[]
ans=1
for i in range(a):
    m.append(2)
for i in range(b):
   
    t=int(input()) 
    if(t>=2):
        m[t]=m[t]-1
        m[t-1]=m[t-1]-1
        m[t-2]=m[t-2]-1
    else:
        m[t]=m[t]-1
        m[t-1]=m[t-1]-1
m[a-1]=m[a-1]-1
#print(m)
for i in m:
    if(i==0):
        ans=0
        break
    ans*=i
 
print(ans%1000000007)